diff --git a/nominatim/api/search/icu_tokenizer.py b/nominatim/api/search/icu_tokenizer.py index 05ec7690c..eb90c122e 100644 --- a/nominatim/api/search/icu_tokenizer.py +++ b/nominatim/api/search/icu_tokenizer.py @@ -122,10 +122,10 @@ def from_db_row(row: SaRow) -> 'ICUToken': else: lookup_word = row.word_token - return ICUToken(penalty=penalty, token=row.word_id, count=count, + return ICUToken(penalty=penalty, token=row.word_id, count=max(1, count), lookup_word=lookup_word, is_indexed=True, word_token=row.word_token, info=row.info, - addr_count=addr_count) + addr_count=max(1, addr_count)) diff --git a/nominatim/api/search/legacy_tokenizer.py b/nominatim/api/search/legacy_tokenizer.py index bd17706e5..031f2456c 100644 --- a/nominatim/api/search/legacy_tokenizer.py +++ b/nominatim/api/search/legacy_tokenizer.py @@ -209,7 +209,7 @@ def make_token(self, row: SaRow) -> Tuple[LegacyToken, qmod.TokenType]: is_indexed = False return LegacyToken(penalty=penalty, token=row.word_id, - count=row.search_name_count or 1, + count=max(1, row.search_name_count or 1), addr_count=1, # not supported lookup_word=lookup_word, word_token=row.word_token.strip(),