mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 05:14:07 +00:00
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.
This commit is contained in:
@@ -581,9 +581,13 @@ class PostcodeSearch(AbstractSearch):
|
|||||||
.where((tsearch.c.name_vector + tsearch.c.nameaddress_vector)
|
.where((tsearch.c.name_vector + tsearch.c.nameaddress_vector)
|
||||||
.contains(sa.type_coerce(self.lookups[0].tokens,
|
.contains(sa.type_coerce(self.lookups[0].tokens,
|
||||||
IntArray)))
|
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),
|
penalty += sa.case(*((t.c.postcode == v, p) for v, p in self.postcodes),
|
||||||
else_=1.0)
|
else_=1.0)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user