2016-03-24 87 views
1

我正在使用Sitecore 7.5,並試圖獲取存儲區項目的子項。 我有一個索引「XYZ」和它的作品時,我嘗試使用得到這個指數:Sitecore ContentSearchManager找不到索引

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個項目。

回答

0

變化從Sitecore.Search.Index,Sitecore.KernelSitecore.ContentSearch.LuceneProvider.LuceneIndex類型,Sitecore.ContentSearch.LuceneProvider

SearchManager.GetIndex( 「XYZ」)。CreateSearchContext( ) - 利用了IndexSearchContext的

ContentSearchManager.GetIndex( 「XYZ」)CreateSearchContext() - 利用SitecoreContentSearch

Sitecore利用SitecoreContentSearch重建索引。 感謝

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

+0

你能看看我編輯的問題嗎? – petros

+0

/sitecore/content/xyz/avc在網頁數據庫中有沒有這個項目? –

+0

您是否也可以檢查網站數據庫中的根目錄爲\t /sitecore/content/xyz/avc下的ID爲{DA757C92-A4CC-468F-BC22-AD347C8C4C9C}的項目 –