The second parameter of the GetDocumentText method is the result output adapter. In this operation, the same output adapter classes are used as those used in similar operations of a single index. For information about output adapters, see the Output adapters page.
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.
C#
stringbasePath=@"c:\SearchNetwork\";intbasePort=49100;// Loading the search network configuration from a fileConfigurationconfiguration=Configuration.Load(basePath+"Configuration.xml");// Creating, configuring and starting the master node; the timeouts are specified in millisecondsSearchNetworkNodenode=SearchNetworkNode.CreateMasterNode(0,basePath+"Node0",newTcpSettings(basePort,3000,3000,3000,1000),newFileLogger(basePath+"Log.txt",4.0),configuration);node.ConfigureAllNodes();node.Start();
The following code example, which continues the previous one, demonstrates retrieving the text of a document indexed in the search network, as well as outputting the resulting data to the console.
C#
stringfileName="Lorem ipsum.pdf";// The name of the document to get the text ofSearchersearcher=node.Searcher;List<NetworkDocumentInfo>documents=newList<NetworkDocumentInfo>();int[]shardIndices=node.GetShardIndices();for(inti=0;i<shardIndices.Length;i++){intshardIndex=shardIndices[i];NetworkDocumentInfo[]infos=searcher.GetIndexedDocuments(shardIndex);documents.AddRange(infos);for(intj=0;j<infos.Length;j++){NetworkDocumentInfoinfo=infos[j];NetworkDocumentInfo[]items=searcher.GetIndexedDocumentItems(info);documents.AddRange(items);}}for(inti=0;i<documents.Count;i++){NetworkDocumentInfodocument=documents[i];if(document.DocumentInfo.ToString().Contains(fileName)){Console.WriteLine();Console.WriteLine(document.DocumentInfo.ToString());StringOutputAdapteroutputAdapter=newStringOutputAdapter(OutputFormat.PlainText);searcher.GetDocumentText(document,outputAdapter);Console.WriteLine(outputAdapter.GetResult());break;}}
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: