From: Sarah Hoffmann Date: Fri, 23 Apr 2021 14:15:00 +0000 (+0200) Subject: add extra column for tokenizer X-Git-Tag: v4.0.0~93^2~27 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/a73711f3cd5e4256ca7808dcca8f6fdb59fa716f add extra column for tokenizer Add a jsonb column to the placex and location_property_osmline tables which can be used by the installed tokenizer as required. No other part of the software will use or otherwise rely on this column. --- diff --git a/lib-sql/tables.sql b/lib-sql/tables.sql index 2072accc..c254e2d4 100644 --- a/lib-sql/tables.sql +++ b/lib-sql/tables.sql @@ -93,6 +93,7 @@ CREATE TABLE location_property_osmline ( linegeo GEOMETRY, interpolationtype TEXT, address HSTORE, + token_info JSONB, -- custom column for tokenizer use only postcode TEXT, country_code VARCHAR(2) ){{db.tablespace.search_data}}; @@ -142,6 +143,7 @@ CREATE TABLE placex ( indexed_status SMALLINT, LIKE place INCLUDING CONSTRAINTS, wikipedia TEXT, -- calculated wikipedia article name (language:title) + token_info JSONB, -- custom column for tokenizer use only country_code varchar(2), housenumber TEXT, postcode TEXT, diff --git a/nominatim/tools/migration.py b/nominatim/tools/migration.py index 80539702..c8011eeb 100644 --- a/nominatim/tools/migration.py +++ b/nominatim/tools/migration.py @@ -175,6 +175,14 @@ def install_legacy_tokenizer(conn, config, **_): configuration for the backwards-compatible legacy tokenizer """ if properties.get_property(conn, 'tokenizer') is None: + with conn.cursor() as cur: + for table in ('placex', 'location_property_osmline'): + has_column = cur.scalar("""SELECT count(*) FROM information_schema.columns + WHERE table_name = %s + and column_name = 'token_info'""", + (table, )) + if has_column == 0: + cur.execute('ALTER TABLE {} ADD COLUMN token_info JSONB'.format(table)) tokenizer = tokenizer_factory.create_tokenizer(config, init_db=False, module_name='legacy')