From 152337196ff6e4d879e4e01d055b461ff0075792 Mon Sep 17 00:00:00 2001 From: Yannic Spreen-Ledebur <35889034+spreeni@users.noreply.github.com> Date: Thu, 5 Sep 2024 19:17:24 +0200 Subject: [PATCH] Refresh Opensearch index after delete operation (#15854) --- .../CHANGELOG.md | 4 ++++ .../llama_index/vector_stores/opensearch/base.py | 12 +++++++++--- .../pyproject.toml | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/CHANGELOG.md b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/CHANGELOG.md index bcbd5d3ab7ff8b..839183749d8029 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/CHANGELOG.md +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG — llama-index-vector-stores-opensearch +## [0.2.1] + +- Refresh Opensearch index after delete operation to reflect the change for future searches + ## [0.1.14] - Adds support for full MetadataFilters (all operators and nested filters) diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/llama_index/vector_stores/opensearch/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/llama_index/vector_stores/opensearch/base.py index 662cc15f5eda6e..c05ce4bf885668 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/llama_index/vector_stores/opensearch/base.py +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/llama_index/vector_stores/opensearch/base.py @@ -466,7 +466,9 @@ async def delete_by_doc_id(self, doc_id: str) -> None: search_query = { "query": {"term": {"metadata.doc_id.keyword": {"value": doc_id}}} } - await self._os_client.delete_by_query(index=self._index, body=search_query) + await self._os_client.delete_by_query( + index=self._index, body=search_query, refresh=True + ) async def delete_nodes( self, @@ -490,12 +492,16 @@ async def delete_nodes( if filters: query["query"]["bool"]["filter"].extend(self._parse_filters(filters)) - await self._os_client.delete_by_query(index=self._index, body=query) + await self._os_client.delete_by_query( + index=self._index, body=query, refresh=True + ) async def clear(self) -> None: """Clears index.""" query = {"query": {"bool": {"filter": []}}} - await self._os_client.delete_by_query(index=self._index, body=query) + await self._os_client.delete_by_query( + index=self._index, body=query, refresh=True + ) async def aquery( self, diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/pyproject.toml b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/pyproject.toml index dc78447bcd99dd..00a6f57f11fe4b 100644 --- a/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/pyproject.toml +++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-opensearch/pyproject.toml @@ -27,7 +27,7 @@ exclude = ["**/BUILD"] license = "MIT" name = "llama-index-vector-stores-opensearch" readme = "README.md" -version = "0.2.0" +version = "0.2.1" [tool.poetry.dependencies] python = ">=3.8.1,<4.0"