This page contains a description of updating indexed documents, as well as updating an index version.
Update indexed documents
The update operation is used to reindex documents that have been changed, deleted or added to indexed folders. Changing a filter specified by the DocumentFilter property of the IndexSettings class can also lead to a change in the list of indexed documents.
When updating, the same options can be specified in the instance of the UpdateOptions class, which are set in the IndexingOptions class to specify indexing options. See the Indexing options page.
The following example demonstrates how to update an index using 2 threads.
C#
stringindexFolder=@"c:\MyIndex\";stringdocumentFolder=@"c:\MyDocuments\";// Creating an index in the specified folderIndexindex=newIndex(indexFolder);// Indexing documents from the specified folderindex.Add(documentFolder);// Change, delete, add documents in the document folder// ...UpdateOptionsoptions=newUpdateOptions();options.Threads=2;// Setting the number of indexing threadsindex.Update(options);// Updating the index
Update index version
Sometimes when a new version of the GroupDocs.Search library is released, the format for storing the index on disk changes. In this case, you also need to update the index. However, updating the index version is different. To do this, use the IndexUpdater class. Without updating the index version, loading the index of the previous version will fail.
When the index version is updated, the documents are reindexed and saved in a folder different from the original in the new format. However, the index of old version does not change. The folder containing the old version of the index may be deleted after the update. The following example demonstrates updating a previous version of an index.
C#
stringsourceIndexFolder=@"c:\MyOldIndex\";stringtargetIndexFolder=@"c:\MyNewIndex\";IndexUpdaterupdater=newIndexUpdater();if(updater.CanUpdateVersion(sourceIndexFolder)){// The index of old version does not changeVersionUpdateResultresult=updater.UpdateVersion(sourceIndexFolder,targetIndexFolder);}
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: