]> git.openstreetmap.org Git - nominatim.git/blobdiff - sql/functions.sql
Merge branch 'master' of github.com:twain47/Nominatim
[nominatim.git] / sql / functions.sql
index ca7f8c857798f7f2f157467a1344a50b2f2d0884..8eaf3925546945a26f0ff8a08f774c26c7dc4724 100644 (file)
@@ -389,7 +389,7 @@ BEGIN
   result := '{}'::INTEGER[];
 
   s := make_standard_name(src);
-  w := getorcreate_name_id(s);
+  w := getorcreate_name_id(s, src);
 
   IF NOT (ARRAY[w] <@ result) THEN
     result := result || w;
@@ -407,6 +407,30 @@ BEGIN
     END LOOP;
   END IF;
 
+  words := regexp_split_to_array(src, E'[,;()]');
+  IF array_upper(words, 1) != 1 THEN
+    FOR j IN 1..array_upper(words, 1) LOOP
+      s := make_standard_name(words[j]);
+      IF s != '' THEN
+        w := getorcreate_word_id(s);
+        IF NOT (ARRAY[w] <@ result) THEN
+          result := result || w;
+        END IF;
+      END IF;
+    END LOOP;
+  END IF;
+
+  s := regexp_replace(src, '市$', '');
+  IF s != src THEN
+    s := make_standard_name(s);
+    IF s != '' THEN
+      w := getorcreate_name_id(s, src);
+      IF NOT (ARRAY[w] <@ result) THEN
+        result := result || w;
+      END IF;
+    END IF;
+  END IF;
+
   RETURN result;
 END;
 $$