From: Sarah Hoffmann Date: Thu, 20 Feb 2025 09:15:03 +0000 (+0100) Subject: do not rerank address by full match in postcode search X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/add9244a2f43a27c41fab2c8f95b14c89d97b0e5?ds=sidebyside do not rerank address by full match in postcode search The reranking result will not be completely correct because the address of a postcode refer to the address _and_ name of the parent and reranking was only done against the address. We assume here that the postcode is precise enough as to not require a penalty to to partial matches. --- diff --git a/src/nominatim_api/search/db_searches.py b/src/nominatim_api/search/db_searches.py index 3a4c826f..8e37c748 100644 --- a/src/nominatim_api/search/db_searches.py +++ b/src/nominatim_api/search/db_searches.py @@ -581,9 +581,13 @@ class PostcodeSearch(AbstractSearch): .where((tsearch.c.name_vector + tsearch.c.nameaddress_vector) .contains(sa.type_coerce(self.lookups[0].tokens, IntArray))) + # Do NOT add rerank penalties based on the address terms. + # The standard rerank penalty only checks the address vector + # while terms may appear in name and address vector. This would + # lead to overly high penalties. + # We assume that a postcode is precise enough to not require + # additional full name matches. - for ranking in self.rankings: - penalty += ranking.sql_penalty(conn.t.search_name) penalty += sa.case(*((t.c.postcode == v, p) for v, p in self.postcodes), else_=1.0)