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.
constindexFolder='c:/MyIndex/';constdocumentsFolder1='c:/MyDocuments/';constdocumentsFolder2='c:/MyDocuments2/';// Creating an index in the specified folder
constindex=newgroupdocs.search.Index(indexFolder);// Indexing documents from the specified folders
index.add(documentsFolder1);index.add(documentsFolder2);// Getting indexed paths from the index
constindexedPaths1=index.getIndexedPaths();// Writing indexed paths to the console
console.log('Indexed paths:');for(leti=0;i<indexedPaths1.length;i++){constindexedPath=indexedPaths1[i];console.log('\t'+indexedPath);}// Deleting index path from the index
constdeleteResult=index.delete([documentsFolder1],newgroupdocs.search.UpdateOptions());// Getting indexed paths after deletion
constindexedPaths2=index.getIndexedPaths();console.log('\nDeleted paths: '+deleteResult.getSuccessCount());console.log('\nIndexed paths:');for(leti=0;i<indexedPaths2.length;i++){constindexedPath=indexedPaths2[i];console.log('\t'+indexedPath);}
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: