簡體   English   中英

如何使用Sitecore Solr自定義索引

[英]How to use Sitecore Solr Custom Index

有人可以幫我理解下面的內容嗎?

  1. 使用Sitecore solr搜索時,是否需要在代碼中指定索引的名稱?

  2. 如果我們創建名為“ sitecore_web-index_custom”的新自定義索引。 我們如何確保在代碼中使用此索引?

謝謝。

為了獲取Sitecore索引,請使用ContentSearchManager類中的GetIndex方法:

Sitecore.ContentSearch.ContentSearchManager.GetIndex(...)

您可以傳遞索引名稱:

// get Sitecore built in index for current database:
string dbName = (Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database).Name;
var index = Sitecore.ContentSearch.ContentSearchManager.GetIndex("sitecore_" + dbName + "_index");

// get custom index
Sitecore.ContentSearch.ContentSearchManager.GetIndex("sitecore_web-index_custom")

或Sitecore項:

// get index by Sitecore item 
Sitecore.ContentSearch.ContentSearchManager.GetIndex((SitecoreIndexableItem)item);

在第二種情況下,Sitecore將嘗試查找在其中對該項目建立索引的索引。

獲取SolrLucene索引沒有什么區別-Sitecore API在這里是透明的。

有關Sitecore搜索和索引的更多信息,請參見

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM