GroupDocs.Search supports the ability to remove indexed files and folders from an index. Only files or folders that were explicitly added to the index can be deleted. It is not possible to remove a file or folder from the index that is a child of the indexed folder. To delete files and folders inside indexed paths, use the document filter (see Document filtering during indexing). To get a list of indexed paths, use the GetIndexedPaths method of the Index class.
The following example shows how to remove indexed paths from an index.
C#
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder1=@"c:\MyDocuments\";stringdocumentsFolder2=@"c:\MyDocuments2\";// Creating an index in the specified folderIndexindex=newIndex(indexFolder);// Indexing documents from the specified foldersindex.Add(documentsFolder1);index.Add(documentsFolder2);// Getting indexed paths from the indexstring[]indexedPaths1=index.GetIndexedPaths();// Writing indexed paths to the consoleConsole.WriteLine("Indexed paths:");foreach(stringpathinindexedPaths1){Console.WriteLine("\t"+path);}// Deleting indexed path from the indexDeleteResultdeleteResult=index.Delete(newstring[]{documentsFolder1},newUpdateOptions());// Getting indexed paths after deletionstring[]indexedPaths2=index.GetIndexedPaths();Console.WriteLine("\nDeleted paths: "+deleteResult.SuccessCount);Console.WriteLine("\nIndexed paths:");foreach(stringpathinindexedPaths2){Console.WriteLine("\t"+path);}
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: