From: Sarah Hoffmann Date: Sun, 7 Jan 2024 16:29:12 +0000 (+0100) Subject: when a country is in the results, restrict further searches to places X-Git-Tag: v4.4.0~28^2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/b2afe3ce3ec7df3691a85462802b547b3d34ce4a?hp=-c when a country is in the results, restrict further searches to places A country search result usually comes with a very high importance. As a result only other very well known places will show up together with country results and that means only places with lower address ranks. Name searches for country names tend to yield a lot of POI results because the country name is part of the name (think "embassy of Sweden"). By excluding POIs from further searches, the search is sped up quite a bit. --- b2afe3ce3ec7df3691a85462802b547b3d34ce4a diff --git a/nominatim/api/search/db_searches.py b/nominatim/api/search/db_searches.py index 68447f6a..555819e7 100644 --- a/nominatim/api/search/db_searches.py +++ b/nominatim/api/search/db_searches.py @@ -484,7 +484,14 @@ class CountrySearch(AbstractSearch): result.bbox = Bbox.from_wkb(row.bbox) results.append(result) - return results or await self.lookup_in_country_table(conn, details) + if not results: + results = await self.lookup_in_country_table(conn, details) + + if results: + details.min_rank = min(5, details.max_rank) + details.max_rank = min(25, details.max_rank) + + return results async def lookup_in_country_table(self, conn: SearchConnection,