SearchNext

SearchNext(ChunkSearchToken)

Continues the search by chunks of the repository started with the Search method.

public SearchResult SearchNext(ChunkSearchToken chunkSearchToken)
Parameter Type Description
chunkSearchToken ChunkSearchToken The chunk search token.

Return Value

The search result.

Exceptions

exception condition
ArgumentNullException The chunk search token is null.
ArgumentException The chunk search token is not a token of a search by chunks of the repository.
ObjectDisposedException The index of the next chunk is disposed.

Remarks

The chunks of the indexes of the repository follow one another: the next chunk of the same index, or the first chunk of the next index. The search goes through the indexes that the repository had when the search started, and NextChunkSearchToken is null after the last chunk of the last index.

The errors of the search of a chunk are reported as SearchNext reports them: by the ErrorOccurred event of the index and of the repository, and in Warnings of the result.

Examples

The example demonstrates how to perform a search by chunks in an index repository.

string indexFolder1 = @"c:\MyIndex1\";
string indexFolder2 = @"c:\MyIndex2\";
string documentsFolder1 = @"c:\MyDocuments1\";
string documentsFolder2 = @"c:\MyDocuments2\";
string query = "Einstein";

IndexRepository repository = new IndexRepository();
Index index1 = repository.Create(indexFolder1); // Creating the first index
index1.Add(documentsFolder1); // Indexing documents
Index index2 = repository.Create(indexFolder2); // Creating the second index
index2.Add(documentsFolder2);

SearchOptions options = new SearchOptions();
options.IsChunkSearch = true; // Enabling the search by chunks

SearchResult result = repository.Search(query, options); // Starting the search by chunks
Console.WriteLine("Document count: " + result.DocumentCount);

while (result.NextChunkSearchToken != null)
{
    result = repository.SearchNext(result.NextChunkSearchToken); // Continuing the search by chunks
    Console.WriteLine("Document count: " + result.DocumentCount);
}

See Also


SearchNext(ChunkSearchToken, Cancellation)

Continues the search by chunks of the repository started with the Search method.

public SearchResult SearchNext(ChunkSearchToken chunkSearchToken, Cancellation cancellation)
Parameter Type Description
chunkSearchToken ChunkSearchToken The chunk search token.
cancellation Cancellation The cancellation object.

Return Value

The search result.

Exceptions

exception condition
ArgumentNullException The chunk search token is null.
ArgumentException The chunk search token is not a token of a search by chunks of the repository.
ObjectDisposedException The index of the next chunk is disposed.

Remarks

The chunks of the indexes of the repository follow one another: the next chunk of the same index, or the first chunk of the next index. The search goes through the indexes that the repository had when the search started, and NextChunkSearchToken is null after the last chunk of the last index.

The errors of the search of a chunk are reported as SearchNext reports them: by the ErrorOccurred event of the index and of the repository, and in Warnings of the result.

Examples

The example demonstrates how to perform a search by chunks in an index repository.

string indexFolder1 = @"c:\MyIndex1\";
string indexFolder2 = @"c:\MyIndex2\";
string documentsFolder1 = @"c:\MyDocuments1\";
string documentsFolder2 = @"c:\MyDocuments2\";
string query = "Einstein";

IndexRepository repository = new IndexRepository();
Index index1 = repository.Create(indexFolder1); // Creating the first index
index1.Add(documentsFolder1); // Indexing documents
Index index2 = repository.Create(indexFolder2); // Creating the second index
index2.Add(documentsFolder2);

Cancellation cancellation = new Cancellation(); // The cancellation of the search and of its continuations
SearchOptions options = new SearchOptions();
options.IsChunkSearch = true; // Enabling the search by chunks
options.Cancellation = cancellation;

SearchResult result = repository.Search(query, options); // Starting the search by chunks
Console.WriteLine("Document count: " + result.DocumentCount);

while (result.NextChunkSearchToken != null)
{
    // Continuing the search by chunks
    result = repository.SearchNext(result.NextChunkSearchToken, cancellation);
    Console.WriteLine("Document count: " + result.DocumentCount);
}

See Also