重建Lucene搜索索引失败

时间:2014-05-06 07:13:39

标签: sitecore sitecore6

我们正在使用Sitecore 6.5和Lucene进行搜索。

我正在尝试使用索引查看器重建索引,但我收到错误:

  

发生错误

     

System.InvalidOperationException:Item的模板为null。在   Sitecore.Search.Crawlers.DatabaseCrawler.GetAllTemplates(Item item)

但我不知道如何找到哪个项目没有模板...

5 个答案:

答案 0 :(得分:2)

您已经遇到了sitecore数据库中不应存在的内容。找到我相信的项目的最佳方法是打开SQL Management Studio并在master数据库上使用以下查询:

select * from items where templateid not in (select id from items)

答案 1 :(得分:0)

您可以在日志中找到它,具体取决于您的日志记录设置。 Crawler调用Item.Template,它应该记录模板,项目和数据库

if (templateItem == null)
      Sitecore.Diagnostics.Log.SingleError(string.Format("Data template '{0}' not found  for item '{1}' in '{2}' database

答案 2 :(得分:0)

你可以像上面提到的那样查询items表,如果你没有SQL服务器的访问权限,我认为sitecore解决方案在你的机器上并且你有连接字符串? 写一个小应用程序然后为你运行查询。

var itemIds = (from i in dbContext.items select i.id).ToList();
var orphanItems = (from oi in dbContext.items where !itemIds.Contains(i.templateId) select oi).ToList();

答案 3 :(得分:0)

请参阅下面给出的网址,我认为它会解决您的问题

http://sitecorebasics.wordpress.com/2013/12/16/template-item-id-not-found-for-item-pathpath/

答案 4 :(得分:-1)

只需在项目中调试索引文件,最好的调试方法是

每当您发布自动重建的站点或项目索引或重建索引的时间时,请将断点放在索引文件中并查看确切的问题

这是示例代码

protected override void AddAllFields(Document document, Item item, bool versionSpecific)
{
}
<index id="Index name" type="Sitecore.Search.Index, Sitecore.Kernel">
   <param desc="name">$(id)</param>
   <param desc="folder">__GermanUrl</param>
   <Analyzer ref="search/analyzer" />
      <locations hint="list:AddCrawler">
         <customSearch type="BusinessModul.UrlIndexer,BusinessModule">
         <Database>web</Database>
         <Root>/sitecore/content/</Root>
         <Boost>2.0</Boost>
         <IndexAllFields>false</IndexAllFields>
         <include hint="list:IncludeTemplate">
         <includeTemplate>template id</includeTemplate>
      </include>
   </customSearch>
   </locations>
</index>
相关问题