do not lookup by address vector when only few tokens are available

Names of countries and states are exceedingly rare in the word count
but are very frequent in the address. A short name has the danger
of producing too many results.
This commit is contained in:
Sarah Hoffmann
2023-07-31 14:27:39 +02:00
parent 8adeaa2c7e
commit afdbdb02a1
2 changed files with 11 additions and 9 deletions

View File

@@ -212,7 +212,7 @@ class SearchBuilder:
exp_count = min(exp_count, min(t.count for t in addr_partials)) \
if addr_partials else exp_count
if exp_count < 1000 and partials_indexed:
if exp_count < 1000 and len(addr_tokens) > 3 and partials_indexed:
# Lookup by address partials and restrict results through name terms.
# Give this a small penalty because lookups in the address index are
# more expensive