From 53ed483f9c329fadd13c367bf38be395f382120a Mon Sep 17 00:00:00 2001 From: j Date: Tue, 21 Jan 2020 14:09:01 +0100 Subject: [PATCH 1/2] don't fail with empty fulltext query --- pandora/document/fulltext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandora/document/fulltext.py b/pandora/document/fulltext.py index b383e8df..5ecdab05 100644 --- a/pandora/document/fulltext.py +++ b/pandora/document/fulltext.py @@ -63,7 +63,7 @@ class FulltextMixin: @classmethod def find_fulltext_ids(cls, query): - if query[0] == '"' and query[-1] == '"': + if query and query[0] == '"' and query[-1] == '"': query = { "match_phrase": { "text": query.lower()[1:-1] From a2ff9480cf14728d28f808ee54743f7b8b177fc6 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 21 Jan 2020 14:09:38 +0100 Subject: [PATCH 2/2] no results for empty query --- pandora/document/fulltext.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandora/document/fulltext.py b/pandora/document/fulltext.py index 5ecdab05..040658ce 100644 --- a/pandora/document/fulltext.py +++ b/pandora/document/fulltext.py @@ -63,7 +63,9 @@ class FulltextMixin: @classmethod def find_fulltext_ids(cls, query): - if query and query[0] == '"' and query[-1] == '"': + if not query: + return [] + elif query[0] == '"' and query[-1] == '"': query = { "match_phrase": { "text": query.lower()[1:-1]