]> git.openstreetmap.org Git - nominatim.git/commitdiff
add one-rank penalty for using partial search
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 11 Mar 2021 16:34:23 +0000 (17:34 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 11 Mar 2021 16:52:44 +0000 (17:52 +0100)
Ensures that full matches are preferred over partial ones even when
the full word consists of only one term.

lib-php/SearchDescription.php

index 913a90d2427f8c493d37bcaa9535205db1820517..436398cdfb50e80c501365991e039e8e33fb1bdc 100644 (file)
@@ -347,10 +347,13 @@ class SearchDescription
         }
 
         if ((!$this->sPostcode && !$this->aAddress && !$this->aAddressNonSearch)
         }
 
         if ((!$this->sPostcode && !$this->aAddress && !$this->aAddressNonSearch)
-            && (empty($this->aName) || $this->iNamePhrase == $iPhrase)
+            && ((empty($this->aName) && empty($this->aNameNonSearch)) || $this->iNamePhrase == $iPhrase)
         ) {
             $oSearch = clone $this;
             $oSearch->iSearchRank++;
         ) {
             $oSearch = clone $this;
             $oSearch->iSearchRank++;
+            if (empty($this->aName) && empty($this->aNameNonSearch)) {
+                $oSearch->iSearchRank++;
+            }
             if (preg_match('#^[0-9 ]+$#', $sToken)) {
                 $oSearch->iSearchRank++;
             }
             if (preg_match('#^[0-9 ]+$#', $sToken)) {
                 $oSearch->iSearchRank++;
             }