From bf864b2c54390ca47121b49476c34bd7813bc7a9 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Thu, 13 May 2021 00:14:52 +0200 Subject: [PATCH] index postcodes after refreshing --- nominatim/clicmd/refresh.py | 4 ++++ nominatim/tools/postcodes.py | 5 ++++- test/python/test_cli.py | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nominatim/clicmd/refresh.py b/nominatim/clicmd/refresh.py index 4d457055..567c416b 100644 --- a/nominatim/clicmd/refresh.py +++ b/nominatim/clicmd/refresh.py @@ -47,6 +47,7 @@ class UpdateRefresh: def run(args): from ..tools import refresh, postcodes from ..tokenizer import factory as tokenizer_factory + from ..indexer.indexer import Indexer tokenizer = tokenizer_factory.get_tokenizer_for_db(args.config) @@ -54,6 +55,9 @@ class UpdateRefresh: LOG.warning("Update postcodes centroid") postcodes.update_postcodes(args.config.get_libpq_dsn(), args.project_dir, tokenizer) + indexer = Indexer(args.config.get_libpq_dsn(), tokenizer, + args.threads or 1) + indexer.index_postcodes() if args.word_counts: LOG.warning('Recompute frequency of full-word search terms') diff --git a/nominatim/tools/postcodes.py b/nominatim/tools/postcodes.py index dd2fd217..e172a77c 100644 --- a/nominatim/tools/postcodes.py +++ b/nominatim/tools/postcodes.py @@ -35,6 +35,9 @@ class _CountryPostcodesCollector: self._update_from_external(analyzer, project_dir) to_add, to_delete, to_update = self._compute_changes(conn) + LOG.info("Processing country '%s' (%s added, %s deleted, %s updated).", + self.country, len(to_add), len(to_delete), len(to_update)) + with conn.cursor() as cur: if to_add: execute_values(cur, @@ -165,4 +168,4 @@ def update_postcodes(dsn, project_dir, tokenizer): conn.commit() - analyzer.add_postcodes_from_db() + analyzer.update_postcodes_from_db() diff --git a/test/python/test_cli.py b/test/python/test_cli.py index 4b1a4c12..e8d2e052 100644 --- a/test/python/test_cli.py +++ b/test/python/test_cli.py @@ -278,6 +278,7 @@ def test_refresh_command(mock_func_factory, temp_db, command, func, tokenizer_mo def test_refresh_postcodes(mock_func_factory, temp_db, tokenizer_mock): func_mock = mock_func_factory(nominatim.tools.postcodes, 'update_postcodes') + idx_mock = mock_func_factory(nominatim.indexer.indexer.Indexer, 'index_postcodes') assert 0 == call_nominatim('refresh', '--postcodes') assert func_mock.called == 1 -- 2.39.5