X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/d8ed565bce27c638074fbc6f1961dfc0d160e312..70dc4957dc41df7d808ae4acb6c881e80b6348f9:/nominatim/api/search/db_search_builder.py diff --git a/nominatim/api/search/db_search_builder.py b/nominatim/api/search/db_search_builder.py index 7826925a..35d10e78 100644 --- a/nominatim/api/search/db_search_builder.py +++ b/nominatim/api/search/db_search_builder.py @@ -321,8 +321,15 @@ class SearchBuilder: self.query.get_tokens(assignment.postcode, TokenType.POSTCODE)) if assignment.qualifier: - sdata.set_qualifiers(self.query.get_tokens(assignment.qualifier, - TokenType.QUALIFIER)) + tokens = self.query.get_tokens(assignment.qualifier, TokenType.QUALIFIER) + if self.details.categories: + tokens = [t for t in tokens if t.get_category() in self.details.categories] + if not tokens: + return None + sdata.set_qualifiers(tokens) + elif self.details.categories: + sdata.qualifiers = dbf.WeightedCategories(self.details.categories, + [0.0] * len(self.details.categories)) if assignment.address: sdata.set_ranking([self.get_addr_ranking(r) for r in assignment.address]) @@ -347,10 +354,6 @@ class SearchBuilder: tokens[cat] = t.penalty return dbf.WeightedCategories(list(tokens.keys()), list(tokens.values())) - if self.details.categories: - return dbf.WeightedCategories(self.details.categories, - [0.0] * len(self.details.categories)) - return None