【问题标题】:How to use Sitecore Solr Custom Index如何使用 Sitecore Solr 自定义索引
【发布时间】:2016-01-08 05:42:25
【问题描述】:

下面有人可以帮我理解吗?

  1. 在使用 Sitecore solr 搜索时,是否需要在代码中指定索引的名称?

  2. 如果我们创建名为“sitecore_web-index_custom”的新自定义索引。我们如何确保我们在代码中使用了这个索引?

谢谢。

【问题讨论】:

    标签: indexing solr sitecore


    【解决方案1】:

    为了获取 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 搜索和索引的更多信息,请参见

    【讨论】:

      猜你喜欢
      • 2017-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多