sitecore 7 中的自定义搜索配置

Custom search configuration in sitecore 7

我一直在研究 sitecore contentSearch API recently.When 我尝试构建自定义索引,但出现如下运行时错误。

Could not find property 'initializeOnAdd' on object of type: Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration

这是我的示例配置。

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <configuration type="Sitecore.ContentSearch.LuceneProvider.LuceneSearchConfiguration, Sitecore.ContentSearch.LuceneProvider">
        <indexes hint="list:AddIndex">
          <index id="demo_master" 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)" />
            <configuration ref="contentSearch/indexConfigurations/LuceneCustomSearchConfiguration" />
            <strategies hint="list:AddStrategy">
              <!-- NOTE: order of these is controls the execution order -->
              <strategy ref="contentSearch/indexUpdateStrategies/syncMaster" />
            </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>master</Database>
                <Root>/sitecore/content/Sample</Root>
              </crawler>
            </locations>
          </index>
        </indexes>
      </configuration>
      <indexConfigurations>
        <LuceneCustomSearchConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
          <indexAllFields>true</indexAllFields>
          <initializeOnAdd>true</initializeOnAdd>
          <analyzer ref="contentSearch/configuration/defaultIndexConfiguration/analyzer" />
          <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="Name"  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>
          </fieldMap>
          <fields hint="raw:AddComputedIndexField">
            <field fieldName="imageurl">Lucene.CustomSearch.BusinessLayer.ComputedFields.ImageUrlComputedField,Lucene.CustomSearch.BusinessLayer</field>
            <field fieldName="releaseyear">Lucene.CustomSearch.BusinessLayer.ComputedFields.YearComputedField,Lucene.CustomSearch.BusinessLayer</field>
            </fields>
          <include hint="list:IncludeTemplate">
            <Laptop>{3AF80D80-404F-411F-9E72-F43A7D92AEC8}</Laptop>
          </include>
          <fieldReaders ref="contentSearch/configuration/defaultIndexConfiguration/fieldReaders"/>
          <indexFieldStorageValueFormatter ref="contentSearch/configuration/defaultIndexConfiguration/indexFieldStorageValueFormatter"/>
          <indexDocumentPropertyMapper ref="contentSearch/configuration/defaultIndexConfiguration/indexDocumentPropertyMapper"/>
        </LuceneCustomSearchConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

我查看了 sitecore 的搜索配置文件并对 it.Type 和分析器做了一些更改 settings.am 我在配置中遗漏了什么?

我已通过 myself.here 解决此问题是 Sitecore 7 自定义搜索的配置设置。

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <configuration type="Sitecore.ContentSearch.LuceneProvider.LuceneSearchConfiguration, Sitecore.ContentSearch.LuceneProvider">
        <indexes hint="list:AddIndex">
          <index id="demo_master" 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)" />
            <configuration ref="contentSearch/indexConfigurations/LuceneCustomSearchConfiguration" />
            <strategies hint="list:AddStrategy">
              <!-- NOTE: order of these is controls the execution order -->
              <strategy ref="contentSearch/indexUpdateStrategies/syncMaster" />
            </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>master</Database>
                <Root>/sitecore/content/Sample</Root>
              </crawler>
            </locations>
          </index>
        </indexes>
      </configuration>
      <indexConfigurations>
        <LuceneCustomSearchConfiguration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
          <indexAllFields>true</indexAllFields>
           <initializeOnAdd>true</initializeOnAdd>
          <analyzer ref="contentSearch/configuration/defaultIndexConfiguration/analyzer" />
          <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>
              </fieldNames>
          </fieldMap>
          <fields hint="raw:AddComputedIndexField">
            <field fieldName="imageurl">Lucene.CustomSearch.BusinessLayer.ComputedFields.ImageUrlComputedField,Lucene.CustomSearch.BusinessLayer</field>
            </fields>
          <include hint="list:IncludeTemplate">
            <Laptop>{3AF80D80-404F-411F-9E72-F43A7D92AEC8}</Laptop>
          </include>
          <fieldReaders ref="contentSearch/configuration/defaultIndexConfiguration/fieldReaders"/>
          <indexFieldStorageValueFormatter ref="contentSearch/configuration/defaultIndexConfiguration/indexFieldStorageValueFormatter"/>
          <indexDocumentPropertyMapper ref="contentSearch/configuration/defaultIndexConfiguration/indexDocumentPropertyMapper"/>
        </LuceneCustomSearchConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>