All search network shards can be optimized with a single call the Optimize method of the Indexer class.
The optimization minimizes the number of index segments on each shard. As a result, search performance increases.
An asynchronous execution flag is available as an option. In the case of asynchronous optimization, you can track the completion of the operation by subscribing to the OptimizationCompleted event.
The following code example demonstrates how to perform search network optimization.