X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/4563750453ede7af40a7ffd75c90327f4e56bff8..1ccf4fb92fe71e9e2bc0baabfb2e92cd79166dae:/sql/functions.sql?ds=inline

diff --git a/sql/functions.sql b/sql/functions.sql
index 818f6ac1..4c040fdc 100644
--- a/sql/functions.sql
+++ b/sql/functions.sql
@@ -347,7 +347,7 @@ BEGIN
 
     w := getorcreate_word_id(s);
 
-    IF NOT (ARRAY[w] <@ result) THEN
+    IF w IS NOT NULL AND NOT (ARRAY[w] <@ result) THEN
       result := result || w;
     END IF;
 
@@ -415,7 +415,7 @@ BEGIN
 
   w := getorcreate_word_id(s);
 
-  IF NOT (ARRAY[w] <@ result) THEN
+  IF w IS NOT NULL AND NOT (ARRAY[w] <@ result) THEN
     result := result || w;
   END IF;
 
@@ -1123,7 +1123,11 @@ BEGIN
         return NULL;
       END IF;
       NEW.rank_search := NEW.admin_level * 2;
-      NEW.rank_address := NEW.rank_search;
+      IF NEW.type = 'administrative' THEN
+        NEW.rank_address := NEW.rank_search;
+      ELSE
+        NEW.rank_address := 0;
+      END IF;
     ELSEIF NEW.class = 'landuse' AND ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') THEN
       NEW.rank_search := 22;
       NEW.rank_address := NEW.rank_search;
