在CD环境中重建搜索索引

时间:2013-07-22 10:14:24

标签: search lucene sitecore sitecore6

我正在更改我的代码以使用旧的Lucene方式的Sitecore.Search。为此,我使用ADC module中的抓取工具。我目前没有使用Searcher,只是模块中的Crawler(尽管我们希望在以后阶段改变它)。
我已经设法让索引和搜索功能在我的CM环境中完美运行,但是当我尝试重建时CD环境不断出现以下错误:

  

找不到配置节点:databases / database [@ id ='core']。

我正在运行以重建搜索索引的代码在CD上是:

foreach (var options in from ListItem item in cblIndexes.Items 
                        where item.Selected           
                        select new JobOptions("RebuildSearchIndex", "index", global::Sitecore.Client.Site.Name, new Builder(item.Value), "Rebuild") { AfterLife = TimeSpan.FromMinutes(1.0) })
           {
               JobManager.Start(options);
           }

在CM上运行此代码可以正常工作 我对其中一个失败索引的配置:

<search>
      <configuration>
        <indexes>
          <index id="PressReleaseIndex" 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 ref="search/crawlers/PressReleaseIndex" param1="web" />
            </locations>
          </index>
        </indexes>
      </configuration>
      <crawlers>
        <PressReleaseIndex type="scSearchContrib.Crawler.Crawlers.AdvancedDatabaseCrawler,scSearchContrib.Crawler">
          <Database>$(1)</Database>
          <Root>/sitecore/content/home/newsroom</Root>
          <IndexAllFields>false</IndexAllFields>

          <include hint="list:IncludeTemplate">
            <pressrelease>{91DB1CBC-32F8-4344-A974-7F4FE5F07668}</pressrelease>
          </include>

          <include hint="list:IncludeField">
            <title>{F8C6E41E-3C9F-45F6-8409-61F5C8F2BF19}</title>
            <shortdescription>{D25294E9-03C1-4E62-968B-5410AAAD0863}</shortdescription>
            <body>{A0AD83E2-1099-407C-B8D7-C123FDAAD5DD}</body>
            <releasedate>{D0B594BC-2ED6-4A0E-A050-3243CD044040}</releasedate>
          </include>

          <fieldCrawlers hint="raw:AddFieldCrawlers">
            <fieldCrawler type="scSearchContrib.Crawler.FieldCrawlers.LookupFieldCrawler,scSearchContrib.Crawler" fieldType="Droplink" />
            <fieldCrawler type="scSearchContrib.Crawler.FieldCrawlers.LookupFieldCrawler,scSearchContrib.Crawler" fieldType="Droptree" />
            <fieldCrawler type="scSearchContrib.Crawler.FieldCrawlers.DateFieldCrawler,scSearchContrib.Crawler" fieldType="Datetime" />
            <fieldCrawler type="scSearchContrib.Crawler.FieldCrawlers.DateFieldCrawler,scSearchContrib.Crawler" fieldType="Date" />
            <fieldCrawler type="scSearchContrib.Crawler.FieldCrawlers.NumberFieldCrawler,scSearchContrib.Crawler" fieldType="Number" />
            <fieldCrawler type="scSearchContrib.Crawler.FieldCrawlers.MultilistFieldCrawler,scSearchContrib.Crawler" fieldType="Multilist" />
            <fieldCrawler type="scSearchContrib.Crawler.FieldCrawlers.MultilistFieldCrawler,scSearchContrib.Crawler" fieldType="Treelist" />
            <fieldCrawler type="scSearchContrib.Crawler.FieldCrawlers.MultilistFieldCrawler,scSearchContrib.Crawler" fieldType="TreelistEx" />
            <fieldCrawler type="scSearchContrib.Crawler.FieldCrawlers.MultilistFieldCrawler,scSearchContrib.Crawler" fieldType="Checklist" />
          </fieldCrawlers>

          <dynamicFields hint="raw:AddDynamicFields">
            <dynamicField type="Sapient.Practice.Ccmp.Common.SitecoreSearch.DynamicFields.ReleaseYearField,Sapient.Practice.Ccmp.Common" name="_releaseyear" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" />
            <dynamicField type="Sapient.Practice.Ccmp.Common.SitecoreSearch.DynamicFields.ReleaseMonthField,Sapient.Practice.Ccmp.Common" name="_releasemonth" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" />
          </dynamicFields>

          <fieldTypes hint="raw:AddFieldTypes">
            <!-- Text fields need to be tokenized -->
            <fieldType name="single-line text" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" />
            <fieldType name="multi-line text" storageType="YES" 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" />
            <fieldType name="date" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" />
          </fieldTypes>
        </PressReleaseIndex>

当解决方案仍在Sitecore 6.3.1上时(我们已升级到Sitecore 6.5 update 5),我已经查看了Staging Guide,并删除了对Core数据库的所有引用。

当我转到CD上的ShowConfig页面并寻找'核心'时,我找不到任何结果。在AppSettings.config,ConnectionStrings.config或我得到的任何其他配置文件中也没有对Core数据库的引用。据我所知,我也没有引用硬编码的核心数据库(或者我之前会遇到问题)。

我无法弄清楚核心数据库的引用位置。
stacktrace的完整例外:

Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj)
   at Sitecore.Reflection.MethodInstance.Invoke()
   at Sitecore.Jobs.JobRunner.RunMethod(JobArgs args)
   at (Object , Object[] )
   at Sitecore.Pipelines.PipelineMethod.Invoke(Object[] parameters)
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.CorePipeline.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Pipelines.CorePipeline.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Jobs.Job.ThreadEntry(Object state)

Nested Exception

Exception: System.InvalidOperationException
Message: Could not find configuration node: databases/database[@id='core']
Source: Sitecore.Kernel
   at Sitecore.Diagnostics.Assert.IsTrue(Boolean condition, String format, Object[] args)
   at Sitecore.Configuration.Factory.GetConfigNode(String xpath, Boolean assert)
   at Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert)
   at Sitecore.Configuration.Factory.CreateObject(String configPath, Boolean assert)
   at Sitecore.Configuration.Factory.GetDatabase(String name, Boolean assert)
   at Sitecore.Configuration.Factory.GetDatabase(String name)
   at Sitecore.Web.UI.HtmlControls.Data.LookupSources.GetDatabase(String source)
   at Sitecore.Data.Fields.CustomField.GetDatabase()
   at Sitecore.Data.Fields.DelimitedField.ValidateLinks(LinksValidationResult result)
   at Sitecore.Links.ItemLinks.AddLinks(Field field, List`1 links, ItemLinkState linkState)
   at Sitecore.Links.ItemLinks.GetLinks(ItemLinkState linkState, Boolean allVersions, Boolean includeStandardValuesLinks)
   at Sitecore.Search.Crawlers.DatabaseCrawler.GetItemLinks(Item item)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddSpecialFields(Document document, Item item)
   at Sitecore.Search.Crawlers.DatabaseCrawler.IndexVersion(Item item, Item latestVersion, IndexUpdateContext context)
   at scSearchContrib.Crawler.Crawlers.AdvancedDatabaseCrawler.IndexVersion(Item item, Item latestVersion, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddItem(Item item, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddTree(Item root, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddTree(Item root, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddTree(Item root, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddTree(Item root, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddTree(Item root, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.AddTree(Item root, IndexUpdateContext context)
   at Sitecore.Search.Crawlers.DatabaseCrawler.Add(IndexUpdateContext context)
   at Sitecore.Search.Index.Rebuild()
   at Saga.Sitecore.Web.Builder.Rebuild()

2 个答案:

答案 0 :(得分:1)

我认为该问题与您的索引配置无关。查看堆栈跟踪时,当您的搜索爬网程序尝试获取分隔字段(多列表,树状列表等)的链接(引用)时,该异常实际上源于Sitecore.Web.UI.HtmlControls.Data.LookupSources.GetDatabase方法。 )。

   at Sitecore.Configuration.Factory.GetDatabase(String name)
   at Sitecore.Web.UI.HtmlControls.Data.LookupSources.GetDatabase(String source)
   at Sitecore.Data.Fields.CustomField.GetDatabase()
   at Sitecore.Data.Fields.DelimitedField.ValidateLinks(LinksValidationResult result)
   at Sitecore.Links.ItemLinks.AddLinks(Field field, List`1 links, ItemLinkState linkState)
   at Sitecore.Links.ItemLinks.GetLinks(ItemLinkState linkState, Boolean allVersions, Boolean includeStandardValuesLinks)
   at Sitecore.Search.Crawlers.DatabaseCrawler.GetItemLinks(Item item)

使用反射器,我们可以查看Sitecore.Data.Fields.CustomField.GetDatabase()方法,如果关联字段在其“源”字段中具有值,则该方法调用LookupSources.GetDatabase方法。 LookupSources.GetDatabase方法尝试解析“源”字段以确定在关联的分隔字段中查询源项目的数据库。某些源字段可以使用“db =”参数显式设置要查询源项的数据库。

因此,长话短说,当您在索引配置中使用<IndexAllFields>true</IndexAllFields>时,您的抓取工具尝试索引的某个字段会有一个“源”字段,其中包含对核心数据库的引用。

您将<IndexAllFields />值设置为false然后明确包含或排除字段以进行索引的解决方案当然有效,但如果您想要找出问题的根本原因,您可能需要查看通过“来源”字段。

答案 1 :(得分:0)

它似乎与配置中的<IndexAllFields>有关。我的第二个索引设置为true。我将其设置为false,执行了IncludeFieldsExcludeFields,现在它已成功构建。

我仍然想知道为什么它会抛出那个错误,因为之前删除了Core数据库。可能是标准领域?