Sitecore ContentSearchManager找不到索引

时间:2016-03-24 12:20:24

标签: sitecore

我正在使用Sitecore 7.5,我尝试获取桶项目的子项。 我有一个索引“xyz”,当我尝试使用以下代码获取此索引时它会起作用:

var context = SearchManager.GetIndex("xyz").CreateSearchContext();

但我想用这个:

using (var context = ContentSearchManager.GetIndex("xyz").CreateSearchContext())
{
    IQueryable<SearchResult> results = context.GetQueryable<SearchResult>();
}

我收到一个例外“未找到索引xyz”。为什么SearchManager找到这个索引但是ContentSearchManager没有?

这是我的索引:

<configuration>
  <indexes hint="list:AddIndex">
<index id="xyz" type="Sitecore.Search.Index, Sitecore.Kernel">
      <param desc="name">$(id)</param>
      <param desc="folder">xyz</param>
      <Analyzer ref="search/analyzer" />
      <locations hint="list:AddCrawler">
        <web-pomoc type="Website.Classes.Search.BasicDatabaseCrawler, Website">
          <Database>web</Database>
          <Root>/sitecore/content/Shared/Kolekcje/Vod/Catchup-VOD</Root>
          <templates hint="list:IncludeTemplate">
            <entry>{DA757C92-A4CC-468F-BC22-AD347C8C4C9C}</entry>
          </templates>
        </web-pomoc>
      </locat
  </indexes>
</configuration>

修改: 我改变了我的索引,现在它看起来像这样:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
        <indexes hint="list:AddIndex">
          <index id="catchup_search" 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 type=”Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider”>
            <indexAllFields>false</indexAllFields>
            <initializeOnAdd>true</initializeOnAdd>
            <analyzer ref=”contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/analyzer” />
            <include hint="list:IncludeTemplate">
                <catchup_entry>{DA757C92-A4CC-468F-BC22-AD347C8C4C9C}</catchup_entry>
            </include>
        </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.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
              </policies>
            </commitPolicyExecutor>
            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>web</Database>
                <Root>/sitecore/content/xyz/avc</Root>
              </crawler>
            </locations>
          </index>
        </indexes>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>

现在它出现在索引管理器中,但是当我重建它时,处理了0个项目。

2 个答案:

答案 0 :(得分:0)

将类型从 Sitecore.Search.Index,Sitecore.Kernel 更改为 Sitecore.ContentSearch.LuceneProvider.LuceneIndex,Sitecore.ContentSearch.LuceneProvider

SearchManager.GetIndex(“xyz”)。CreateSearchContext() - 使用IndexSearchContext

ContentSearchManager.GetIndex(“xyz”)。CreateSearchContext() - 利用SitecoreContentSearch

Sitecore利用SitecoreContentSearch重建索引。 感谢

答案 1 :(得分:0)

您的索引定义错误 你需要使用类似的东西:

 <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
 <sitecore>
  <contentSearch>
  <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
    <indexes hint="list:AddIndex">
      <index id="sitecore_web_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
        <param desc="name">$(id)</param>
        <param desc="folder">$(id)</param>
         ...
      </index>
    </indexes>
  </configuration>
</contentSearch>

请检查Sitecore 7.5的默认索引定义

添加索引配置文件后,请检查索引是否出现在IndexManager中:

enter image description here