Pinoy2015
Pinoy2015

Reputation: 1459

ContentSearchManager does not return any Results

Sitecore 8 ContentSearchManager does not return any result. Below is my code:

    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;
        }
    }

Code Snapshot:

enter image description here

Sitecore Tree:

enter image description here

Is there anything that I need to do to make it work? Like setting up anything in config or something?

What I have tried so far:

Note:

I am using lucene.

UPDATES:

When I switch to master the records retrieves.

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

UPDATES 2 (09/08/2015)

Looks like I have a problem when performing indexing in web.

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)

Any ideas how to fix? What I have tried so far are:

But nothing seems to work.

Is there a way to clean up the indexing of web so I could index from start?

SOLUTION:

Since the index is corrupted. I deleted the files and folders inside the \Data\indexes. Then after rebuild everything seems to work properly.

I also found this. It helps also.

Upvotes: 1

Views: 1459

Answers (3)

Pinoy2015
Pinoy2015

Reputation: 1459

SOLUTION:

Since the index is corrupted. I deleted the files and folders inside the \Data\indexes. Then after rebuild everything seems to work properly.

Upvotes: 0

Younes
Younes

Reputation: 4823

The answer below AND are you 100% sure that the items you search for are published? I know it's stupid, but sometimes we just seem to forget to publish.

Upvotes: 0

Ian Graham
Ian Graham

Reputation: 3216

Double check in your config for sitecore_web_index that the root path for the index is set so that it will include the globalreferences path.

There should a patch file for this in the include directory.

For reference it should be setup like this:

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

If you still can't get any data I would recommend downloading Luke to see exactly what's in your index

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

Upvotes: 2

Related Questions