To run a text search, use the search_first method of the Searcher class. This method returns the first portion of results.
To continue the search, the search_next method is used, returning the second and subsequent portions of results. Continue the search while the next_chunk_search_token property of the result is not None.
Text and object forms of the search query are supported when appropriate overloads of the search_first method are used. The options for a network search are the same as those for a single index search, but a search network performs only chunk search: set the is_chunk_search option to True, otherwise the search_first method raises ValueError.
Each portion of results is returned as a NetworkSearchResult object, which has the following members:
node_index — the index of the node from which the result was received;
next_chunk_search_token — the token for continuing the search, or None if the search is complete.
A found document is represented by the NetworkFoundDocument class, which contains the found_document object, as in a single index search, and the index of the shard where the document was found (shard_index property).
The examples on this page use the master node of a running search network. The following code creates and starts the master node as described on the Search network deployment page; the slave nodes must be started beforehand. The examples that follow continue this code in the same Python process.
fromgroupdocs.search.commonimportFileLoggerfromgroupdocs.search.scalingimportSearchNetworkNodefromgroupdocs.search.scaling.configuringimportConfiguration,TcpSettingsbase_path="./SearchNetwork/"base_port=49100# Loading the search network configuration from a fileconfiguration=Configuration.load(base_path+"Configuration.xml")# Creating, configuring and starting the master node; the timeouts are specified in millisecondsnode=SearchNetworkNode.create_master_node(0,base_path+"Node0",TcpSettings(base_port,3000,3000,3000,1000),FileLogger(base_path+"Log.txt",4.0),configuration)node.configure_all_nodes()node.start()