From 08341f5698cdf14fc87b2b1c4a73d87b86130b3c Mon Sep 17 00:00:00 2001 From: Sara Zan Date: Fri, 29 Oct 2021 10:10:03 +0200 Subject: [PATCH] Raise a warning if the 'query' param of the 'query' method of 'ElasticsearchDocumentStore' is not a string. (#1674) --- haystack/document_stores/elasticsearch.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/haystack/document_stores/elasticsearch.py b/haystack/document_stores/elasticsearch.py index 222648c00..9e7c6d333 100644 --- a/haystack/document_stores/elasticsearch.py +++ b/haystack/document_stores/elasticsearch.py @@ -721,6 +721,9 @@ class ElasticsearchDocumentStore(BaseDocumentStore): # Default Retrieval via BM25 using the user query on `self.search_fields` else: + if not isinstance(query, str): + logger.warning("The query provided seems to be not a string, but an object " + f"of type {type(query)}. This can cause Elasticsearch to fail.") body = { "size": str(top_k), "query": {