避免系统文件夹的 Sitecore Lucene/Solr 索引

Avoid Sitecore Lucene/Solr Indexing of System Folder

我刚刚在 Sitecore 中设置了我的 Solr 搜索功能,它为网站编制了索引。我可以进行搜索并返回结果。不幸的是,它索引太多,并且返回系统特定的东西,例如内容树中的模板和分析节点。我在 /system/ 文件夹和其他地方输入 'system' 它 returns 之类的东西。

我可以通过添加要排除的模板来减少很多,但我宁愿告诉它避免一两个特定的文件夹(布局文件夹、系统文件夹等)。

有没有办法在 ContentSearch 配置中执行此操作?如果没有,我该怎么做?

谢谢!

您可以创建自定义索引,并通过设置 root 节点将其限制为该索引中您想要的内容:

<contentSearch>
  <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
    <indexes hint="list:AddIndex">
      <index id="my_custom_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
        ...
        <locations hint="list:AddCrawler">
          <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
            <Database>web</Database>
            <Root>/sitecore/content</Root>
          </crawler>
        </locations>
        ....
      </index>
    </indexes>
  </configuration>
</contentSearch>

请注意,索引 id 属性设置为自定义索引名称,根节点更改为 root 节点。以上是Sitecore.ContentSearch.Solr.Index.Web.config的副本,您可能需要根据您的需要为master创建一个类似的。

您可以在此博客中找到有关定义自己的自定义索引的更多信息 post:Defining a custom index in Sitecore 7, the absolute minimum

或者,保留默认索引并在您自己的搜索查询中添加过滤器以将返回的结果限制为仅 /sitecore/content