]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge pull request #2437 from lonvia/tweak-ranking-searches
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 3 Sep 2021 12:16:23 +0000 (14:16 +0200)
committerGitHub <noreply@github.com>
Fri, 3 Sep 2021 12:16:23 +0000 (14:16 +0200)
Some more tweaks for search interpretation

lib-php/TokenHousenumber.php
lib-php/TokenSpecialTerm.php

index cd60d3ca5620b7851a36736971adf753c6db49f9..f7bdc4713e913d0e466d48779e14a9a0924b0bc5 100644 (file)
@@ -59,7 +59,7 @@ class HouseNumber
         $iSearchCost = 1;
         if (preg_match('/\\d/', $this->sToken) === 0
             || preg_match_all('/[^0-9]/', $this->sToken, $aMatches) > 2) {
-            $iSearchCost++;
+            $iSearchCost += strlen($this->sToken) - 1;
         }
         if (!$oSearch->hasOperator(\Nominatim\Operator::NONE)) {
             $iSearchCost++;
index 5b2d4c70a64f75de8971da78500bc2b8ad65e331..6eb2ede341a21b2a51da6646431a8c5fd41c16f1 100644 (file)
@@ -44,7 +44,10 @@ class SpecialTerm
      */
     public function isExtendable($oSearch, $oPosition)
     {
-        return !$oSearch->hasOperator() && $oPosition->isPhrase('');
+        return !$oSearch->hasOperator()
+               && $oPosition->isPhrase('')
+               && ($this->iOperator != \Nominatim\Operator::NONE
+                  || (!$oSearch->hasAddress() && !$oSearch->hasHousenumber() && !$oSearch->hasCountry()));
     }
 
     /**
@@ -66,8 +69,8 @@ class SpecialTerm
                 $iOp = \Nominatim\Operator::NAME;
             } else {
                 $iOp = \Nominatim\Operator::NEAR;
+                $iSearchCost += 2;
             }
-            $iSearchCost += 2;
         } elseif (!$oPosition->isFirstToken() && !$oPosition->isLastToken()) {
             $iSearchCost += 2;
         }