X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/182f5f5d7b4e3e01fc0ab60a263fa213260bde57..00b05e239495fe147f9a74f0e36eb243c8a32227:/lib-php/SearchDescription.php diff --git a/lib-php/SearchDescription.php b/lib-php/SearchDescription.php index 913a90d2..94cadda3 100644 --- a/lib-php/SearchDescription.php +++ b/lib-php/SearchDescription.php @@ -219,6 +219,9 @@ class SearchDescription $oSearch = clone $this; $oSearch->iSearchRank++; $oSearch->sHouseNumber = $oSearchTerm->sToken; + if ($this->iOperator != Operator::NONE) { + $oSearch->iSearchRank++; + } // sanity check: if the housenumber is not mainly made // up of numbers, add a penalty if (preg_match('/\\d/', $oSearch->sHouseNumber) === 0 @@ -255,7 +258,7 @@ class SearchDescription ) { if ($this->iOperator == Operator::NONE) { $oSearch = clone $this; - $oSearch->iSearchRank++; + $oSearch->iSearchRank += 2; $iOp = $oSearchTerm->iOperator; if ($iOp == Operator::NONE) { @@ -265,6 +268,11 @@ class SearchDescription $iOp = Operator::NEAR; } $oSearch->iSearchRank += 2; + } else if (!$bFirstToken && !$bLastToken) { + $oSearch->iSearchRank += 2; + } + if ($this->sHouseNumber) { + $oSearch->iSearchRank++; } $oSearch->setPoiSearch( @@ -289,7 +297,7 @@ class SearchDescription $oSearch->aAddress[$iWordID] = $iWordID; $aNewSearches[] = $oSearch; } - } else { + } else if (empty($this->aNameNonSearch)) { $oSearch = clone $this; $oSearch->iSearchRank++; $oSearch->aName = array($iWordID => $iWordID); @@ -347,10 +355,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++; }