From: Sarah Hoffmann Date: Wed, 31 Jul 2024 12:09:35 +0000 (+0200) Subject: make housenumber search work with non-indexed partials X-Git-Tag: deploy~4^2~3^2~2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/cfe5284f644bb749614c5fbaf130f906473208e3 make housenumber search work with non-indexed partials --- diff --git a/src/nominatim_api/search/db_search_builder.py b/src/nominatim_api/search/db_search_builder.py index e29f0b93..6453509e 100644 --- a/src/nominatim_api/search/db_search_builder.py +++ b/src/nominatim_api/search/db_search_builder.py @@ -167,7 +167,12 @@ class SearchBuilder: expected_count = sum(t.count for t in hnrs) partials = {t.token: t.addr_count for trange in address - for t in self.query.get_partials_list(trange)} + for t in self.query.get_partials_list(trange) + if t.is_indexed} + + if not partials: + # can happen when none of the partials is indexed + return if expected_count < 8000: sdata.lookups.append(dbf.FieldLookup('nameaddress_vector', diff --git a/src/nominatim_api/search/legacy_tokenizer.py b/src/nominatim_api/search/legacy_tokenizer.py index ecb0bbfe..68cbd712 100644 --- a/src/nominatim_api/search/legacy_tokenizer.py +++ b/src/nominatim_api/search/legacy_tokenizer.py @@ -253,13 +253,14 @@ class LegacyQueryAnalyzer(AbstractQueryAnalyzer): def _dump_word_tokens(query: qmod.QueryStruct) -> Iterator[List[Any]]: - yield ['type', 'token', 'word_token', 'lookup_word', 'penalty', 'count', 'info'] + yield ['type', 'token', 'word_token', 'lookup_word', 'penalty', 'count', 'info', 'indexed'] for node in query.nodes: for tlist in node.starting: for token in tlist.tokens: t = cast(LegacyToken, token) yield [tlist.ttype.name, t.token, t.word_token or '', - t.lookup_word or '', t.penalty, t.count, t.info] + t.lookup_word or '', t.penalty, t.count, t.info, + 'Y' if t.is_indexed else 'N'] async def create_query_analyzer(conn: SearchConnection) -> AbstractQueryAnalyzer: