X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/566ac7af993f487e249185ddae59bc38c38f84de..41383c05cd65a36c518f9adce55cfec2a9be00d0:/lib-sql/functions/ranking.sql diff --git a/lib-sql/functions/ranking.sql b/lib-sql/functions/ranking.sql index 0b18954c..97a0cde3 100644 --- a/lib-sql/functions/ranking.sql +++ b/lib-sql/functions/ranking.sql @@ -287,21 +287,19 @@ LANGUAGE plpgsql IMMUTABLE; CREATE OR REPLACE FUNCTION weigh_search(search_vector INT[], - term_vectors TEXT[], - weight_vectors FLOAT[], + rankings TEXT, def_weight FLOAT) RETURNS FLOAT AS $$ DECLARE - pos INT := 1; - terms TEXT; + rank JSON; BEGIN - FOREACH terms IN ARRAY term_vectors + FOR rank IN + SELECT * FROM json_array_elements(rankings::JSON) LOOP - IF search_vector @> terms::INTEGER[] THEN - RETURN weight_vectors[pos]; + IF true = ALL(SELECT x::int = ANY(search_vector) FROM json_array_elements_text(rank->1) as x) THEN + RETURN (rank->>0)::float; END IF; - pos := pos + 1; END LOOP; RETURN def_weight; END;