diff --git a/integrations/elasticsearch/src/elasticsearch_haystack/document_store.py b/integrations/elasticsearch/src/elasticsearch_haystack/document_store.py index c498fe55e..c34e58196 100644 --- a/integrations/elasticsearch/src/elasticsearch_haystack/document_store.py +++ b/integrations/elasticsearch/src/elasticsearch_haystack/document_store.py @@ -12,6 +12,7 @@ from haystack import default_from_dict, default_to_dict from haystack.dataclasses import Document from haystack.document_stores import document_store, DocumentStoreError, DuplicateDocumentError, DuplicatePolicy +from haystack.utils.filters import convert from elasticsearch_haystack.filters import _normalize_filters @@ -128,6 +129,9 @@ def _search_documents(self, **kwargs) -> List[Document]: return documents def filter_documents(self, filters: Optional[Dict[str, Any]] = None) -> List[Document]: + if "operator" not in filters and "conditions" not in filters: + filters = convert(filters) + query = {"bool": {"filter": _normalize_filters(filters)}} if filters else None documents = self._search_documents(query=query) return documents