mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-12-25 05:52:32 +03:00
index postcodes after refreshing
This commit is contained in:
parent
4abaf71234
commit
bf864b2c54
@ -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')
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user