mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 05:18:00 +00:00
merge addr tags into search_name table
When a place of rank 30 has addr tags that are not covered by the search terms of the parent, add a separate entry for the POI in the search_name table that includes the addr tags. We can only do that with named places. For POIs without a name the housenumber is used as name. If that is not available either, searching still won't work.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
Feature: Creation of search terms
|
||||
Tests that search_name table is filled correctly
|
||||
|
||||
Scenario: POIs without a name have no search entry
|
||||
Scenario: Unnamed POIs have no search entry
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | geometry |
|
||||
@@ -13,6 +13,152 @@ Feature: Creation of search terms
|
||||
When importing
|
||||
Then search_name has no entry for N1
|
||||
|
||||
Scenario: Unnamed POI has a search entry when it has unknown addr: tags
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | housenr | addr+city | geometry |
|
||||
| N1 | place | house | 23 | Walltown | :p-N1 |
|
||||
And the places
|
||||
| osm | class | type | name+name | geometry |
|
||||
| W1 | highway | residential | Rose Street | :w-north |
|
||||
When importing
|
||||
Then search_name contains
|
||||
| object | name_vector | nameaddress_vector |
|
||||
| N1 | #23 | Rose Street, Walltown |
|
||||
When searching for "23 Rose Street, Walltown"
|
||||
Then results contain
|
||||
| osm_type | osm_id |
|
||||
| N | 1 |
|
||||
|
||||
Scenario: Unnamed POI has no search entry when it has known addr: tags
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | housenr | addr+city | geometry |
|
||||
| N1 | place | house | 23 | Walltown | :p-N1 |
|
||||
And the places
|
||||
| osm | class | type | name+name | addr+city | geometry |
|
||||
| W1 | highway | residential | Rose Street | Walltown | :w-north |
|
||||
When importing
|
||||
Then search_name has no entry for N1
|
||||
When searching for "23 Rose Street, Walltown"
|
||||
Then results contain
|
||||
| osm_type | osm_id |
|
||||
| N | 1 |
|
||||
|
||||
Scenario: Unnamed POI must have a house number to get a search entry
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | addr+city | geometry |
|
||||
| N1 | place | house | Walltown | :p-N1 |
|
||||
And the places
|
||||
| osm | class | type | name+name | geometry |
|
||||
| W1 | highway | residential | Rose Street | :w-north |
|
||||
When importing
|
||||
Then search_name has no entry for N1
|
||||
|
||||
Scenario: Unnamed POIs doesn't inherit parent name when unknown addr:place is present
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | housenr | addr+place | geometry |
|
||||
| N1 | place | house | 23 | Walltown | :p-N1 |
|
||||
And the places
|
||||
| osm | class | type | name+name | geometry |
|
||||
| W1 | highway | residential | Rose Street | :w-north |
|
||||
When importing
|
||||
Then search_name contains
|
||||
| object | name_vector | nameaddress_vector |
|
||||
| N1 | #23 | Walltown |
|
||||
When searching for "23 Rose Street, Walltown"
|
||||
Then exactly 0 results are returned
|
||||
|
||||
# XXX Need to change parenting of POis without addr:street and with addr:place
|
||||
Scenario: Unnamed POIs doesn't inherit parent name when addr:place is present only in parent address
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | housenr | addr+place | geometry |
|
||||
| N1 | place | house | 23 | Walltown | :p-N1 |
|
||||
And the places
|
||||
| osm | class | type | name+name | addr+city | geometry |
|
||||
| W1 | highway | residential | Rose Street | Walltown | :w-north |
|
||||
When importing
|
||||
Then search_name contains
|
||||
| object | name_vector | nameaddress_vector |
|
||||
| N1 | #23 | Walltown |
|
||||
When searching for "23 Rose Street, Walltown"
|
||||
Then exactly 1 result is returned
|
||||
And results contain
|
||||
| osm_type | osm_id |
|
||||
| W | 1 |
|
||||
|
||||
Scenario: Unnamed POIs does inherit parent name when unknown addr:place and addr:street is present
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | housenr | addr+place | addr+street | geometry |
|
||||
| N1 | place | house | 23 | Walltown | Lily Street | :p-N1 |
|
||||
And the places
|
||||
| osm | class | type | name+name | geometry |
|
||||
| W1 | highway | residential | Rose Street | :w-north |
|
||||
When importing
|
||||
Then search_name has no entry for N1
|
||||
When searching for "23 Rose Street"
|
||||
Then results contain
|
||||
| osm_type | osm_id |
|
||||
| N | 1 |
|
||||
When searching for "23 Lily Street"
|
||||
Then exactly 0 results are returned
|
||||
|
||||
Scenario: An unknown addr:street is ignored
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | housenr | addr+street | geometry |
|
||||
| N1 | place | house | 23 | Lily Street | :p-N1 |
|
||||
And the places
|
||||
| osm | class | type | name+name | geometry |
|
||||
| W1 | highway | residential | Rose Street | :w-north |
|
||||
When importing
|
||||
Then search_name has no entry for N1
|
||||
When searching for "23 Rose Street"
|
||||
Then results contain
|
||||
| osm_type | osm_id |
|
||||
| N | 1 |
|
||||
When searching for "23 Lily Street"
|
||||
Then exactly 0 results are returned
|
||||
|
||||
Scenario: Named POIs have unknown address tags added in the search_name table
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | name+name | addr+city | geometry |
|
||||
| N1 | place | house | Green Moss | Walltown | :p-N1 |
|
||||
And the places
|
||||
| osm | class | type | name+name | geometry |
|
||||
| W1 | highway | residential | Rose Street | :w-north |
|
||||
When importing
|
||||
Then search_name contains
|
||||
| object | name_vector | nameaddress_vector |
|
||||
| N1 | #Green Moss | Rose Street, Walltown |
|
||||
When searching for "Green Moss, Rose Street, Walltown"
|
||||
Then results contain
|
||||
| osm_type | osm_id |
|
||||
| N | 1 |
|
||||
|
||||
Scenario: Named POI doesn't inherit parent name when addr:place is present only in parent address
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
| osm | class | type | name+name | addr+place | geometry |
|
||||
| N1 | place | house | Green Moss | Walltown | :p-N1 |
|
||||
And the places
|
||||
| osm | class | type | name+name | geometry |
|
||||
| W1 | highway | residential | Rose Street | :w-north |
|
||||
When importing
|
||||
Then search_name contains
|
||||
| object | name_vector | nameaddress_vector |
|
||||
| N1 | #Green Moss | Walltown |
|
||||
When searching for "Green Moss, Rose Street, Walltown"
|
||||
Then exactly 1 result is returned
|
||||
And results contain
|
||||
| osm_type | osm_id |
|
||||
| W | 1 |
|
||||
|
||||
Scenario: Named POIs inherit address from parent
|
||||
Given the scene roads-with-pois
|
||||
And the places
|
||||
|
||||
@@ -470,12 +470,22 @@ def check_search_name_contents(context, exclude):
|
||||
for res in cur:
|
||||
for h in row.headings:
|
||||
if h in ('name_vector', 'nameaddress_vector'):
|
||||
terms = [x.strip().replace('#', ' ') for x in row[h].split(',')]
|
||||
terms = [x.strip() for x in row[h].split(',') if not x.strip().startswith('#')]
|
||||
words = [x.strip()[1:] for x in row[h].split(',') if x.strip().startswith('#')]
|
||||
subcur = context.db.cursor()
|
||||
subcur.execute("""SELECT word_id, word_token
|
||||
FROM word, (SELECT unnest(%s) as term) t
|
||||
WHERE word_token = make_standard_name(t.term)""",
|
||||
(terms,))
|
||||
subcur.execute(""" SELECT word_id, word_token
|
||||
FROM word, (SELECT unnest(%s::TEXT[]) as term) t
|
||||
WHERE word_token = make_standard_name(t.term)
|
||||
and class is null and country_code is null
|
||||
and operator is null
|
||||
UNION
|
||||
SELECT word_id, word_token
|
||||
FROM word, (SELECT unnest(%s::TEXT[]) as term) t
|
||||
WHERE word_token = ' ' || make_standard_name(t.term)
|
||||
and class is null and country_code is null
|
||||
and operator is null
|
||||
""",
|
||||
(terms, words))
|
||||
if not exclude:
|
||||
ok_(subcur.rowcount >= len(terms),
|
||||
"No word entry found for " + row[h])
|
||||
|
||||
Reference in New Issue
Block a user