make sure that addr:* tags can always be searched for

Always add contents of addr:* tags into address part of the search
table, even when there is no corresponding other name. This keeps
search tolerant to the kind of tagging where parts show up in the
address that have no corresponding object in the database or where
it is only an unaddressable object.
This commit is contained in:
Sarah Hoffmann
2020-08-19 11:37:21 +02:00
parent 984979d9bf
commit d6ff7475f1
2 changed files with 9 additions and 3 deletions

View File

@@ -207,16 +207,22 @@ CREATE OR REPLACE FUNCTION addr_ids_from_name(lookup_word TEXT)
AS $$
DECLARE
lookup_token TEXT;
id INTEGER;
return_word_id INTEGER[];
BEGIN
lookup_token := make_standard_name(lookup_word);
SELECT array_agg(word_id) FROM word
WHERE word_token = lookup_token and class is null and type is null
INTO return_word_id;
IF return_word_id IS NULL THEN
id := nextval('seq_word');
INSERT INTO word VALUES (id, lookup_token, null, null, null, null, 0);
return_word_id = ARRAY[id];
END IF;
RETURN return_word_id;
END;
$$
LANGUAGE plpgsql STABLE;
LANGUAGE plpgsql;
-- Normalize a string and look up its name ids (full words).