Text search in network

To run a text search, use the SearchFirst method of the Searcher class. This method returns the first portion of results.

To continue the search, the SearchNext method is used, returning the second and subsequent portions of results.

Text and object forms of the search query are supported when appropriate overloads of the SearchFirst method are used. The options for a network search are the same as those for a single index search.

The following code example demonstrates performing a full-text search on the search network.


Searcher searcher = node.Searcher;

SearchQuery query = SearchQuery.CreateWordQuery(word);
Console.WriteLine("First time search for: " + query);
SearchOptions options = new SearchOptions();
options.IsChunkSearch = true;
options.UseSynonymSearch = useSynonymSearch;
int totalOccurrences = 0;
List<NetworkFoundDocument> documents = new List<NetworkFoundDocument>();

NetworkSearchResult result = searcher.SearchFirst(query, options);

AddDocsFromResult(documents, result);
totalOccurrences += result.OccurrenceCount;

while (result.NextChunkSearchToken != null)
    Console.WriteLine("Next time search for: " + query);

    result = searcher.SearchNext(result.NextChunkSearchToken);

    AddDocsFromResult(documents, result);
    totalOccurrences += result.OccurrenceCount;

Console.WriteLine("Total occurrences: " + totalOccurrences);

More information about search queries can be found in the article Queries in text and object form.

More resources

GitHub examples

You may easily run the code from documentation articles and see the features in action in our GitHub examples:

Free online document search App

Along with full featured .NET library we provide simple, but powerful free Apps.

You are welcome to search over your PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX and more with our free online Free Online Document Search App.