X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/9a84adef5981d1a8357fd1775358742aae83867b..253dc7d7cd6cae88b8f2d777c1b2996390b37e54:/lib-sql/functions/placex_triggers.sql?ds=inline diff --git a/lib-sql/functions/placex_triggers.sql b/lib-sql/functions/placex_triggers.sql index 386140f4..01f99715 100644 --- a/lib-sql/functions/placex_triggers.sql +++ b/lib-sql/functions/placex_triggers.sql @@ -481,24 +481,20 @@ BEGIN name_vector := array_merge(name_vector, hnr_vector); END IF; - IF is_place_addr THEN - addr_place_ids := token_addr_place_search_tokens(token_info); - IF not addr_place_ids <@ parent_name_vector THEN - -- make sure addr:place terms are always searchable - nameaddress_vector := array_merge(nameaddress_vector, addr_place_ids); - -- If there is a housenumber, also add the place name as a name, - -- so we can search it by the usual housenumber+place algorithms. - IF hnr_vector is not null THEN - name_vector := array_merge(name_vector, addr_place_ids); - END IF; - END IF; - END IF; - -- Cheating here by not recomputing all terms but simply using the ones -- from the parent object. nameaddress_vector := array_merge(nameaddress_vector, parent_name_vector); nameaddress_vector := array_merge(nameaddress_vector, parent_address_vector); + -- make sure addr:place terms are always searchable + IF is_place_addr THEN + addr_place_ids := token_addr_place_search_tokens(token_info); + IF hnr_vector is not null AND not addr_place_ids <@ parent_name_vector + THEN + name_vector := array_merge(name_vector, hnr_vector); + END IF; + nameaddress_vector := array_merge(nameaddress_vector, addr_place_ids); + END IF; END; $$ LANGUAGE plpgsql; @@ -731,10 +727,12 @@ BEGIN {% if not disable_diff_updates %} -- The following is not needed until doing diff updates, and slows the main index process down - IF NEW.rank_address > 0 THEN + IF NEW.rank_address between 2 and 27 THEN IF (ST_GeometryType(NEW.geometry) in ('ST_Polygon','ST_MultiPolygon') AND ST_IsValid(NEW.geometry)) THEN -- Performance: We just can't handle re-indexing for country level changes - IF st_area(NEW.geometry) < 1 THEN + IF (NEW.rank_address < 26 and st_area(NEW.geometry) < 1) + OR (NEW.rank_address >= 26 and st_area(NEW.geometry) < 0.01) + THEN -- mark items within the geometry for re-indexing -- RAISE WARNING 'placex poly insert: % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type; @@ -749,9 +747,11 @@ BEGIN or name is not null or (NEW.rank_address >= 16 and address ? 'place')); END IF; - ELSE + ELSEIF ST_GeometryType(NEW.geometry) not in ('ST_LineString', 'ST_MultiLineString') + OR ST_Length(NEW.geometry) < 0.5 + THEN -- mark nearby items for re-indexing, where 'nearby' depends on the features rank_search and is a complete guess :( - diameter := update_place_diameter(NEW.rank_search); + diameter := update_place_diameter(NEW.rank_address); IF diameter > 0 THEN -- RAISE WARNING 'placex point insert: % % % % %',NEW.osm_type,NEW.osm_id,NEW.class,NEW.type,diameter; IF NEW.rank_search >= 26 THEN @@ -1265,6 +1265,8 @@ BEGIN END IF; ELSEIF NEW.rank_address > 25 THEN max_rank := 25; + ELSEIF NEW.class in ('place','boundary') and NEW.type in ('postcode','postal_code') THEN + max_rank := NEW.rank_search; ELSE max_rank := NEW.rank_address; END IF; @@ -1401,6 +1403,8 @@ BEGIN {% if debug %}RAISE WARNING 'placex_delete:12 % %',OLD.osm_type,OLD.osm_id;{% endif %} + UPDATE location_postcode SET indexed_status = 2 WHERE parent_place_id = OLD.place_id; + RETURN OLD; END;