From a40f985557975eaf4987925724b09c46f6decaf6 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 17 Jun 2025 11:47:54 +0200 Subject: 🐛 searches - raw search index: better management of terms with spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ishtar_common/models_common.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ishtar_common/models_common.py') diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 13447a4d3..bb786d48d 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -1013,6 +1013,7 @@ class FullSearch(models.Model): SEPS = [" ", "-", "/"] values = [] # split ID terms + # MNP 1995-1-1/42 -> ("MNP", "1995", "1", "42") for idx, sep in enumerate(SEPS): if not idx: values = value.split(sep) @@ -1021,9 +1022,13 @@ class FullSearch(models.Model): for val in values: new_values += val.split(sep) values = new_values + # stock also ID with separators + # MNP 1995-1-1 -> ("MNP", "1995-1-1") + for v in value.split(" "): + if v not in values: + values.append(v) + values = list(set(values)) for val in values: - if len(val) < 2: - continue val = val.replace("'", "").lower() result.append(f"'{val}':1") return result -- cgit v1.2.3