X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/21df87dedc032979e86e095a0deef7f02eaceb33..306b91004f6db6cc4500a59407c5da18f664443f:/nominatim/api/search/geocoder.py?ds=inline diff --git a/nominatim/api/search/geocoder.py b/nominatim/api/search/geocoder.py index 7ff3ed08..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: @@ -134,7 +134,10 @@ class ForwardGeocoder: return for result in results: - if not result.display_name: + # Negative importance indicates ordering by distance, which is + # more important than word matching. + if not result.display_name\ + or (result.importance is not None and result.importance < 0): continue distance = 0.0 norm = self.query_analyzer.normalize_text(result.display_name)