From 3d2693d2e429e584250f222c6b7c149b0142aa3b Mon Sep 17 00:00:00 2001 From: Vladimir Blagojevic Date: Thu, 12 Sep 2024 15:30:03 +0200 Subject: [PATCH] chore: ElasticSearch - remove legacy filters elasticsearch (#1078) * Remove legacy filter support * Improve error message * Error msg fmt --- .../document_stores/elasticsearch/document_store.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/elasticsearch/src/haystack_integrations/document_stores/elasticsearch/document_store.py b/integrations/elasticsearch/src/haystack_integrations/document_stores/elasticsearch/document_store.py index 11016e3fc..734e2d2b8 100644 --- a/integrations/elasticsearch/src/haystack_integrations/document_stores/elasticsearch/document_store.py +++ b/integrations/elasticsearch/src/haystack_integrations/document_stores/elasticsearch/document_store.py @@ -12,7 +12,6 @@ from haystack.dataclasses import Document from haystack.document_stores.errors import DocumentStoreError, DuplicateDocumentError from haystack.document_stores.types import DuplicatePolicy -from haystack.utils.filters import convert from haystack.version import __version__ as haystack_version from elasticsearch import Elasticsearch, helpers # type: ignore[import-not-found] @@ -224,7 +223,8 @@ def filter_documents(self, filters: Optional[Dict[str, Any]] = None) -> List[Doc :returns: List of `Document`s that match the filters. """ if filters and "operator" not in filters and "conditions" not in filters: - filters = convert(filters) + msg = "Invalid filter syntax. See https://docs.haystack.deepset.ai/docs/metadata-filtering for details." + raise ValueError(msg) query = {"bool": {"filter": _normalize_filters(filters)}} if filters else None documents = self._search_documents(query=query)