mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-15 19:07:58 +00:00
move houseunumber handling to tokenizer
Normalization and token computation are now done in the tokenizer. The tokenizer keeps a cache to the hundred most used house numbers to keep the numbers of calls to the database low.
This commit is contained in:
@@ -292,7 +292,6 @@ CREATE OR REPLACE FUNCTION create_poi_search_terms(obj_place_id BIGINT,
|
||||
parent_place_id BIGINT,
|
||||
address HSTORE,
|
||||
country TEXT,
|
||||
housenumber TEXT,
|
||||
token_info JSONB,
|
||||
geometry GEOMETRY,
|
||||
OUT name_vector INTEGER[],
|
||||
@@ -302,6 +301,7 @@ DECLARE
|
||||
parent_name_vector INTEGER[];
|
||||
parent_address_vector INTEGER[];
|
||||
addr_place_ids INTEGER[];
|
||||
hnr_vector INTEGER[];
|
||||
|
||||
addr_item RECORD;
|
||||
parent_address_place_ids BIGINT[];
|
||||
@@ -358,9 +358,10 @@ BEGIN
|
||||
-- This is unusual for the search_name table but prevents that the place
|
||||
-- is returned when we only search for the street/place.
|
||||
|
||||
IF housenumber is not null and not nameaddress_vector <@ parent_address_vector THEN
|
||||
name_vector := array_merge(name_vector,
|
||||
ARRAY[getorcreate_housenumber_id(make_standard_name(housenumber))]);
|
||||
hnr_vector := token_get_housenumber_search_tokens(token_info);
|
||||
|
||||
IF hnr_vector is not null and not nameaddress_vector <@ parent_address_vector THEN
|
||||
name_vector := array_merge(name_vector, hnr_vector);
|
||||
END IF;
|
||||
|
||||
IF not address ? 'street' and address ? 'place' THEN
|
||||
@@ -370,7 +371,7 @@ BEGIN
|
||||
nameaddress_vector := array_merge(nameaddress_vector, addr_place_ids);
|
||||
-- If there is a housenumber, also add the place name as a name,
|
||||
-- so we can search it by the usual housenumber+place algorithms.
|
||||
IF housenumber is not null THEN
|
||||
IF hnr_vector is not null THEN
|
||||
name_vector := array_merge(name_vector,
|
||||
ARRAY[getorcreate_name_id(make_standard_name(address->'place'))]);
|
||||
END IF;
|
||||
@@ -812,21 +813,8 @@ BEGIN
|
||||
|
||||
{% if debug %}RAISE WARNING 'Copy over address tags';{% endif %}
|
||||
-- housenumber is a computed field, so start with an empty value
|
||||
NEW.housenumber := NULL;
|
||||
NEW.housenumber := token_normalized_housenumber(NEW.token_info);
|
||||
IF NEW.address is not NULL THEN
|
||||
IF NEW.address ? 'conscriptionnumber' THEN
|
||||
IF NEW.address ? 'streetnumber' THEN
|
||||
NEW.housenumber := (NEW.address->'conscriptionnumber') || '/' || (NEW.address->'streetnumber');
|
||||
ELSE
|
||||
NEW.housenumber := NEW.address->'conscriptionnumber';
|
||||
END IF;
|
||||
ELSEIF NEW.address ? 'streetnumber' THEN
|
||||
NEW.housenumber := NEW.address->'streetnumber';
|
||||
ELSEIF NEW.address ? 'housenumber' THEN
|
||||
NEW.housenumber := NEW.address->'housenumber';
|
||||
END IF;
|
||||
NEW.housenumber := create_housenumber_id(NEW.housenumber);
|
||||
|
||||
addr_street := NEW.address->'street';
|
||||
addr_place := NEW.address->'place';
|
||||
|
||||
@@ -940,8 +928,7 @@ BEGIN
|
||||
SELECT * INTO name_vector, nameaddress_vector
|
||||
FROM create_poi_search_terms(NEW.place_id,
|
||||
NEW.partition, NEW.parent_place_id,
|
||||
NEW.address,
|
||||
NEW.country_code, NEW.housenumber,
|
||||
NEW.address, NEW.country_code,
|
||||
NEW.token_info, NEW.centroid);
|
||||
|
||||
IF array_length(name_vector, 1) is not NULL THEN
|
||||
|
||||
Reference in New Issue
Block a user