mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
disallow special housenumber search with a single frequent partial
This commit is contained in:
@@ -155,13 +155,21 @@ class SearchBuilder:
|
|||||||
""" Build a simple address search for special entries where the
|
""" Build a simple address search for special entries where the
|
||||||
housenumber is the main name token.
|
housenumber is the main name token.
|
||||||
"""
|
"""
|
||||||
partial_tokens: List[int] = []
|
sdata.lookups = [dbf.FieldLookup('name_vector', [t.token for t in hnrs], 'lookup_any')]
|
||||||
for trange in address:
|
|
||||||
partial_tokens.extend(t.token for t in self.query.get_partials_list(trange))
|
partials = [t for trange in address
|
||||||
|
for t in self.query.get_partials_list(trange)]
|
||||||
|
|
||||||
|
if len(partials) != 1 or partials[0].count < 10000:
|
||||||
|
sdata.lookups.append(dbf.FieldLookup('nameaddress_vector',
|
||||||
|
[t.token for t in partials], 'lookup_all'))
|
||||||
|
else:
|
||||||
|
sdata.lookups.append(
|
||||||
|
dbf.FieldLookup('nameaddress_vector',
|
||||||
|
[t.token for t
|
||||||
|
in self.query.get_tokens(address[0], TokenType.WORD)],
|
||||||
|
'lookup_any'))
|
||||||
|
|
||||||
sdata.lookups = [dbf.FieldLookup('name_vector', [t.token for t in hnrs], 'lookup_any'),
|
|
||||||
dbf.FieldLookup('nameaddress_vector', partial_tokens, 'lookup_all')
|
|
||||||
]
|
|
||||||
sdata.housenumbers = dbf.WeightedStrings([], [])
|
sdata.housenumbers = dbf.WeightedStrings([], [])
|
||||||
yield dbs.PlaceSearch(0.05, sdata, sum(t.count for t in hnrs))
|
yield dbs.PlaceSearch(0.05, sdata, sum(t.count for t in hnrs))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user