将sitecore 6.6索引配置升级到sitecore 7(使用ComputedFields)

时间:2013-12-20 03:25:20

标签: indexing sitecore lucene.net sitecore6 sitecore7

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 IComputedIndexField接口,而不是继承ADC中的BaseDynamicField类。现在我的问题是如何更改索引配置以匹配新的sitecore 7 API。网上有点点零碎,但找不到转换配置所需的所有示例。有人可以帮我吗?

虽然我这样做,但我认为我们不必重建索引,因为它仍在内部使用Lucene。我不想改变索引结构。只想将代码和配置从AdvancedDatabaseCrawler升级到Sitecore 7.我是否应该担心破坏现有的索引?请详细说明这一点。

由于

2 个答案:

答案 0 :(得分: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转。 131127(7.0 Update-3)因为它修复了您当前版本中IncludeTemplates逻辑中的错误。

答案 1 :(得分:4)

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

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

这是约翰·韦斯特关于sitecore 7 index update strategies的一篇好文章。它可以帮助您按照自己的方式配置索引。

转换配置:

<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>