Update Elastics store delete() (#84)

This commit is contained in:
Tuan Anh Nguyen Dang (Tadashi_Cin)
2023-11-21 15:29:00 +07:00
committed by GitHub
parent 9a96a9b876
commit 3ac277cc0b
2 changed files with 38 additions and 1 deletions

View File

@@ -153,7 +153,12 @@ class ElasticsearchDocumentStore(BaseDocumentStore):
def delete(self, ids: Union[List[str], str]):
"""Delete document by id"""
raise NotImplementedError("Delete by-id is a Work-in-Progress.")
if not isinstance(ids, list):
ids = [ids]
query = {"query": {"terms": {"_id": ids}}}
self.client.delete_by_query(index=self.index_name, body=query)
self.client.indices.refresh(index=self.index_name)
def save(self, path: Union[str, Path]):
"""Save document to path"""