]> git.openstreetmap.org Git - nominatim.git/commitdiff
do not rerank address by full match in postcode search
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 20 Feb 2025 09:15:03 +0000 (10:15 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 20 Feb 2025 09:29:03 +0000 (10:29 +0100)
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.

src/nominatim_api/search/db_searches.py

index 3a4c826fd871c0a60725d62188066e0bbd9ae7d9..8e37c7482d11a8e7251ebfe105d69669113487c5 100644 (file)
@@ -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)))
                      .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)
 
         penalty += sa.case(*((t.c.postcode == v, p) for v, p in self.postcodes),
                            else_=1.0)