【问题标题】:ContentSearchManager does not return any ResultsContentSearchManager 不返回任何结果
【发布时间】:2015-09-07 05:46:44
【问题描述】:

Sitecore 8 ContentSearchManager 不返回任何结果。以下是我的代码:

    public IQueryable<SearchResultItem> PerformSearch()
    {
        var index = ContentSearchManager.GetIndex("sitecore_web_index");
        using (var searchContext = index.CreateSearchContext())
        {
            var locations = searchContext.GetQueryable<SearchResultItem>()
            .Where(i => i.Path.StartsWith("/sitecore/content/GlobalReferences/Locations"));


            var item = locations.ToList();


            return locations;
        }
    }

代码快照:

站点核心树:

我需要做些什么才能让它工作吗?比如在配置中设置什么东西?

到目前为止我所尝试的:

  • 重建索引 [无结果]

注意:

我正在使用 lucene。

更新:

当我切换到主记录检索时。

var index = ContentSearchManager.GetIndex("sitecore_master_index");

更新 2 (09/08/2015)

看起来我在网络中执行索引时遇到了问题。

Job started: Index_Update_IndexName=sitecore_web_index|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Lucene.Net.Index.CorruptIndexException: checksum mismatch in segments file
   at Lucene.Net.Index.SegmentInfos.Read(Directory directory, String segmentFileName)
   at Lucene.Net.Index.IndexFileDeleter..ctor(Directory directory, IndexDeletionPolicy policy, SegmentInfos segmentInfos, StreamWriter infoStream, DocumentsWriter docWriter, HashSet`1 synced)
   at Lucene.Net.Index.IndexWriter.Init(Directory d, Analyzer a, Boolean create, IndexDeletionPolicy deletionPolicy, Int32 maxFieldLength, IndexingChain indexingChain, IndexCommit commit)
   at Lucene.Net.Index.IndexWriter..ctor(Directory d, Analyzer a, Boolean create, MaxFieldLength mfl)
   at Sitecore.ContentSearch.LuceneProvider.Sharding.LuceneShard.Reset()
   at Sitecore.ContentSearch.LuceneProvider.LuceneIndex.DoReset(IProviderUpdateContext context)
   at Sitecore.ContentSearch.LuceneProvider.LuceneIndex.PerformRebuild(IndexingOptions indexingOptions, CancellationToken cancellationToken)
   at Sitecore.ContentSearch.LuceneProvider.LuceneIndex.Rebuild()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at (Object , Object[] )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Jobs.Job.ThreadEntry(Object state)

任何想法如何解决?到目前为止我尝试过的是:

  • 重建索引
  • 重建树
  • 全部重建

但似乎没有任何效果。

有没有办法清理网页的索引,以便我可以从头开始索引?

解决方案:

由于索引已损坏。我删除了 \Data\indexes 中的文件和文件夹。然后重建后一切似乎都可以正常工作。

我还找到了this。它也有帮助。

【问题讨论】:

  • 你使用 Lucene 还是 Solr?尝试在查询中使用小写路径"/sitecore/content/globalreferences/locations"
  • 你能切换到网络数据库并检查“位置”项目及其子项目吗?
  • @Ahmed,已经检查过了。它在那里(项目和子项目)
  • 好的,尝试删除整个网络索引文件夹,然后再次尝试重建它。
  • @Pinoy2015 您可以在“\Data\indexes\sitecore_web_index”中找到索引文件夹,您只需将其删除,然后重建您的索引

标签: sitecore sitecore8


【解决方案1】:

再次检查您的 sitecore_web_index 配置,确定索引的根路径已设置为包含全局引用路径。

在包含目录中应该有一个补丁文件。

作为参考,它应该像这样设置:

http://www.mikkelhm.dk/blog/defining-a-custom-index-in-sitecore-7-the-absolute-minimum

如果您仍然无法获得任何数据,我建议您下载 Luke 以查看索引中的确切内容

https://code.google.com/p/luke/

【讨论】:

  • 这是根目录:web /sitecore
  • 正如 Marek 所问,您使用的是 Lucene 吗?
  • 是的,我正在使用 lucen
  • 如果不使用补丁文件,只使用默认的,没有补丁文件是不是不行?
  • 如果直接在配置中它会起作用,但补丁文件可能会覆盖设置。你有没有做过 /sitecore/admin/showconfig.aspx 来检查爬虫的根设置是否没有被覆盖?
【解决方案2】:

下面的答案并且您是否 100% 确定您搜索的项目已发布?我知道这很愚蠢,但有时我们似乎只是忘记了发布。

【讨论】:

  • 是的,在我重建索引之后。我发布它以确保。
【解决方案3】:

解决方案:

由于索引已损坏。我删除了 \Data\indexes 中的文件和文件夹。然后重建后一切似乎都可以正常工作。

【讨论】:

  • 很高兴这是解决方案,顺便说一句,您可以将您的答案勾选为正确。
猜你喜欢
  • 2017-12-28
  • 2017-12-09
  • 2020-10-03
  • 2017-03-19
  • 2017-05-20
  • 2012-08-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多