From 0a19cc18e5060e02eb76850cf428a4d9c48ec0c1 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Tue, 8 Aug 2023 14:59:33 +0200 Subject: [PATCH] block queries with lots of one and two letter terms --- nominatim/api/search/icu_tokenizer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nominatim/api/search/icu_tokenizer.py b/nominatim/api/search/icu_tokenizer.py index f259995d..ad08294e 100644 --- a/nominatim/api/search/icu_tokenizer.py +++ b/nominatim/api/search/icu_tokenizer.py @@ -192,7 +192,12 @@ class ICUQueryAnalyzer(AbstractQueryAnalyzer): standardized form search will work with. All information removed at this stage is inevitably lost. """ - return cast(str, self.normalizer.transliterate(text)) + norm = cast(str, self.normalizer.transliterate(text)) + numspaces = norm.count(' ') + if numspaces > 4 and len(norm) <= (numspaces + 1) * 3: + return '' + + return norm def split_query(self, query: qmod.QueryStruct) -> Tuple[QueryParts, WordDict]: -- 2.39.5