From: Sarah Hoffmann Date: Tue, 20 Jun 2023 10:22:08 +0000 (+0200) Subject: avoid fallback country lookup when places are excluded X-Git-Tag: v4.3.0~66^2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/4ad88188095a3ce19c8fd6f5449d78b5e4aa82d4?hp=--cc avoid fallback country lookup when places are excluded --- 4ad88188095a3ce19c8fd6f5449d78b5e4aa82d4 diff --git a/nominatim/api/search/db_searches.py b/nominatim/api/search/db_searches.py index ba4a3995..76ff368f 100644 --- a/nominatim/api/search/db_searches.py +++ b/nominatim/api/search/db_searches.py @@ -403,6 +403,12 @@ class CountrySearch(AbstractSearch): details: SearchDetails) -> nres.SearchResults: """ Look up the country in the fallback country tables. """ + # Avoid the fallback search when this is a more search. Country results + # usually are in the first batch of results and it is not possible + # to exclude these fallbacks. + if details.excluded: + return nres.SearchResults() + t = conn.t.country_name tgrid = conn.t.country_grid diff --git a/nominatim/api/types.py b/nominatim/api/types.py index aa3256cd..87568a09 100644 --- a/nominatim/api/types.py +++ b/nominatim/api/types.py @@ -306,7 +306,7 @@ def format_excluded(ids: Any) -> List[int]: (isinstance(i, str) and (not i or i.isdigit())) for i in plist): raise UsageError("Parameter 'excluded' only takes place IDs.") - return [int(id) for id in plist if id] + return [int(id) for id in plist if id] or [0] def format_categories(categories: List[Tuple[str, str]]) -> List[Tuple[str, str]]: