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 get_indexed_paths method of the Index class.
Deleting documents does not rewrite the index. Deleted documents are excluded from search results immediately, but their data remain in the index files until the index is optimized. Therefore, after deleting a large number of documents, call the optimize method to physically remove them and free up disk space. The DeleteResult object returned by the delete method contains the total, successful and failed counts, the results for individual items and the error messages.
The following example shows how to remove indexed paths from an index.
fromgroupdocs.searchimportIndexfromgroupdocs.search.optionsimportUpdateOptionsdocuments_folder1="./documents"documents_folder2="./documents2"# Creating an index in the specified folderindex=Index("./index")# Indexing documents from the specified foldersindex.add(documents_folder1)index.add(documents_folder2)# Getting indexed paths from the indexindexed_paths1=index.get_indexed_paths()# Writing indexed paths to the consoleprint("Indexed paths:")forpathinindexed_paths1:print("\t"+path)# Deleting indexed path from the indexdelete_result=index.delete([documents_folder1],UpdateOptions())# Getting indexed paths after deletionindexed_paths2=index.get_indexed_paths()print("\nDeleted paths: "+str(delete_result.success_count))print("\nIndexed paths:")forpathinindexed_paths2:print("\t"+path)
Along with the full-featured library, we provide a free online document search app. You are welcome to search over your PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX and more with our Free Online Document Search App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.