The GroupDocs.Search API provides the ability to perform search by chunks. This means that in one call to the Search method of the Index class, only in one index segment search is performed. This feature becomes relevant when searching in large indexes containing tens and hundreds of thousands of documents.
When performing search by chunks, the Search method is first called with the IsChunkSearch flag set to true in the search options. And then the search in each subsequent segment is performed using the SearchNext method with passing ChunkSearchToken of the next chunk as an argument.
The following example demonstrates the search by chunks.
C#
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder=@"c:\MyDocuments\";stringquery="Einstein";// Creating an index in the specified folderIndexindex=newIndex(indexFolder);// Indexing documents from the specified folderindex.Add(documentsFolder);// Creating a search options instanceSearchOptionsoptions=newSearchOptions();options.IsChunkSearch=true;// Enabling the search by chunks// Starting the search by chunksSearchResultresult=index.Search(query,options);Console.WriteLine("Document count: "+result.DocumentCount);Console.WriteLine("Occurrence count: "+result.OccurrenceCount);// Continuing the search by chunkswhile(result.NextChunkSearchToken!=null){result=index.SearchNext(result.NextChunkSearchToken);Console.WriteLine("Document count: "+result.DocumentCount);Console.WriteLine("Occurrence count: "+result.OccurrenceCount);}
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: