Search code examples
lucenesitecoresitecore7

Sitecore - get all indexed items


I am using lucene search to get bucket items filtered by some string and this is my code:

var innerQuery = new FullTextQuery(myString);
                    var hits = searchContext.Search(innerQuery, searchIndex.GetDocumentCount());

Is there some query or something different that will let me get all indexed items? I tried with empty "myString" but there is an error that it cannot be empty.


Solution

  • You can use Lucene.Net.Search.MatchAllDocsQuery:

    SearchHits hits = searchContext.Search(new MatchAllDocsQuery(), int.MaxValue);