From: Sarah Hoffmann Date: Thu, 11 Mar 2021 16:34:23 +0000 (+0100) Subject: add one-rank penalty for using partial search X-Git-Tag: v3.7.0~19^2~5 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/478dfb0639f6bb6d8eb160bb881fddf7b730cc85 add one-rank penalty for using partial search Ensures that full matches are preferred over partial ones even when the full word consists of only one term. --- diff --git a/lib-php/SearchDescription.php b/lib-php/SearchDescription.php index 913a90d2..436398cd 100644 --- a/lib-php/SearchDescription.php +++ b/lib-php/SearchDescription.php @@ -347,10 +347,13 @@ class SearchDescription } 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++; + if (empty($this->aName) && empty($this->aNameNonSearch)) { + $oSearch->iSearchRank++; + } if (preg_match('#^[0-9 ]+$#', $sToken)) { $oSearch->iSearchRank++; }