mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 05:14:07 +00:00
Added --no-replace command for special phrases importation and added corresponding tests
This commit is contained in:
@@ -306,7 +306,7 @@ class LegacyICUNameAnalyzer:
|
||||
# WHERE word_id is null and type = 'postcode'""")
|
||||
|
||||
|
||||
def update_special_phrases(self, phrases):
|
||||
def update_special_phrases(self, phrases, should_replace):
|
||||
""" Replace the search index for special phrases with the new phrases.
|
||||
"""
|
||||
norm_phrases = set(((self.normalize(p[0]), p[1], p[2], p[3])
|
||||
@@ -345,7 +345,7 @@ class LegacyICUNameAnalyzer:
|
||||
columns=['word', 'word_token', 'class', 'type',
|
||||
'operator', 'search_name_count'])
|
||||
|
||||
if to_delete:
|
||||
if to_delete and should_replace:
|
||||
psycopg2.extras.execute_values(
|
||||
cur,
|
||||
""" DELETE FROM word USING (VALUES %s) as v(name, in_class, in_type, op)
|
||||
|
||||
@@ -314,7 +314,7 @@ class LegacyNameAnalyzer:
|
||||
FROM location_postcode) x""")
|
||||
|
||||
|
||||
def update_special_phrases(self, phrases):
|
||||
def update_special_phrases(self, phrases, should_replace):
|
||||
""" Replace the search index for special phrases with the new phrases.
|
||||
"""
|
||||
norm_phrases = set(((self.normalize(p[0]), p[1], p[2], p[3])
|
||||
@@ -343,7 +343,7 @@ class LegacyNameAnalyzer:
|
||||
FROM (VALUES %s) as v(name, class, type, op))""",
|
||||
to_add)
|
||||
|
||||
if to_delete:
|
||||
if to_delete and should_replace:
|
||||
psycopg2.extras.execute_values(
|
||||
cur,
|
||||
""" DELETE FROM word USING (VALUES %s) as v(name, in_class, in_type, op)
|
||||
|
||||
Reference in New Issue
Block a user