Synchronizing shards

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 →

If there is any communication interruption in the search network, some operations may not complete correctly. To resolve such problems, call the Synchronize method of the Indexer class. The method synchronizes the list of indexed documents kept by the indexer with the documents in the shards.

Since version 26.11, the Synchronize method throws InvalidOperationException and sends nothing to the shards when the master node cannot read its list of the documents of a shard, for example because another program holds it: a synchronization with an incomplete list would delete documents from the shard. Call the method again when the list can be read.

The asynchronous operation flag is available as an option (SynchronizeOptions.IsAsync). You can track the completion of the operation by subscribing to the SynchronizationCompleted event.

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#

string basePath = @"c:\SearchNetwork\";
int basePort = 49100;

// Loading the search network configuration from a file
Configuration configuration = Configuration.Load(basePath + "Configuration.xml");

// Creating, configuring and starting the master node; the timeouts are specified in milliseconds
SearchNetworkNode node = SearchNetworkNode.CreateMasterNode(
    0,
    basePath + "Node0",
    new TcpSettings(basePort, 3000, 3000, 3000, 1000),
    new FileLogger(basePath + "Log.txt", 4.0),
    configuration);
node.ConfigureAllNodes();
node.Start();

The following code example, which continues the previous one, demonstrates how to synchronize search network nodes.

C#

Console.WriteLine("Synchronizing shards");
Indexer indexer = node.Indexer;
SynchronizeOptions options = new SynchronizeOptions();
indexer.Synchronize(options);

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.