Compare commits

...

6 Commits

Author SHA1 Message Date
Sarah Hoffmann
fed64cda5a Merge pull request #3957 from jayaddison/issue-2714/linked-places-default-language
Indexing: add default-language placename from linked places
2026-02-11 15:08:18 +01:00
Sarah Hoffmann
b995803c66 Merge pull request #3979 from jayaddison/issue-2714-prep/extract-rank-zero-specialcasing
Indexer: relocate zero-ranked-address indexing
2026-02-11 15:05:28 +01:00
James Addison
310d6e3c92 Indexer: relocate zero-ranked-address indexing 2026-02-10 11:51:18 +00:00
James Addison
e62811cf97 Indexing: invert boolean logic to factor-out empty ELSE clause
Relates-to commit fa2a789e27.
2026-02-09 18:33:02 +00:00
James Addison
fa2a789e27 Indexing: manage the case where no default-language exists
Relates-to commit 6fee784c9f.
2026-02-05 20:48:01 +00:00
James Addison
6fee784c9f Indexing: add default-language placename from linked places 2026-02-05 15:19:48 +00:00
4 changed files with 19 additions and 6 deletions

View File

@@ -29,6 +29,7 @@ DECLARE
location RECORD;
result prepare_update_info;
extra_names HSTORE;
default_language VARCHAR(10);
BEGIN
IF not p.address ? '_inherited' THEN
result.address := p.address;
@@ -85,6 +86,13 @@ BEGIN
IF location.name is not NULL THEN
{% if debug %}RAISE WARNING 'Names original: %, location: %', result.name, location.name;{% endif %}
-- Add the linked-place (e.g. city) name as a searchable placename in the default language (if any)
default_language := get_country_language_code(location.country_code);
IF default_language is not NULL AND NOT location.name ? ('name:' || default_language) THEN
location.name := location.name || hstore('name:' || default_language, location.name->'name');
END IF;
-- Add all names from the place nodes that deviate from the name
-- in the relation with the prefix '_place_'. Deviation means that
-- either the value is different or a given key is missing completely

View File

@@ -56,7 +56,7 @@ class Indexer:
cur.execute('ANALYZE')
while True:
if await self.index_by_rank(0, 4) > 0:
if await self.index_by_rank(1, 4) > 0:
_analyze()
if await self.index_boundaries() > 100:
@@ -68,6 +68,9 @@ class Indexer:
if await self.index_by_rank(26, 30) > 1000:
_analyze()
# Special case: rank zero depends on the previously-indexed [1..30] ranks
await self.index_by_rank(0, 0)
if await self.index_postcodes() > 100:
_analyze()
@@ -147,8 +150,11 @@ class Indexer:
total += await self._index(runners.RankRunner(rank, analyzer),
batch=batch, total_tuples=total_tuples.get(rank, 0))
if maxrank == 30:
# Special case: rank zero depends on ranks [1..30]
if minrank == 0:
total += await self._index(runners.RankRunner(0, analyzer))
if maxrank == 30:
total += await self._index(runners.InterpolationRunner(analyzer), batch=20)
return total

View File

@@ -297,9 +297,8 @@ Feature: Linking of places
| R1 | LabelPlace |
@skip
Scenario: Linked places expand default language names
Given the grid
Given the grid with origin CO
| 1 | | 2 |
| | 9 | |
| 4 | | 3 |

View File

@@ -226,12 +226,12 @@ async def test_index_partial_with_30(test_db, threads, test_tokenizer):
idx = indexer.Indexer('dbname=test_nominatim_python_unittest', test_tokenizer, threads)
await idx.index_by_rank(28, 30)
assert test_db.placex_unindexed() == 27
assert test_db.placex_unindexed() == 28
assert test_db.osmline_unindexed() == 0
assert test_db.scalar("""
SELECT count(*) FROM placex
WHERE indexed_status = 0 AND rank_address between 1 and 27""") == 0
WHERE indexed_status = 0 AND rank_address between 0 and 27""") == 0
@pytest.mark.parametrize("threads", [1, 15])