Minimizes the number of index segments by merging them one with another. This operation improves search performance.
publicvoidOptimize()
Examples
The example demonstrates how to merge segments of an index.
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder1=@"c:\MyDocuments1\";stringdocumentsFolder2=@"c:\MyDocuments2\";stringdocumentsFolder3=@"c:\MyDocuments3\";Indexindex=newIndex(indexFolder);// Creating index in the specified folderindex.Add(documentsFolder1);// Indexing documents from the specified folderindex.Add(documentsFolder2);// Each call to Add creates at least one new segment in the indexindex.Add(documentsFolder3);// Merging segments of the indexindex.Optimize();
Minimizes the number of index segments by merging them one with another. This operation improves search performance.
publicvoidOptimize(MergeOptionsoptions)
Parameter
Type
Description
options
MergeOptions
The merge options.
Examples
The example demonstrates how to merge segments of an index with particular merge options.
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder1=@"c:\MyDocuments1\";stringdocumentsFolder2=@"c:\MyDocuments2\";stringdocumentsFolder3=@"c:\MyDocuments3\";Indexindex=newIndex(indexFolder);// Creating index in the specified folderindex.Add(documentsFolder1);// Indexing documents from the specified folderindex.Add(documentsFolder2);// Each call to Add creates at least one new segment in the indexindex.Add(documentsFolder3);MergeOptionsoptions=newMergeOptions();options.IsAsync=true;// Asynchronous operationoptions.Cancellation=newCancellation();// Creating cancellation object// Merging segments of the indexindex.Optimize(options);// This method will return before the operation is completedoptions.Cancellation.CancelAfter(10000);// Setting maximum duration of the operation to 10 seconds