X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/a413aae8a3962be4d623844d867604df68a9a211..283db76e458c3159888f01e5837ff8db0bfd9780:/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