]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/api/search/token_assignment.py
force a fixed pool size and make it configurable
[nominatim.git] / nominatim / api / search / token_assignment.py
index e9c03d3f96a76a490f7849be3bd97173fa162487..11da23594880f9f4353630e69e6e26dbee6f0f32 100644 (file)
@@ -270,7 +270,12 @@ class _TokenSequence:
             if (base.postcode.start == 0 and self.direction != -1)\
                or (base.postcode.end == query.num_token_slots() and self.direction != 1):
                 log().comment('postcode search')
-                yield dataclasses.replace(base, penalty=self.penalty)
+                # <address>,<postcode> should give preference to address search
+                if base.postcode.start == 0:
+                    penalty = self.penalty
+                else:
+                    penalty = self.penalty + 0.1
+                yield dataclasses.replace(base, penalty=penalty)
 
         # Postcode or country-only search
         if not base.address:
@@ -278,6 +283,9 @@ class _TokenSequence:
                 log().comment('postcode/country search')
                 yield dataclasses.replace(base, penalty=self.penalty)
         else:
+            # <postcode>,<address> should give preference to postcode search
+            if base.postcode and base.postcode.start == 0:
+                self.penalty += 0.1
             # Use entire first word as name
             if self.direction != -1:
                 log().comment('first word = name')
@@ -292,6 +300,10 @@ class _TokenSequence:
                                           penalty=self.penalty,
                                           address=base.address[:-1])
 
+            # variant for special housenumber searches
+            if base.housenumber:
+                yield dataclasses.replace(base, penalty=self.penalty)
+
             # Use beginning of first word as name
             if self.direction != -1:
                 first = base.address[0]