【问题标题】:Lucene index creation is not workingLucene 索引创建不起作用
【发布时间】:2012-09-12 18:25:31
【问题描述】:

我正在尝试通过 App.Config 在内容项模板之一上通过 Sitecore 6.5 中的 Lucene 创建一个索引。请记住,此处列出的 'master'SC DB,而不是物理 SQL DB。 这是我的代码:

    <configuration xmlns:x="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <databases>
      <database id="master" singleInstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
        <Engines.HistoryEngine.Storage>
          <obj type="Sitecore.Data.$(database).$(database)HistoryStorage, Sitecore.Kernel">
            <param connectionStringName="$(id)" />
            <EntryLifeTime>30.00:00:00</EntryLifeTime>
          </obj>
        </Engines.HistoryEngine.Storage>
        <Engines.HistoryEngine.SaveDotNetCallStack>false</Engines.HistoryEngine.SaveDotNetCallStack>
      </database>
    </databases>
    <search>
      <configuration>
        <indexes>
          <index id="master" type="Sitecore.Search.Index, Sitecore.Kernel">
            <param desc="name">$(id)</param>
            <param desc="folder">master</param>
            <Analyzer ref="search/analyzer" />
            <locations hint="list:AddCrawler">
              <master type="Sitecore.SharedSource.Search.Crawlers.AdvancedDatabaseCrawler,Sitecore.SharedSource.Search">
                <Database>master</Database>
                <Root>/sitecore/content/Data</Root>
                <IndexAllFields>false</IndexAllFields>
                <include hint="list:IncludeTemplate">
                  <template1>{EF11A8D0-D373-4A4B-90BA-16984D277612}</template1>
                </include>
                <fieldCrawlers hint="raw:AddFieldCrawlers">
                  <fieldCrawler type="Sitecore.SharedSource.Search.FieldCrawlers.LookupFieldCrawler,Sitecore.SharedSource.Search" fieldType="Single-Line Text" />
                  <fieldCrawler type="Sitecore.SharedSource.Search.FieldCrawlers.DateFieldCrawler,Sitecore.SharedSource.Search" fieldType="Multilist" />
                </fieldCrawlers>
                <!-- If a field type is not defined, defaults of storageType="NO", indexType="UN_TOKENIZED" vectorType="NO" boost="1f" are applied-->
                <fieldTypes hint="raw:AddFieldTypes">
                  <!-- Text fields need to be tokenized -->
                  <fieldType name="single-line text" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <fieldType name="multi-line text" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <fieldType name="word document" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <fieldType name="html" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <fieldType name="rich text" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <fieldType name="memo" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <fieldType name="text" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <!-- Multilist based fields need to be tokenized to support search of multiple values -->
                  <fieldType name="multilist" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <fieldType name="treelist" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <fieldType name="treelistex" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <fieldType name="checklist" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                  <!-- Legacy tree list field from ver. 5.3 -->
                  <fieldType name="tree list" storageType="NO" indexType="TOKENIZED" vectorType="NO" boost="1f" />
                </fieldTypes>
              </master>
            </locations>
          </index>
        </indexes>
      </configuration>
    </search>
  </sitecore>
</configuration>

当我在此之后运行我的解决方案时,我正在通过“索引查看器”查看我的索引,但什么也看不到。我在这里做错了什么?

我添加了这段代码:

  private IDictionary<string, Sitecore.Search.Index> GetSearchIndexes()
    {
        var _configuration = Sitecore.Configuration.Factory.CreateObject("search/configuration", true) as Sitecore.Search.SearchConfiguration;
        return _configuration.Indexes;
    }

但在 _configuration.Indexes 的返回中,我得到了:master、web、advanced。我的索引不同,这些是数据库列表。

【问题讨论】:

  • 当您说在索引查看器中看不到任何内容时,您的意思是您看不到任何文档或索引没有出现在列表中?
  • 索引未出现在列表中。
  • 我在下面的评论中读到您选择 DataIndex 作为类型,但您在上面创建的是 SearchIndex。如果选择 SearchIndex 作为类型,你看到了吗?

标签: search sitecore lucene


【解决方案1】:

我假设您的意思是 web.config 而不是 app.config

转到 Sitecore > 控制面板 > 数据库 > 重建搜索索引 以在文件系统上生成索引。

或者,下载this script 并运行它。

【讨论】:

  • 嘿,马克:我在 myProjectName->App_Config->Include->myName.Config 下添加了这个文件
  • 按照你说的做了之后,我去IndexViewer,Selected Index Type = DataIndex,Database = Master。但是在索引下拉列表中我什么也看不到:(
  • 改为运行脚本,我添加了一个链接。
  • 我在我的问题中添加了代码。我将数据库名称作为上述函数的返回值(我从 Alex 的代码中获取了代码)。
猜你喜欢
  • 2014-10-07
  • 1970-01-01
  • 1970-01-01
  • 2016-01-23
  • 2012-05-10
  • 2012-07-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多