[英]How to use Sitecore Solr Custom Index
有人可以幫我理解下面的內容嗎?
使用Sitecore solr搜索時,是否需要在代碼中指定索引的名稱?
如果我們創建名為“ 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將嘗試查找在其中對該項目建立索引的索引。
獲取Solr或Lucene索引沒有什么區別-Sitecore API在這里是透明的。
有關Sitecore搜索和索引的更多信息,請參見
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.