X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/0b755473bfa03610541c260e628b5d567b627b16..ab9202b1c2de078822756d447e450610f0815692:/lib/SearchDescription.php diff --git a/lib/SearchDescription.php b/lib/SearchDescription.php index 47676d59..ad404528 100644 --- a/lib/SearchDescription.php +++ b/lib/SearchDescription.php @@ -187,7 +187,7 @@ class SearchDescription ) { if (!$this->sCountryCode) { $oSearch = clone $this; - $oSearch->iSearchRank += 2; + $oSearch->iSearchRank++; $oSearch->sCountryCode = $oSearchTerm->sCountryCode; // Country is almost always at the end of the string // - increase score for finding it anywhere else (optimisation) @@ -199,15 +199,10 @@ class SearchDescription } elseif (($sPhraseType == '' || $sPhraseType == 'postalcode') && is_a($oSearchTerm, '\Nominatim\Token\Postcode') ) { - // We need to try the case where the postal code is the primary element - // (i.e. no way to tell if it is (postalcode, city) OR (city, postalcode) - // so try both. if (!$this->sPostcode) { // If we have structured search or this is the first term, // make the postcode the primary search element. - if ($this->iOperator == Operator::NONE - && ($sPhraseType == 'postalcode' || $bFirstToken) - ) { + if ($this->iOperator == Operator::NONE && $bFirstToken) { $oSearch = clone $this; $oSearch->iSearchRank++; $oSearch->iOperator = Operator::POSTCODE; @@ -447,8 +442,8 @@ class SearchDescription $iLimit ); - //now search for housenumber, if housenumber provided - if ($this->sHouseNumber && !empty($aResults)) { + // Now search for housenumber, if housenumber provided. Can be zero. + if (($this->sHouseNumber || $this->sHouseNumber === '0') && !empty($aResults)) { // Downgrade the rank of the street results, they are missing // the housenumber. foreach ($aResults as $oRes) { @@ -657,13 +652,10 @@ class SearchDescription } if ($this->sHouseNumber) { - $aTerms[] = 'address_rank between 16 and 27'; + $aTerms[] = 'address_rank between 16 and 30'; } elseif (!$this->sClass || $this->iOperator == Operator::NAME) { if ($iMinAddressRank > 0) { - $aTerms[] = 'address_rank >= '.$iMinAddressRank; - } - if ($iMaxAddressRank < 30) { - $aTerms[] = 'address_rank <= '.$iMaxAddressRank; + $aTerms[] = "((address_rank between $iMinAddressRank and $iMaxAddressRank) or (search_rank between $iMinAddressRank and $iMaxAddressRank))"; } }