6

Sitecore CMS+DMS 6.6.0 rev.130404 => 7.0 rev.130424

在我们的项目中,我们一直使用 AdvancedDatabaseCrawler (ADC) 作为我们的索引(特别是因为它的动态字段功能)。这是一个示例索引配置:

<index id="GeoIndex" type="Sitecore.Search.Index, Sitecore.Kernel">
<param desc="name">$(id)</param>
<param desc="folder">$(id)</param>
<analyzer ref="search/analyzer" />
<locations hint="list:AddCrawler">
  <web type="scSearchContrib.Crawler.Crawlers.AdvancedDatabaseCrawler, scSearchContrib.Crawler">
    <database>web</database>
    <root>/sitecore/content/Globals/Locations</root>
    <IndexAllFields>true</IndexAllFields>
    <include hint="list:IncludeTemplate">
      <!--Suburb Template-->
      <suburb>{FF0D64AA-DCB4-467A-A310-FF905F9393C0}</suburb>
    </include>
    <dynamicFields hint="raw:AddDynamicFields">
      <dynamicField type="OurApp.CustomSearchFields.SearchTextField,OurApp" name="search text" storageType="NO" indexType="TOKENIZED" vectorType="NO" />
      <dynamicField type="OurApp.CustomSearchFields.LongNameField,OurApp" name="display name" storageType="YES" indexType="UN_TOKENIZED" vectorType="NO" />
    </dynamicFields>
  </web>
</locations>
</index>

如您所见,我们scSearchContrib.Crawler.Crawlers.AdvancedDatabaseCrawler用作爬虫,它使用<dynamicFields hint="raw:AddDynamicFields">部分内定义的字段将自定义字段注入索引。

现在我们正在将我们的项目升级到 sitecore 7。在 Sitecore 7 中,他们将 DynamicFields 功能从 ADC 移植到了 sitecore。我找到了一些关于这方面的文章,并将我们的自定义搜索字段类转换为实现 sitecore 7接口,而不是从ADC 中的类IComputedIndexField继承。BaseDynamicField现在我的问题是如何更改索引配置以匹配新的 sitecore 7 API。网上有一些零碎的东西,但找不到转换配置所需的所有示例。有人可以帮我吗?

当我这样做时,我的印象是我们不必重建我们的索引,因为它仍然在内部使用 Lucene。我不想更改索引结构。只想将代码和配置从 AdvancedDatabaseCrawler 升级到 Sitecore 7。我应该担心破坏我们现有的索引吗?请对此也有所了解。

谢谢

4

2 回答 2

7

一些快速的澄清:)

我们没有将 ADC 合并到 Sitecore 7 中,该ContentSearch层是对 Sitecore 旧搜索层的完全重写。我们从 ADC 中提取了一些核心概念,例如动态字段,并将它们放入新的实现中(如 ComputedFields)。它们不是 1:1 兼容的,您必须在索引上做一些工作。

Lucene 的版本也已从 2.* 升级到 3.0.3,因此无论如何都需要重新创建所有索引,因为它们是 Lucene 的一个非常不同的版本。

这里有两个选项,旧的 Lucene 搜索(Sitecore.Search 命名空间)(ADC 是基于它构建的)没有被触及,并且仍然可以以相同的方式工作,尽管我不确定 ADC 与 Sitecore 7 的兼容性是否在理论上现在已被取代。

下一个选项是更新您的索引以利用 Sitecore 7 的新搜索功能。您拥有的配置不会直接兼容,但是,虽然您需要将索引重新设计为新配置,但基本概念应该是熟悉的给你。您拥有的动态字段应该在逻辑上映射到 ComputedFields(索引项目时计算的字段),其他一切都很简单。

虽然它看起来像很多额外的配置ContentSearch,但它是您不需要触摸的默认配置,您只需要覆盖要添加的计算字段和要包含的模板的配置部分。

可以在此处找到创建自己的配置覆盖的示例:http: //www.mikkelhm.dk/post/2013/10/12/Defining-a-custom-index-in-Sitecore-7-and-utilizing-it .aspx

我还建议您确保升级到 7.0 rev。131127 (7.0 Update-3) 因为这修复了您当前拥有的版本中 IncludeTemplates 逻辑中的错误。

于 2013-12-20T09:37:46.117 回答
4

我设法转换了 sitecore ContentSearch API 的索引配置。查看 Sitecore 默认索引配置对此有很大帮助。

注意:正如 Stephen 也提到的,<include hint="list:IncludeTemplate">在 Sitecore 7.0 初始版本中不起作用。它已在 Sitecore 7.0 rev 中修复。131127(7.0 Update-3),我打算升级到它。

这是John West撰写的一篇关于sitecore 7 索引更新策略的好文章。它将帮助您以您想要的方式配置索引。

转换后的配置:

<sitecore>
<contentSearch>
  <configuration type="Sitecore.ContentSearch.LuceneProvider.LuceneSearchConfiguration, Sitecore.ContentSearch.LuceneProvider">
    <DefaultIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
      <IndexAllFields>true</IndexAllFields>
      <include hint="list:IncludeTemplate">
        <!--Suburb Template-->
        <suburb>{FF0D64AA-DCB4-467A-A310-FF905F9393C0}</suburb>
      </include>
      <fields hint="raw:AddComputedIndexField">
        <field fieldName="search text" storageType="NO" indexType="TOKENIZED" vectorType="NO">OurApp.CustomSearchFields.SearchTextField,OurApp</field>
        <field fieldName="display name" storageType="YES" indexType="UN_TOKENIZED" vectorType="NO">OurApp.CustomSearchFields.LongNameField,OurApp</field>
      </fields>
    </DefaultIndexConfiguration>
    <indexes hint="list:AddIndex">
      <index id="GeoIndex" 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/databasePropertyStore" param1="$(id)" />
        <strategies hint="list:AddStrategy">
          <!-- NOTE: order of these is controls the execution order -->
          <strategy ref="contentSearch/indexUpdateStrategies/onPublishEndAsync" />
        </strategies>
        <commitPolicy hint="raw:SetCommitPolicy">
          <policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
        </commitPolicy>
        <commitPolicyExecutor hint="raw:SetCommitPolicyExecutor">
          <policyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch" />
        </commitPolicyExecutor>
        <locations hint="list:AddCrawler">
          <crawler type="Sitecore.ContentSearch.LuceneProvider.Crawlers.DefaultCrawler, Sitecore.ContentSearch.LuceneProvider">
            <Database>web</Database>
            <Root>/sitecore/content/Globals/Countries</Root>
          </crawler>
        </locations>
      </index>
    </indexes>
  </configuration>
</contentSearch>
</sitecore>
于 2013-12-23T03:33:19.363 回答