Sitecore:索引 Treelist 字段时出错?

Sitecore: Error when indexing Treelist field?

我在 Sitecore 中有一个索引。被索引的模板字段之一是名为 "tags" 的树列表字段。当我使用 Luke 检查索引时,我看到了该字段并且它有值。

1.) 标签索引中的值是所选树列表项目的 ID -- 我需要它作为显示名称。

2.) 现在我的抓取日志充满了:

WARN You have specified both IncludeTemplates and ExcludeTemplates. This logic is not supported. Exclude templates will be ignored.

这是我的索引配置,但显然我有一些不正确的地方:

<index id="knowledge_center_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
    <param desc="name">$(id)</param>
    <param desc="folder">$(id)</param>
    <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
    <configuration ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration">
        <include hint="list:IncludeTemplate">
            <generalTemplatePage>{AD63DB1D-A3A5-4D16-9F19-7D878BBE2568}</generalTemplatePage>
            <newsPage>{85901309-D07C-447B-97DA-EA6F1581832C}</newsPage>
            <inTheNewsPage>{C49A9219-231D-42C6-AED2-9115CC241247}</inTheNewsPage>
        </include>
        <IndexAllFields>true</IndexAllFields>
        <fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
            <fieldNames hint="raw:AddFieldByFieldName">
                <fieldType fieldName="tags" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
            </fieldNames>
        </fieldMap>
    </configuration>
    <strategies hint="list:AddStrategy">
        <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" />
        <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/remoteRebuild" />
    </strategies>
    <commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
        <policies hint="list:AddCommitPolicy">
            <policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
        </policies>
    </commitPolicyExecutor>
    <locations hint="list:AddCrawler">
        <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
            <Database>web</Database>
            <Root>/sitecore/content/Sites/My Site/Knowledge Center</Root>
        </crawler>
    </locations>
</index>

更新:@Marek Musielak——对于#1,我遵循了你在回答中指出的 link 并且在我的 Crawling.logs 中一遍又一遍地遇到这种错误:

6272 12:49:18 ERROR Could not compute value for ComputedIndexField: potential for indexable: sitecore://master/{2D06E798-6BFE-4089-A610-5C341BF28B09}?lang=en&ver=3 Exception: System.Reflection.TargetInvocationException Message: Exception has been thrown by the target of an invocation. Source: mscorlib at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.CreateObject(Type type, Object[] parameters) at Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert) at Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) at Sitecore.Configuration.Factory.GetInnerObject(XmlNode paramNode, String[] parameters, Boolean assert) at Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper) at Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) at Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert) at Sitecore.Analytics.Reporting.ReportingQueryBase..ctor(ReportDataProviderBase reportProvider, CachingPolicy cachingPolicy) at Sitecore.ContentTesting.Analytics.Reporting.TestPotentialQuery..ctor(ReportDataProviderBase reportProvider) at Sitecore.ContentTesting.ContentSearch.ComputedIndexFields.TestPotentialMetricBase.ComputeFieldValue(IIndexable indexable) at Sitecore.ContentSearch.LuceneProvider.LuceneDocumentBuilder.AddComputedIndexFields()

Nested Exception

Exception: System.Reflection.TargetInvocationException Message: Exception has been thrown by the target of an invocation. Source: mscorlib at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Reflection.ReflectionUtil.CreateObject(Type type, Object[] parameters) at Sitecore.Configuration.Factory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert) at Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) at Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert) at Sitecore.Analytics.Reports.StimulsoftIntegration.BuiltInFunctionsReportDataSource..ctor()

Nested Exception

Exception: System.InvalidOperationException Message: Cannot use DataAdapterProvider as Analytics is disabled. Source: Sitecore.Analytics.MongoDB at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider..ctor(Func`2 driverFactory)

为什么要关心是否禁用了分析?


更新 2:@Rogier

我需要将 fieldMap 移动到 defaultLuceneIndexConfiguration 中:

<defaultLuceneIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
<fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
    <fieldNames hint="raw:AddFieldByFieldName">
        <field patch:before="field[0]" fieldName="tags" storageType="YES" indexType="UNTOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
    </fieldNames>
</fieldMap>
<fields hint="raw:AddComputedIndexField">
    <field patch:before="field[0]" fieldName="tags">MyNamespace.Search.ComputedFields, MyNamespace.Search</field>
</fields>

主索引补丁最终看起来像:

<index id="knowledge_center_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
    <param desc="name">$(id)</param>
    <param desc="folder">$(id)</param>
    <!-- This initializes index property store. Id has to be set to the index id -->
    <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
    <configuration ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration">
        <include hint="list:IncludeTemplate">
            <generalTemplatePage>{AD63DB1D-A3A5-4D16-9F19-7D878BBE2568}</generalTemplatePage>
            <newsPage>{85901309-D07C-447B-97DA-EA6F1581832C}</newsPage>
            <inTheNewsPage>{C49A9219-231D-42C6-AED2-9115CC241247}</inTheNewsPage>
        </include>
        <IndexAllFields>true</IndexAllFields>
    </configuration>
    <strategies hint="list:AddStrategy">
        <!-- NOTE: order of these is controls the execution order -->
        <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" />
        <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/remoteRebuild" />
    </strategies>
    <commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
        <policies hint="list:AddCommitPolicy">
            <policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
        </policies>
    </commitPolicyExecutor>
    <locations hint="list:AddCrawler">
        <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
            <Database>web</Database>
            <Root>/sitecore/content/Sites/My Site/Knowledge Center</Root>
        </crawler>
    </locations>

希望对您有所帮助...

广告 1):

默认情况下,Sitecore 索引所选项目的 ID。原因很简单:让我们暂时假设 Sitecore 存储标签的名称。假设您为 MyArticle 项选择了 TagATagB。 Sitecore 为您的 MyArticle 项目编制索引,并在索引中保存 TagATagB 值。现在您将 TagA 重命名为 Other TagA。 Sitecore 不会重新抓取您的 MyArticle 因为它没有改变(只有标签项目改变了)。所以你的 MyArticle 项目在索引中有不正确的值 - 它仍然 TagA 在那里。

当然,如果您知道自己 永远不会 更改任何标签的名称(或显示名称),您可以轻松创建一个计算字段,它将保留项目显示名称。在此博客 post 中有如何执行此操作的示例:Computed index field for MultiList type field

广告 2):

只要进入/sitecore/admin/showconfig.aspx页面,检查是否有定义ExcludeTemplate的地方。然后在您的 App_Config\Include 文件夹中跟踪该条目,瞧。