【问题标题】:Custom Sitecore index configuration for Solr implementationSolr 实施的自定义 Sitecore 索引配置
【发布时间】:2017-03-13 18:57:56
【问题描述】:

我在 Sitecore 中有一个自定义索引,我最初创建该索引是为了使用 Lucene。为了这个问题,我们称该索引为“新闻”。我正在将所有 Lucene 索引转换为 Solr。每个站点核心索引(包括新闻索引)都有一个单独的 Solr 核心。所有索引都在重建,我在 Solr 中看到默认 OOTB Sitecore 索引的文档,但没有文档被添加到 Solr 中的 News Core。我用于新闻核心的模式是通过控制面板中的 Sitecore 模式生成工具生成的。是否需要修改此架构以反映我在 Sitecore 索引配置文件中指定的字段?

<sitecore>
 <contentSearch>
  <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
    <indexes hint="list:AddIndex">
      <index id="News" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
        <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/defaultSolrIndexConfiguration">

          <documentOptions ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/documentOptions">

            <indexAllFields>true</indexAllFields>

            <!-- Included templates -->
            <include hint="list:AddIncludedTemplate">
              <template1>{3139428E-AF1E-4678-916F-08B2A44453E7}</template1>
              <template2>{C74B549F-9A1D-4FE3-8A3E-F4CF778DCD3C}</template2>
              <template3>{E29A6486-5721-4FAA-A5F7-B3CC3AD81DB1}</template3>
              <template4>{D5ED7AB3-D466-4CED-A739-B55D9E39FAE7}</template4>
              <template5>{AB86861A-6030-46C5-B394-E8F99E8B87DB}</template5>
              <template6>{9E349B58-3F90-450C-A7EE-B904AC59D14B}</template6>
            </include>
          </documentOptions>
          <fieldMap type="Sitecore.ContentSearch.FieldMap, Sitecore.ContentSearch">
            <fieldNames hint="raw:AddFieldByFieldName">
              <field fieldName="_uniqueid" 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>
              <field fieldName="article" 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>
              <field fieldName="author" 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>
              <field fieldName="author credentials" 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>
              <field fieldName="date" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.DateTime" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
                <analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
              </field>
              <field fieldName="degree" 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>
              <field fieldName="graduation year" 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>
             <field fieldName="location" 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>
              <field fieldName="navigation title" 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>
              <field fieldName="page abstract" 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>
              <field fieldName="parentname" 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>
              <field fieldName="school" 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>
              <field fieldName="text" 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>
             <field fieldName="url" 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>
              <field fieldName="value" 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>
            </fieldNames>
            <fieldTypes hint="raw:AddFieldByFieldTypeName">
              <fieldType fieldTypeName="image" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String"   settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
              <fieldType fieldTypeName="general link" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String"   settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider" />
            </fieldTypes>
          </fieldMap>
          <fields hint="raw:AddComputedIndexField">
            <field fieldName="external_link" stored="true" returnType="System.String">mydll.ExternalLink, mydll</field>
            <field fieldName="image" stored="true" returnType="System.String">mydll.ComputedFields.Image, mydll</field>
            <field fieldName="terms" stored="true" returnType="System.String">mydll.ComputedFields.Terms, mydll</field>
            <field fieldName="url" stored="true" returnType="System.String">mydll.ComputedFields.Url, mydll</field>
            <field fieldName="parentname" stored="true" returnType="System.String">mydll.ComputedFields.ParentName, mydll</field>
          </fields>

        </configuration>

        <strategies hint="list:AddStrategy">
          <!-- NOTE: order of these is controls the execution order -->
          <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" />
        </strategies>
        <commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
          <policies hint="list:AddCommitPolicy">
            <policy type="Sitecore.ContentSearch.ModificationCountCommitPolicy, Sitecore.ContentSearch">
              <Limit>300</Limit>
            </policy>
          </policies>
        </commitPolicyExecutor>

        <locations hint="list:AddCrawler">
          <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
            <Database>web</Database>
            <Root>/sitecore/content</Root>
          </crawler>
        </locations>

        <enableItemLanguageFallback>false</enableItemLanguageFallback>
        <enableFieldLanguageFallback>false</enableFieldLanguageFallback>

      </index>
    </indexes>
   </configuration>
  </contentSearch>
 </sitecore>

【问题讨论】:

  • 问题不会出在架构中,而可能出在索引配置中。对于自定义索引,Lucene 和 Solr 之间存在一些差异。您能分享一下以提供更好的帮助吗?
  • @Gatogordo 我已经编辑了答案以显示自定义配置

标签: indexing solr lucene sitecore


【解决方案1】:

有几点需要改变:

  • 将您的索引重命名为“新闻”(在索引名称中使用大写时我遇到了一些问题)
  • indexAllFields 移到documentOptions 之外(它必须在configuration 下使用Solr - 与documentOptions 处于同一级别)
  • ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/fieldMap 添加到您的fieldMap 元素中。
  • 重做你的fieldMap - 你在这里使用Lucene fieldMap。您可以查看默认的 Solr 配置,以获取有关如何使用 Solr 执行此操作的示例 - 它看起来更像 &lt;field fieldName="article" returnType="string" /&gt; 等等..
  • 重做你的fieldTypes,因为那仍然是指Lucene

最好的办法是将默认的 Solr 配置放在您的自定义配置旁边,以提供有关如何设置所有元素的示例。

【讨论】:

  • 谢谢!我的配置文件都搞砸了。感谢您为我指明正确的方向。我能够解决这个问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-01-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多