是否有人在使用SOLR时为关键字标记器提供了sitecore索引配置的示例?我试图在一个有多个字串的字段上进行分面,但是当前返回的面将字段中的单词和返回的面分开。
例如:我有一个州领域的项目,我试图在州领域--它的价值像新罕布什尔州,南达科他州。但是在结果中,我得到了
名称=新,聚合= xx
名字=汉普郡,合计= xx
名称=南方,聚合= xx
名称=达科他州,合计= xx
有人能帮我找到正确的配置来改变这个吗?
这是我的当前配置:
<index id="site_search_web_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
<param desc="name">$(id)</param>
<param desc="core">site_search_web</param>
<param desc="propertyStore" ref="contentSearch/databasePropertyStore" param1="$(id)" />
<strategies hint="list:AddStrategy">
<strategy ref="contentSearch/indexUpdateStrategies/onPublishEndAsync" />
</strategies>
<locations hint="list:AddCrawler">
<crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
<Database>web</Database>
<Root>/sitecore/content/Home</Root>
</crawler>
</locations>
</index>发布于 2015-01-30 10:00:31
您可以通过下列解决方案之一实现这一目标:
解决方案1
您可以创建一个计算字段,该字段返回facet值,并将计算字段类型设置为"string“,以避免标记化。您的计算字段应该如下所示:
public class TitleComputedField : IComputedIndexField
{
public object ComputeFieldValue(IIndexable indexable)
{
if (indexable == null) throw new ArgumentNullException("indexable");
var scIndexable = indexable as SitecoreIndexableItem;
if (scIndexable == null)
{
Log.Warn(
this + " : unsupported IIndexable type : " + indexable.GetType(), this);
return false;
}
var item = (Item)scIndexable;
if (item == null)
{
Log.Warn(
this + " : unsupported SitecoreIndexableItem type : " + scIndexable.GetType(), this);
return false;
}
if (String.Compare(item.Database.Name, "core", StringComparison.OrdinalIgnoreCase) == 0)
{
return false;
}
return = item.Fields["Title"];
}
public string FieldName { get; set; }
public string ReturnType { get; set; }
}并按照以下方式配置Sitecore.ContentSearch.Solr.Indexes.config中的计算字段:
<fields hint="raw:AddComputedIndexField">
...
<field fieldName="plaintitle" returnType="string">YourNamespace.TitleComputedField, YourAssembly</field>
</fields>最后,如果您在“平面标题”字段上,您应该得到预期的结果。
解决方案2
可以通过更新solr schema.xml在索引级别上创建字段,如下所示:
在字符串类型的solr中创建一个新字段
<fields>
...
<field name="plaintitle" type="string" indexed="true" stored="true" />
</fields>然后创建一个“复制字段”,将原始字段复制到新字段中。
<copyField source="title_t" dest="plaintitle" />在这两种解决方案中,您都可以使用以下代码对新字段进行分面:
query.FacetOn(i => i["plaintitle"]);https://stackoverflow.com/questions/28116532
复制相似问题