mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-12-26 06:22:13 +03:00
avoid LookupAny with address and too many name tokens
The index for nameaddress_vector has grown so large that PostgreSQL will resort to a sequential scan if there are too many items in the LookupAny list.
This commit is contained in:
parent
76eadc562c
commit
33c0f249b1
@ -176,11 +176,12 @@ class SearchBuilder:
|
|||||||
sdata.lookups.append(dbf.FieldLookup('nameaddress_vector',
|
sdata.lookups.append(dbf.FieldLookup('nameaddress_vector',
|
||||||
list(partials), lookups.LookupAll))
|
list(partials), lookups.LookupAll))
|
||||||
else:
|
else:
|
||||||
|
addr_fulls = [t.token for t
|
||||||
|
in self.query.get_tokens(address[0], TokenType.WORD)]
|
||||||
|
if len(addr_fulls) > 5:
|
||||||
|
return
|
||||||
sdata.lookups.append(
|
sdata.lookups.append(
|
||||||
dbf.FieldLookup('nameaddress_vector',
|
dbf.FieldLookup('nameaddress_vector', addr_fulls, lookups.LookupAny))
|
||||||
[t.token for t
|
|
||||||
in self.query.get_tokens(address[0], TokenType.WORD)],
|
|
||||||
lookups.LookupAny))
|
|
||||||
|
|
||||||
sdata.housenumbers = dbf.WeightedStrings([], [])
|
sdata.housenumbers = dbf.WeightedStrings([], [])
|
||||||
yield dbs.PlaceSearch(0.05, sdata, expected_count)
|
yield dbs.PlaceSearch(0.05, sdata, expected_count)
|
||||||
|
Loading…
Reference in New Issue
Block a user