From ea25d36bf3d4a1075ad1398e92ffac9ca564c0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bournhonesque?= Date: Fri, 22 Sep 2023 23:25:53 +0200 Subject: [PATCH] fix: fix bug in parse_lucene_query --- TODO.md | 3 ++- app/query.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/TODO.md b/TODO.md index 9997833e..f116303b 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,5 @@ 1. Make it possible to search nutrient values (ES object type) 2. Index taxonomies in separate indices and allow to do search-as-you-type on taxonomies 3. Add a limit to number of page queryable (=10k results) -4. Remove obsolete products from collection \ No newline at end of file +4. Remove obsolete products from collection +5. Fix luqum parser that search in "text" field when searching: '"match phrase"' \ No newline at end of file diff --git a/app/query.py b/app/query.py index ac372f3a..685712e4 100644 --- a/app/query.py +++ b/app/query.py @@ -112,10 +112,15 @@ def parse_lucene_dsl_query( if luqum_tree is not None: logger.debug("parsed luqum tree: %s", repr(luqum_tree)) - # We join with space every non word not recognized by the parser - remaining_terms = " ".join( - item.value for item in luqum_tree.children if isinstance(item, Word) - ) + if luqum_tree.children: + # We join with space every non word not recognized by the parser + remaining_terms = " ".join( + item.value for item in luqum_tree.children if isinstance(item, Word) + ) + else: + # single term + remaining_terms = luqum_tree.value + processed_tree = UnknownOperationRemover().visit(luqum_tree) logger.debug("processed luqum tree: %s", repr(processed_tree)) if processed_tree.children: