mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
use restrict for housenumber lookups with few numbers
This commit is contained in:
@@ -163,11 +163,15 @@ class SearchBuilder:
|
|||||||
housenumber is the main name token.
|
housenumber is the main name token.
|
||||||
"""
|
"""
|
||||||
sdata.lookups = [dbf.FieldLookup('name_vector', [t.token for t in hnrs], 'lookup_any')]
|
sdata.lookups = [dbf.FieldLookup('name_vector', [t.token for t in hnrs], 'lookup_any')]
|
||||||
|
expected_count = sum(t.count for t in hnrs)
|
||||||
|
|
||||||
partials = [t for trange in address
|
partials = [t for trange in address
|
||||||
for t in self.query.get_partials_list(trange)]
|
for t in self.query.get_partials_list(trange)]
|
||||||
|
|
||||||
if len(partials) != 1 or partials[0].count < 10000:
|
if expected_count < 8000:
|
||||||
|
sdata.lookups.append(dbf.FieldLookup('nameaddress_vector',
|
||||||
|
[t.token for t in partials], 'restrict'))
|
||||||
|
elif len(partials) != 1 or partials[0].count < 10000:
|
||||||
sdata.lookups.append(dbf.FieldLookup('nameaddress_vector',
|
sdata.lookups.append(dbf.FieldLookup('nameaddress_vector',
|
||||||
[t.token for t in partials], 'lookup_all'))
|
[t.token for t in partials], 'lookup_all'))
|
||||||
else:
|
else:
|
||||||
@@ -178,7 +182,7 @@ class SearchBuilder:
|
|||||||
'lookup_any'))
|
'lookup_any'))
|
||||||
|
|
||||||
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, expected_count)
|
||||||
|
|
||||||
|
|
||||||
def build_name_search(self, sdata: dbf.SearchData,
|
def build_name_search(self, sdata: dbf.SearchData,
|
||||||
|
|||||||
Reference in New Issue
Block a user