From 09b5ea097b32d66fdc44e38208ff62325048b2d9 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 12 Jul 2025 11:17:07 +0200 Subject: [PATCH] restrict pre-selection by postcode to country --- src/nominatim_api/search/db_searches/address_search.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nominatim_api/search/db_searches/address_search.py b/src/nominatim_api/search/db_searches/address_search.py index 77aa79cf..32d4555b 100644 --- a/src/nominatim_api/search/db_searches/address_search.py +++ b/src/nominatim_api/search/db_searches/address_search.py @@ -175,10 +175,11 @@ class AddressSearch(base.AbstractSearch): sql = sql.where(t.c.country_code.in_(self.countries.values)) if self.postcodes: - if not self.has_address_terms or self.expected_count > 10000: + if self.expected_count > 10000: tpc = conn.t.postcode sql = sql.where(sa.select(tpc.c.postcode) .where(tpc.c.postcode.in_(self.postcodes.values)) + .where(tpc.c.country_code == t.c.country_code) .where(t.c.centroid.within_distance(tpc.c.geometry, 0.4)) .exists()) -- 2.39.5