Skip to content

Commit

Permalink
when a country is in the results, restrict further searches to places
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lonvia committed Jan 7, 2024
1 parent 7337898 commit b2afe3c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nominatim/api/search/db_searches.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,14 @@ async def lookup(self, conn: SearchConnection,
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,
Expand Down

0 comments on commit b2afe3c

Please sign in to comment.