X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/503baf46d58e414eca0ec19cdafd2229b372485f..228ef1972a915d1f960e021f4496147645e22370:/sql/functions/address_lookup.sql diff --git a/sql/functions/address_lookup.sql b/sql/functions/address_lookup.sql index c8c63092..daed3a8b 100644 --- a/sql/functions/address_lookup.sql +++ b/sql/functions/address_lookup.sql @@ -60,14 +60,16 @@ BEGIN prevresult := ''; FOR location IN - SELECT * FROM get_addressdata(for_place_id, housenumber) + SELECT name, + CASE WHEN place_id = for_place_id THEN 99 ELSE rank_address END as rank_address + FROM get_addressdata(for_place_id, housenumber) WHERE isaddress order by rank_address desc LOOP currresult := trim(get_name_by_language(location.name, languagepref)); IF currresult != prevresult AND currresult IS NOT NULL AND result[(100 - location.rank_address)] IS NULL THEN - result[(100 - location.rank_address)] := trim(get_name_by_language(location.name, languagepref)); + result[(100 - location.rank_address)] := currresult; prevresult := currresult; END IF; END LOOP;