From: Sarah Hoffmann Date: Sat, 25 Nov 2023 17:39:28 +0000 (+0100) Subject: use restrict for housenumber lookups with few numbers X-Git-Tag: v4.4.0~74^2~1 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/0c72a434e033c54729294129dd4e37527db19faf?ds=sidebyside use restrict for housenumber lookups with few numbers --- diff --git a/nominatim/api/search/db_search_builder.py b/nominatim/api/search/db_search_builder.py index 6d94feab..39c25f6b 100644 --- a/nominatim/api/search/db_search_builder.py +++ b/nominatim/api/search/db_search_builder.py @@ -163,11 +163,15 @@ class SearchBuilder: housenumber is the main name token. """ 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 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', [t.token for t in partials], 'lookup_all')) else: @@ -178,7 +182,7 @@ class SearchBuilder: 'lookup_any')) 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,