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.
Searchersearcher=node.getSearcher();SearchOptionsoptions=newSearchOptions();options.setChunkSearch(true);options.setUseSynonymSearch(useSynonymSearch);inttotalOccurrences=0;ArrayList<NetworkFoundDocument>documents=newArrayList<NetworkFoundDocument>();NetworkSearchResultresult;if(isObjectForm){SearchQueryquery=SearchQuery.createWordQuery(word);System.out.println();System.out.println("First time search in object form for: "+query);result=searcher.searchFirst(query,options);}else{Stringquery=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);