The errors of the search of a chunk are reported as Search reports them: by the ErrorOccurred event of the index, and in Warnings of the result. The method throws an exception only for an argument that is not valid and for a disposed index. An error that stops the search gives an empty result without the token of the next chunk, so the search by chunks ends; a part of the index that cannot be read is passed over, and Truncated of the result is true.
Examples
The example demonstrates how to perform chunk search.
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder=@"c:\MyDocuments\";stringquery="Einstein";Indexindex=newIndex(indexFolder);// Creating index in the specified folderindex.Add(documentsFolder);// Indexing documents from the specified folderSearchOptionsoptions=newSearchOptions();options.IsChunkSearch=true;// Enabling chunk searchSearchResultresult=index.Search(query,options);// Starting chunk searchConsole.WriteLine("Document count: "+result.DocumentCount);Console.WriteLine("Occurrence count: "+result.OccurrenceCount);while(result.NextChunkSearchToken!=null){result=index.SearchNext(result.NextChunkSearchToken);// Continuing chunk searchConsole.WriteLine("Document count: "+result.DocumentCount);Console.WriteLine("Occurrence count: "+result.OccurrenceCount);}
The errors of the search of a chunk are reported as Search reports them: by the ErrorOccurred event of the index, and in Warnings of the result. The method throws an exception only for an argument that is not valid and for a disposed index. An error that stops the search gives an empty result without the token of the next chunk, so the search by chunks ends; a part of the index that cannot be read is passed over, and Truncated of the result is true.
Examples
The example demonstrates how to perform chunk search with a cancellation object.
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder=@"c:\MyDocuments\";stringquery="Einstein";Indexindex=newIndex(indexFolder);// Creating index in the specified folderindex.Add(documentsFolder);// Indexing documents from the specified folderCancellationcancellation=newCancellation();// This cancellation object aborts all search continuations if canceledSearchOptionsoptions=newSearchOptions();options.IsChunkSearch=true;// Enabling chunk searchoptions.Cancellation=cancellation;SearchResultresult=index.Search(query,options);// Starting chunk searchConsole.WriteLine("Document count: "+result.DocumentCount);Console.WriteLine("Occurrence count: "+result.OccurrenceCount);while(result.NextChunkSearchToken!=null){result=index.SearchNext(result.NextChunkSearchToken,cancellation);// Continuing chunk searchConsole.WriteLine("Document count: "+result.DocumentCount);Console.WriteLine("Occurrence count: "+result.OccurrenceCount);}