]> git.openstreetmap.org Git - nominatim.git/commitdiff
reduce penalty for special searches by name
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 2 Sep 2021 16:13:45 +0000 (18:13 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 3 Sep 2021 06:50:38 +0000 (08:50 +0200)
Additional penalty for special terms with operator None
should only go to near searches. To reduce the number
of produced searches, restrict the none operator to
appear only in conjunction with the name.

lib-php/TokenSpecialTerm.php

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;
         }