diff --git a/haystack/document_store/elasticsearch.py b/haystack/document_store/elasticsearch.py index 3e2d60545..d3f94bcbf 100644 --- a/haystack/document_store/elasticsearch.py +++ b/haystack/document_store/elasticsearch.py @@ -437,14 +437,13 @@ class ElasticsearchDocumentStore(BaseDocumentStore): } # type: Dict[str,Any] if filters: - filter_clause = [] for key, values in filters.items(): - filter_clause.append( - { - "terms": {key: values} - } - ) - body["query"]["bool"]["filter"] = filter_clause + if type(values) != list: + raise ValueError(f'Wrong filter format for key "{key}": Please provide a list of allowed values for each key. ' + 'Example: {"name": ["some", "more"], "category": ["only_one"]} ') + body["query"]["script_score"]["query"] = { + "terms": filters + } if self.excluded_meta_data: body["_source"] = {"excludes": self.excluded_meta_data}