Skip to content

Commit

Permalink
Convert legacy filters if used
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Nov 29, 2023
1 parent 49a2c01 commit 01dcf59
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 01dcf59

Please sign in to comment.