无法将自定义Sitecore Lucene索引限制为/ sitecore / content / Home

时间:2011-03-18 21:03:19

标签: lucene sitecore lucene.net config sitecore6

我正在尝试在运行Sitecore 6.3.1的网站上创建一个新的Lucene索引。我使用现有的“系统”索引作为指南,我成功地在web和master上创建了一个新索引,以索引Sitecore内容树中的所有项目。

然而,我遇到困难的是限制数据库搜寻器索引的内容树的哪个部分。当前,搜索索引包含来自内容树中的任何地方的项目(内容项,媒体库项,布局,模板等)。我想将索引限制为仅/sitecore/content/Home中的项目。

我在~/App_Config/Include/Search Indexes/website.config创建了一个文件,我已粘贴以下相关部分:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <sitecore>

    <!-- This works as expected.... -->
    <databases>
      <database id="web">
        <indexes hint="list:AddIndex">
          <index path="indexes/index[@id='website']" />
        </indexes>
      </database>

      <!-- ... similar entry for master database goes here ... -->
    </databases>

    <!-- So does this.... -->
    <indexes>
      <index id="website" singleInstance="true" type="Sitecore.Data.Indexing.Index, Sitecore.Kernel">
        <param desc="name">$(id)</param>
        <fields hint="raw:AddField">
          <!-- ... field descriptions go here ... -->
        </fields>
      </index>
    </indexes>

    <!-- This works... mostly.  The "__website" directory does get created,
          but the Root directive is getting ignored.
    -->
    <search>
      <configuration type="Sitecore.Search.SearchConfiguration, Sitecore.Kernel" singleInstance="true">
        <indexes hint="list:AddIndex">
          <index id="website" singleInstance="true" type="Sitecore.Search.Index, Sitecore.Kernel">
            <param desc="name">$(id)</param>
            <param desc="folder">__$(id)</param>

            <Analyzer ref="search/analyzer" />

            <locations hint="list:AddCrawler">
              <web type="Sitecore.Search.Crawlers.DatabaseCrawler, Sitecore.Kernel">
                <Database>web</Database>
                <Root>/sitecore/content/home</Root>
                <Tags>content</Tags>
              </web>

              <!-- ... similar entry for master database goes here ... -->
            </locations>
          </index>
        </indexes>
      </configuration>
    </search>
  </sitecore>
</configuration>

几点说明:

  • 这不是来自我的web.config文件;我创建了一个单独的文件,以便通过Sitecore软件包分发配置更改。

  • 索引已添加到masterweb;为简洁起见,我省略了对master的引用。

  • Sitecore肯定正在处理configuration/sitecore/search/configuration的条目。当我转到http://localhost/sitecore/admin/showconfig.aspx时,我可以看到它们,如果我将其中一个标记值更改为无效(例如<Root>/nothere</Root>),则Sitecore会在下一页加载时抛出异常。

  • 我已经查看了IndexViewer中的索引内容,并且错误的项目肯定会被编入索引(例如,索引中的文档#0是/sitecore节点)。

我哪里错了?我需要对配置文件进行哪些更改才能让搜索索引器忽略/sitecore/content/Home之外的项目?

1 个答案:

答案 0 :(得分:0)

我能够使用Advanced Database Crawler解决问题。使用Alex演示文稿中提供的代码切换configuration/search/configuration块(参见上面的链接),一切都开始工作,或多或少地自动化。