X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c2629bc08d081262a7fd1cbd9d52acb5f44bd8ec..a4ba79fe780e521cb3f1958dd1a22238b85aa9f5:/sql/update-postcodes.sql?ds=sidebyside

diff --git a/sql/update-postcodes.sql b/sql/update-postcodes.sql
index a90abe25..d59df15b 100644
--- a/sql/update-postcodes.sql
+++ b/sql/update-postcodes.sql
@@ -6,7 +6,7 @@ SELECT country_code,
        ST_Centroid(ST_Collect(ST_Centroid(geometry))) as centroid
   FROM placex
  WHERE address ? 'postcode'
-       AND address->'postcode' NOT SIMILAR TO '%(,|;)%'
+       AND address->'postcode' NOT SIMILAR TO '%(,|;|:)%'
        AND geometry IS NOT null
 GROUP BY country_code, pc;
 
@@ -48,5 +48,11 @@ INSERT INTO location_postcode
   SELECT nextval('seq_place'), 1, country_code, pc, centroid
     FROM tmp_new_postcode_locations new;
 
+-- Remove unused word entries
+DELETE FROM word
+    WHERE class = 'place' AND type = 'postcode'
+          AND NOT EXISTS (SELECT 0 FROM location_postcode p
+                          WHERE p.postcode = word.word);
+
 -- Finally index the newly inserted postcodes
 UPDATE location_postcode SET indexed_status = 0 WHERE indexed_status > 0;
