mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
tweak postcode search
Give a preference to left-right reading, i.e <postcode>,<address> prefers a postcode search while <address>,<postcode> rather does an address search. Also exclude non-addressables, countries and state from results when a postcode is contained in the query.
This commit is contained in:
@@ -270,7 +270,12 @@ class _TokenSequence:
|
||||
if (base.postcode.start == 0 and self.direction != -1)\
|
||||
or (base.postcode.end == query.num_token_slots() and self.direction != 1):
|
||||
log().comment('postcode search')
|
||||
yield dataclasses.replace(base, penalty=self.penalty)
|
||||
# <address>,<postcode> should give preference to address search
|
||||
if base.postcode.start == 0:
|
||||
penalty = self.penalty
|
||||
else:
|
||||
penalty = self.penalty + 0.1
|
||||
yield dataclasses.replace(base, penalty=penalty)
|
||||
|
||||
# Postcode or country-only search
|
||||
if not base.address:
|
||||
@@ -278,6 +283,9 @@ class _TokenSequence:
|
||||
log().comment('postcode/country search')
|
||||
yield dataclasses.replace(base, penalty=self.penalty)
|
||||
else:
|
||||
# <postcode>,<address> should give preference to postcode search
|
||||
if base.postcode and base.postcode.start == 0:
|
||||
self.penalty += 0.1
|
||||
# Use entire first word as name
|
||||
if self.direction != -1:
|
||||
log().comment('first word = name')
|
||||
|
||||
Reference in New Issue
Block a user