Indexing 如何使用Sitecore Solr自定义索引

Indexing 如何使用Sitecore Solr自定义索引,indexing,solr,sitecore,Indexing,Solr,Sitecore,有人能帮我理解下面的内容吗 使用Sitecore solr搜索时,是否需要在代码中指定索引的名称 如果我们将新的自定义索引命名为“sitecore\u web-index\u custom”。如何确保在代码中使用此索引 谢谢。要获取Sitecore索引,请使用ContentSearchManager类中的GetIndex方法: Sitecore.ContentSearch.ContentSearchManager.GetIndex(…) 您可以传递索引名称: //获取当前数据库的Sitecor

有人能帮我理解下面的内容吗

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

  • 如果我们将新的自定义索引命名为“sitecore\u web-index\u custom”。如何确保在代码中使用此索引


  • 谢谢。

    要获取Sitecore索引,请使用
    ContentSearchManager
    类中的
    GetIndex
    方法:

    Sitecore.ContentSearch.ContentSearchManager.GetIndex(…)
    
    您可以传递索引名称:

    //获取当前数据库的Sitecore内置索引:
    字符串dbName=(Sitecore.Context.ContentDatabase??Sitecore.Context.Database).Name;
    var index=Sitecore.ContentSearch.ContentSearchManager.GetIndex(“Sitecore_389;”+dbName+“index”);
    //获取自定义索引
    Sitecore.ContentSearch.ContentSearchManager.GetIndex(“Sitecore\u web-index\u自定义”)
    
    或Sitecore项目:

    //按Sitecore项获取索引
    Sitecore.ContentSearch.ContentSearchManager.GetIndex((SitecoreIndexableItem)项);
    
    在第二个场景中,Sitecore将尝试查找索引项的索引

    获取SolrLucene索引之间没有区别-Sitecore API在这里是透明的

    有关Sitecore搜索和索引的更多信息,请参阅


    要获取Sitecore索引,请使用
    ContentSearchManager
    类中的
    GetIndex
    方法:

    Sitecore.ContentSearch.ContentSearchManager.GetIndex(…)
    
    您可以传递索引名称:

    //获取当前数据库的Sitecore内置索引:
    字符串dbName=(Sitecore.Context.ContentDatabase??Sitecore.Context.Database).Name;
    var index=Sitecore.ContentSearch.ContentSearchManager.GetIndex(“Sitecore_389;”+dbName+“index”);
    //获取自定义索引
    Sitecore.ContentSearch.ContentSearchManager.GetIndex(“Sitecore\u web-index\u自定义”)
    
    或Sitecore项目:

    //按Sitecore项获取索引
    Sitecore.ContentSearch.ContentSearchManager.GetIndex((SitecoreIndexableItem)项);
    
    在第二个场景中,Sitecore将尝试查找索引项的索引

    获取SolrLucene索引之间没有区别-Sitecore API在这里是透明的

    有关Sitecore搜索和索引的更多信息,请参阅