]> git.openstreetmap.org Git - nominatim.git/blobdiff - sql/functions/postcode_triggers.sql
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / sql / functions / postcode_triggers.sql
index 96788d65ab2d6a9157d2ed377969bb9589402a40..515b76664ad4cf6de31f52c7fed1f121485e849f 100644 (file)
@@ -27,8 +27,8 @@ BEGIN
     NEW.parent_place_id = 0;
     FOR location IN
       SELECT place_id
-        FROM getNearFeatures(partition, NEW.geometry, NEW.rank_search, '{}'::int[])
-        WHERE NOT isguess ORDER BY rank_address DESC LIMIT 1
+        FROM getNearFeatures(partition, NEW.geometry, NEW.rank_search)
+        WHERE NOT isguess ORDER BY rank_address DESC, distance asc LIMIT 1
     LOOP
         NEW.parent_place_id = location.place_id;
     END LOOP;