X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/bd2c64876f7ddc99da14ea78a652f797e17134f4..9cb9b670d182932851613ac8a08d3a1e7c8ce51f:/nominatim/api/search/db_search_fields.py diff --git a/nominatim/api/search/db_search_fields.py b/nominatim/api/search/db_search_fields.py index 325e08df..13f1c56e 100644 --- a/nominatim/api/search/db_search_fields.py +++ b/nominatim/api/search/db_search_fields.py @@ -129,10 +129,11 @@ class FieldRanking: """ assert self.rankings - col = table.c[self.column] - - return sa.case(*((col.contains(r.tokens),r.penalty) for r in self.rankings), - else_=self.default) + return sa.func.weigh_search(table.c[self.column], + [f"{{{','.join((str(s) for s in r.tokens))}}}" + for r in self.rankings], + [r.penalty for r in self.rankings], + self.default) @dataclasses.dataclass