From: Sarah Hoffmann Date: Wed, 29 Nov 2023 13:02:56 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: deploy~31 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/0806e5dff439ef5bdb91a378abb0fd61983d6a24?hp=4dadbaea73a77d0ad33e5f98d8f8fb828286ecb3 Merge remote-tracking branch 'upstream/master' --- diff --git a/nominatim/api/search/db_search_builder.py b/nominatim/api/search/db_search_builder.py index f89d8b62..39c25f6b 100644 --- a/nominatim/api/search/db_search_builder.py +++ b/nominatim/api/search/db_search_builder.py @@ -113,7 +113,10 @@ class SearchBuilder: penalty = min(near_items.penalties) near_items.penalties = [p - penalty for p in near_items.penalties] for search in builder: - yield dbs.NearSearch(penalty + assignment.penalty, near_items, search) + search_penalty = search.penalty + search.penalty = 0.0 + yield dbs.NearSearch(penalty + assignment.penalty + search_penalty, + near_items, search) else: for search in builder: search.penalty += assignment.penalty @@ -160,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: @@ -175,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, diff --git a/nominatim/api/search/geocoder.py b/nominatim/api/search/geocoder.py index 91c45b65..bb3c6a1c 100644 --- a/nominatim/api/search/geocoder.py +++ b/nominatim/api/search/geocoder.py @@ -79,7 +79,7 @@ class ForwardGeocoder: end_time = dt.datetime.now() + self.timeout - min_ranking = 1000.0 + min_ranking = searches[0].penalty + 2.0 prev_penalty = 0.0 for i, search in enumerate(searches): if search.penalty > prev_penalty and (search.penalty > min_ranking or i > 20): @@ -94,7 +94,7 @@ class ForwardGeocoder: prevresult.accuracy = min(prevresult.accuracy, result.accuracy) else: results[rhash] = result - min_ranking = min(min_ranking, result.ranking + 0.5, search.penalty + 0.3) + min_ranking = min(min_ranking, result.accuracy * 1.2) log().result_dump('Results', ((r.accuracy, r) for r in lookup_results)) prev_penalty = search.penalty if dt.datetime.now() >= end_time: