]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib-sql/functions/ranking.sql
Merge pull request #3592 from lonvia/remove-cmake
[nominatim.git] / lib-sql / functions / ranking.sql
index 0b18954cedb985ab71430b20762958f7571dd6da..97a0cde38e2b6aa6ef8aebf63af2611894502fbd 100644 (file)
@@ -287,21 +287,19 @@ LANGUAGE plpgsql IMMUTABLE;
 
 
 CREATE OR REPLACE FUNCTION weigh_search(search_vector INT[],
 
 
 CREATE OR REPLACE FUNCTION weigh_search(search_vector INT[],
-                                        term_vectors TEXT[],
-                                        weight_vectors FLOAT[],
+                                        rankings TEXT,
                                         def_weight FLOAT)
   RETURNS FLOAT
   AS $$
 DECLARE
                                         def_weight FLOAT)
   RETURNS FLOAT
   AS $$
 DECLARE
-  pos INT := 1;
-  terms TEXT;
+  rank JSON;
 BEGIN
 BEGIN
-  FOREACH terms IN ARRAY term_vectors
+  FOR rank IN
+    SELECT * FROM json_array_elements(rankings::JSON)
   LOOP
   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;
     END IF;
-    pos := pos + 1;
   END LOOP;
   RETURN def_weight;
 END;
   END LOOP;
   RETURN def_weight;
 END;