X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/4e7ec92d6f86b3a4dfb1df0723d95b16865c33f0..5ec48c66cba0e9407135b2949f2a5e446d3620ed:/sql/functions/placex_triggers.sql

diff --git a/sql/functions/placex_triggers.sql b/sql/functions/placex_triggers.sql
index 1f664a4a..9a5c6776 100644
--- a/sql/functions/placex_triggers.sql
+++ b/sql/functions/placex_triggers.sql
@@ -307,7 +307,13 @@ BEGIN
   END LOOP;
 
   FOR location IN
-    SELECT * FROM getNearFeatures(partition, geometry, maxrank, isin_tokens)
+    SELECT * FROM getNearFeatures(partition, geometry, maxrank)
+    ORDER BY rank_address, isin_tokens && keywords desc, isguess asc,
+             distance *
+               CASE WHEN rank_address = 16 AND rank_search = 15 THEN 0.2
+                    WHEN rank_address = 16 AND rank_search = 16 THEN 0.25
+                    WHEN rank_address = 16 AND rank_search = 18 THEN 0.5
+                    ELSE 1 END ASC
   LOOP
     IF location.rank_address != current_rank_address THEN
       current_rank_address := location.rank_address;
