Text search in network

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Search MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-search -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-search/search-net-mcp:latest
Folders, licensing and more →

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.getSearcher();

SearchOptions options = new SearchOptions();
options.setChunkSearch(true);
options.setUseSynonymSearch(useSynonymSearch);
int totalOccurrences = 0;
ArrayList<NetworkFoundDocument> documents = new ArrayList<NetworkFoundDocument>();

NetworkSearchResult result;
if (isObjectForm) {
    SearchQuery query = SearchQuery.createWordQuery(word);
    System.out.println();
    System.out.println("First time search in object form for: " + query);
    result = searcher.searchFirst(query, options);
} else {
    String query = word;
    System.out.println();
    System.out.println("First time search in text form for: " + query);
    result = searcher.searchFirst(query, options);
}

addDocsFromResult(documents, result);
totalOccurrences += result.getOccurrenceCount();
traceResult(result);

while (result.getNextChunkSearchToken() != null) {
    System.out.println();
    System.out.println("Next time search for: " + word);

    result = searcher.searchNext(result.getNextChunkSearchToken());

    addDocsFromResult(documents, result);
    totalOccurrences += result.getOccurrenceCount();
    traceResult(result);
}

System.out.println();
System.out.println("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.