[英]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.