From c32fa2172d7d688e3b816957cd1e92f6ca129244 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 13 May 2012 09:15:56 +0200 Subject: [PATCH] pre-create word list to avoid duplicates due to parallel indexing --- sql/functions.sql | 26 +++++++++++++++++++++++++- utils/setup.php | 8 ++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/sql/functions.sql b/sql/functions.sql index ec25c7fa..b4657bf8 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -389,7 +389,7 @@ BEGIN result := '{}'::INTEGER[]; s := make_standard_name(src); - w := getorcreate_name_id(s); + w := getorcreate_name_id(s, src); IF NOT (ARRAY[w] <@ result) THEN result := result || w; @@ -407,6 +407,30 @@ BEGIN END LOOP; END IF; + words := regexp_split_to_array(src, E'[,;()]'); + IF array_upper(words, 1) != 1 THEN + FOR j IN 1..array_upper(words, 1) LOOP + s := make_standard_name(words[j]); + IF s != '' THEN + w := getorcreate_word_id(s); + IF NOT (ARRAY[w] <@ result) THEN + result := result || w; + END IF; + END IF; + END LOOP; + END IF; + + s := regexp_replace(src, '市$', ''); + IF s != src THEN + s := make_standard_name(s); + IF s != '' THEN + w := getorcreate_name_id(s, src); + IF NOT (ARRAY[w] <@ result) THEN + result := result || w; + END IF; + END IF; + END IF; + RETURN result; END; $$ diff --git a/utils/setup.php b/utils/setup.php index 29dd86ac..b40bad3a 100755 --- a/utils/setup.php +++ b/utils/setup.php @@ -264,6 +264,14 @@ if (!pg_query($oDB->connection, 'CREATE SEQUENCE seq_place start 100000')) fail(pg_last_error($oDB->connection)); echo '.'; + // pre-create the word list + if (!pg_query($oDB->connection, 'select count(make_keywords(v)) from (select distinct svals(name) as v from place) as w where v is not null;')) fail(pg_last_error($oDB->connection)); + echo '.'; + if (!pg_query($oDB->connection, 'select count(make_keywords(v)) from (select distinct postcode as v from place) as w where v is not null;')) fail(pg_last_error($oDB->connection)); + echo '.'; + if (!pg_query($oDB->connection, 'select count(getorcreate_housenumber_id(v)) from (select distinct housenumber as v from place where housenumber is not null) as w;')) fail(pg_last_error($oDB->connection)); + echo '.'; + $aDBInstances = array(); for($i = 0; $i < $iInstances; $i++) { -- 2.39.5