forked from hans/Nominatim
do not write any word counts on initial word insert
This commit is contained in:
@@ -128,16 +128,14 @@ DECLARE
|
|||||||
partial_terms TEXT[] = '{}'::TEXT[];
|
partial_terms TEXT[] = '{}'::TEXT[];
|
||||||
term TEXT;
|
term TEXT;
|
||||||
term_id INTEGER;
|
term_id INTEGER;
|
||||||
term_count INTEGER;
|
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT min(word_id) INTO full_token
|
SELECT min(word_id) INTO full_token
|
||||||
FROM word WHERE word = norm_term and type = 'W';
|
FROM word WHERE word = norm_term and type = 'W';
|
||||||
|
|
||||||
IF full_token IS NULL THEN
|
IF full_token IS NULL THEN
|
||||||
full_token := nextval('seq_word');
|
full_token := nextval('seq_word');
|
||||||
INSERT INTO word (word_id, word_token, type, word, info)
|
INSERT INTO word (word_id, word_token, type, word)
|
||||||
SELECT full_token, lookup_term, 'W', norm_term,
|
SELECT full_token, lookup_term, 'W', norm_term
|
||||||
json_build_object('count', 0)
|
|
||||||
FROM unnest(lookup_terms) as lookup_term;
|
FROM unnest(lookup_terms) as lookup_term;
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
@@ -150,14 +148,13 @@ BEGIN
|
|||||||
|
|
||||||
partial_tokens := '{}'::INT[];
|
partial_tokens := '{}'::INT[];
|
||||||
FOR term IN SELECT unnest(partial_terms) LOOP
|
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';
|
FROM word WHERE word_token = term and type = 'w';
|
||||||
|
|
||||||
IF term_id IS NULL THEN
|
IF term_id IS NULL THEN
|
||||||
term_id := nextval('seq_word');
|
term_id := nextval('seq_word');
|
||||||
term_count := 0;
|
INSERT INTO word (word_id, word_token, type)
|
||||||
INSERT INTO word (word_id, word_token, type, info)
|
VALUES (term_id, term, 'w');
|
||||||
VALUES (term_id, term, 'w', json_build_object('count', term_count));
|
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
partial_tokens := array_merge(partial_tokens, ARRAY[term_id]);
|
partial_tokens := array_merge(partial_tokens, ARRAY[term_id]);
|
||||||
|
|||||||
Reference in New Issue
Block a user