X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/185d369404bbb6ebffbd4bd24100797a407ed8ac..56124546a659c43bfab0df0baa0557713af06589:/lib-sql/functions/address_lookup.sql diff --git a/lib-sql/functions/address_lookup.sql b/lib-sql/functions/address_lookup.sql index 45e49750..b6adfdc3 100644 --- a/lib-sql/functions/address_lookup.sql +++ b/lib-sql/functions/address_lookup.sql @@ -223,11 +223,13 @@ BEGIN OR placex.country_code = place.country_code) ORDER BY rank_address desc, (place_addressline.place_id = in_place_id) desc, - (fromarea and place.centroid is not null and not isaddress - and (place.address is null or avals(name) && avals(place.address)) - and ST_Contains(geometry, place.centroid)) desc, - isaddress desc, fromarea desc, - distance asc, rank_search desc + (CASE WHEN coalesce((avals(name) && avals(place.address)), False) THEN 2 + WHEN isaddress THEN 0 + WHEN fromarea + and place.centroid is not null + and ST_Contains(geometry, place.centroid) THEN 1 + ELSE -1 END) desc, + fromarea desc, distance asc, rank_search desc LOOP -- RAISE WARNING '%',location; location_isaddress := location.rank_address != current_rank_address;