]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #3655 from lonvia/remove-name-ranking-in-postcode-search
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 20 Feb 2025 13:32:43 +0000 (14:32 +0100)
committerGitHub <noreply@github.com>
Thu, 20 Feb 2025 13:32:43 +0000 (14:32 +0100)
Tweak penalties for postcode searches

src/nominatim_api/query_preprocessing/normalize.py
src/nominatim_api/search/icu_tokenizer.py
test/bdd/api/search/structured.feature

index afb93ded3087c8e0c592fbb41efcb9241c713746..0bb0c8ed744d00e1e97c3c114b05ed9d887729d2 100644 (file)
@@ -27,5 +27,5 @@ def create(config: QueryConfig) -> QueryProcessingFunc:
 
     return lambda phrases: list(
         filter(lambda p: p.text,
-               (Phrase(p.ptype, cast(str, normalizer.transliterate(p.text)))
+               (Phrase(p.ptype, cast(str, normalizer.transliterate(p.text)).strip('-: '))
                 for p in phrases)))
index 6f1dcf7902ab65e5a4481d6a3d7b65e6274deab8..487dd1710354c9c9801cef9ce22033c1a5169e87 100644 (file)
@@ -244,7 +244,7 @@ class ICUQueryAnalyzer(AbstractQueryAnalyzer):
             standardized form search will work with. All information removed
             at this stage is inevitably lost.
         """
-        return cast(str, self.normalizer.transliterate(text))
+        return cast(str, self.normalizer.transliterate(text)).strip('-: ')
 
     def split_query(self, query: qmod.QueryStruct) -> Tuple[QueryParts, WordDict]:
         """ Transliterate the phrases and split them into tokens.
index a1dd5b83d4621b07dd670f3311dbf8d165cc0cce..1d60992335fe2657025c947f0e74f28f85414c19 100644 (file)
@@ -67,3 +67,13 @@ Feature: Structured search queries
         Then result addresses contain
           | town |
           | Vaduz |
+
+    #3651
+    Scenario: Structured search with surrounding extra characters
+        When sending xml search query "" with address
+          | street             | city  | postalcode |
+          | "19 Am schrägen Weg" | "Vaduz" | "9491"  |
+        Then result addresses contain
+          | house_number | road |
+          | 19           | Am Schrägen Weg |
+