asp.net-mvc – Sitecore搜索方面和计算字段
发布时间:2020-12-16 09:20:23 所属栏目:asp.Net 来源:网络整理
导读:我有10篇文章内容项,每篇文章项都有一个贡献者清单 我在编辑器中为分面搜索创建了一个贡献者方面.但是核对表值被索引为字符串id. 现在在搜索结果页面上,构面值显示为字符串ID. 我创建了一个ComputedField来索引显示名称 public class Contributors : IComput
我有10篇文章内容项,每篇文章项都有一个贡献者清单
我在编辑器中为分面搜索创建了一个贡献者方面.但是核对表值被索引为字符串id. 现在在搜索结果页面上,构面值显示为字符串ID. public class Contributors : IComputedIndexField { public object ComputeFieldValue(IIndexable indexable) { var item = indexable as SitecoreIndexableItem; if (item == null || item.Item == null) return string.Empty; StringBuilder ContributorsNameList = new StringBuilder(); IIndexableDataField cField = indexable.GetFieldByName("Contributors"); if (cField != null) { var cList = cField.Value.ToString().Split(new[] { '|' },StringSplitOptions.RemoveEmptyEntries).ToList(); foreach (var cId in cList) { var cItem = item.Item.Database.GetItem(new ID(cId)); if (cItem != null) ContributorsNameList.Append(cItem.Name.ToString()); } return ContributorsNameList; } return null; } public string FieldName { get; set; } public string ReturnType { get; set; } } 和配置文件 <?xml version="1.0" encoding="utf-8" ?> <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> <sitecore> <contentSearch> <configuration> <defaultIndexConfiguration> <fields hint="raw:AddComputedIndexField"> <field fieldName="tagsfacet" storageType="yes" indexType="untokenized"> Sandbox.SitecoreCustomizations.ComputedIndexFields.TagsFacet,Sandbox</field> </fields> <fields hint="raw:AddFieldByFieldName"> <field fieldName="tagsfacet" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration,Sitecore.ContentSearch.LuceneProvider"> <Analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer,Sitecore.ContentSearch.LuceneProvider" /> </field> </fields> </defaultIndexConfiguration> </configuration> </contentSearch> </sitecore> </configuration> 但现在得到id和名字(发生两次) 解决方法
你需要看看BucketConfiguration.ResolveFacetValueToFriendlyName
在Sitecore.Buckets.config中. <!-- RESOLVE FACET VALUE TO FRIENDLY NAME If you are storing a field in the index that is being faceted on,it may be stored as an ID. This Setting when set to true,will try and resolve this to the friendly item name instead. USAGE: In an environment with huge amounts of items (e.g. 1 Million),this will not scale properly. --> <setting name="BucketConfiguration.ResolveFacetValueToFriendlyName" value="false"/> 将此值修补为true,它应该可以正常工作. 这样您的ComputedField就会过时. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-core – 将绝对文件路径转换为相对路径
- 剃刀 – 从另一个TagHelper调用TagHelpers?
- asp.net-mvc-3 – 另一个数据库实例RavenDB MVC3已经使用的
- asp.net – UpdatePanel回发后调用Javascript函数问题
- asp.net-mvc – 在调用action之前发生的ASP.NET MVC事件?
- ASP.NET EF实体主外键关系
- asp.net-mvc – 调试流畅的验证规则
- asp.net – 如何在设计模式下打开RDLC
- asp.net-mvc – 如何在远程验证中使用多个AdditionalField
- asp.net-mvc – 使用jQuery ASP.NET MVC自动保存表单输入
推荐文章
站长推荐
热点阅读