From: Sarah Hoffmann Date: Thu, 20 Mar 2025 20:33:27 +0000 (+0100) Subject: do not write any word counts on initial word insert X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/58ef032a2b4d0fafe4c768a1ea88ebfdf0dcdd73?hp=--cc do not write any word counts on initial word insert --- 58ef032a2b4d0fafe4c768a1ea88ebfdf0dcdd73 diff --git a/lib-sql/tokenizer/icu_tokenizer.sql b/lib-sql/tokenizer/icu_tokenizer.sql index f0c30f1b..29039987 100644 --- a/lib-sql/tokenizer/icu_tokenizer.sql +++ b/lib-sql/tokenizer/icu_tokenizer.sql @@ -128,16 +128,14 @@ DECLARE partial_terms TEXT[] = '{}'::TEXT[]; term TEXT; term_id INTEGER; - term_count INTEGER; BEGIN SELECT min(word_id) INTO full_token FROM word WHERE word = norm_term and type = 'W'; IF full_token IS NULL THEN full_token := nextval('seq_word'); - INSERT INTO word (word_id, word_token, type, word, info) - SELECT full_token, lookup_term, 'W', norm_term, - json_build_object('count', 0) + INSERT INTO word (word_id, word_token, type, word) + SELECT full_token, lookup_term, 'W', norm_term FROM unnest(lookup_terms) as lookup_term; END IF; @@ -150,14 +148,13 @@ BEGIN partial_tokens := '{}'::INT[]; FOR term IN SELECT unnest(partial_terms) LOOP - SELECT min(word_id), max(info->>'count') INTO term_id, term_count + SELECT min(word_id) INTO term_id FROM word WHERE word_token = term and type = 'w'; IF term_id IS NULL THEN term_id := nextval('seq_word'); - term_count := 0; - INSERT INTO word (word_id, word_token, type, info) - VALUES (term_id, term, 'w', json_build_object('count', term_count)); + INSERT INTO word (word_id, word_token, type) + VALUES (term_id, term, 'w'); END IF; partial_tokens := array_merge(partial_tokens, ARRAY[term_id]);