search - 搜索结果转换中的多个索引不适用于 Kentico
问题描述
我有两种不同的索引,至少在我的本地索引的搜索预览中都可以正常工作。我将它们都添加到索引区域的智能搜索部分,一个是页面爬虫,第二个是在媒体库中搜索的自定义索引。问题是结果只与爬虫的结果匹配,并且没有显示任何自定义索引。我认为问题在于我的 smartSearchResults 转换,因为每次我尝试从自定义索引中添加一个字段时,我都会收到该值不存在的错误。我的问题是如何使用两个索引来检索同一 Web 部件中的所有结果?
这就是变形的样子
<div class="result">
<!-- Search result title -->
<div>
<a href='<%# SearchResultUrl() %>'>
<%#SearchHighlight(HTMLHelper.HTMLEncode(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), "/"))), "<span style='font-weight:bold;'>", "</span>")%>
</a>
</div>
<p class="content">
<%#
IfCompare(GetSearchValue("UseCustomContent"), true,
SearchHighlight(LimitLength(HTMLHelper.StripTags(Eval<string>("Content")), 280), "<strong>", "</strong>"),
SearchHighlight(LimitLength(HTMLHelper.StripTags(GetSearchValue("CustomContent").ToString()), 280), "<strong>", "</strong>")
)
%>
</p><!-- content -->
<%-- MEDIA LIBRARY CONTENT--%>
<div>
<%#GetSearchValue("FileName") %>
</div>
<div class="file">
<i class="<%# GetFileIconClass(Eval<string>("documentExtensions")) %>"></i>
</div><!-- file -->
</div>
</div>
但我没有收到任何结果消息
解决方案
在尝试使用它之前,您必须检查该值是否存在。您可以为此使用 IfEmpty。一个例子:
<%# IfEmpty(GetSearchValue("Email"),"","<span class='label'>Email</span>")%>
<%# IfEmpty(GetSearchValue("Email"),"",GetSearchValue("Email"))%>
推荐阅读
- ios - NSMutableAttributedString 文本颜色无法正常工作
- swift - Swift:检查 customview 是否符合协议
- jquery - 动态添加文本框并在数据库中保存数据
- java - 使用类名启动线程
- wordpress - WordPress:如何检查搜索结果是否是页面的帖子?
- javascript - 使用 Socket.io 广播消息的问题
- java - 卡住 String.replace java 用正则表达式
- mongodb - 我的 mongodb 更新中的竞争条件?(使用流星)
- javascript - 由于 JS 导致的 iphone 键盘循环
- javascript - 如何为现有的 Javascript 库创建 Angular 库包装器?