From 1a6761021459189e0ae8b54175aa427fc431007f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Wroniszewski?= Date: Wed, 2 Oct 2024 18:43:46 +0200 Subject: [PATCH] Increase exp_count thresholds 3-fold only for frequent partials --- src/nominatim_api/search/db_search_builder.py | 2 +- src/nominatim_api/search/db_searches.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nominatim_api/search/db_search_builder.py b/src/nominatim_api/search/db_search_builder.py index 6453509eb..adbdadaed 100644 --- a/src/nominatim_api/search/db_search_builder.py +++ b/src/nominatim_api/search/db_search_builder.py @@ -243,7 +243,7 @@ def yield_lookups(self, name: TokenRange, address: List[TokenRange])\ # To catch remaining results, lookup by name and address # We only do this if there is a reasonable number of results expected. exp_count = exp_count / (2**len(addr_tokens)) if addr_tokens else exp_count - if exp_count < 10000 and addr_count < 20000\ + if exp_count < 30000 and addr_count < 20000\ and all(t.is_indexed for t in name_partials.values()): penalty += 0.35 * max(1 if name_fulls else 0.1, 5 - len(name_partials) - len(addr_tokens)) diff --git a/src/nominatim_api/search/db_searches.py b/src/nominatim_api/search/db_searches.py index 35c063fc9..48d7b27b8 100644 --- a/src/nominatim_api/search/db_searches.py +++ b/src/nominatim_api/search/db_searches.py @@ -673,7 +673,7 @@ def _inner_search_name_cte(self, conn: SearchConnection, if self.postcodes: # if a postcode is given, don't search for state or country level objects sql = sql.where(t.c.address_rank > 9) - if self.expected_count > 10000: + if self.expected_count > 30000: # Many results expected. Restrict by postcode. tpc = conn.t.postcode sql = sql.where(sa.select(tpc.c.postcode)