Delete a Document from Index
Deleting specific documents from your index is a crucial part of maintaining your data. The HoppySearch Python client makes it simple to remove individual documents from your index. Follow the instructions below to delete a document:
Getting Started
Before using the HoppySearch Python client to delete a document from your index, ensure you have completed the initial configuration as described in the HoppySearch Python Client documentation.
Deleting a Document
To delete a specific document from your index, use the following code:
- python
hs_guid = "15b522d8-1545-4dc9-9160-0b512f7d6997"
optionals = {
"diag": True,
"showStats": True
}
try:
response = hoppysearch.delete(hs_guid, optionals)
print(response)
except ApiException as e:
print("Exception: %s\n" % e)
Understanding the Code
- hs_guid: Replace this with the unique identifier (GUID) of the document you want to delete. This identifier should correspond to the document you wish to remove from your index.
- optionals: This dictionary allows you to specify optional parameters for the deletion operation.
- diag:
- True: Enables extra diagnostics recording.
- False: Disables diagnostics recording.
- showStats:
- True: Provides statistics about the deletion operation.
- False: Does not provide statistics.
- diag:
By executing this code, you can selectively remove individual documents from your index, ensuring your data remains accurate and up-to-date.