$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
) {
if ($this->iOperator == Operator::NONE) {
$oSearch = clone $this;
- $oSearch->iSearchRank++;
+ $oSearch->iSearchRank += 2;
$iOp = $oSearchTerm->iOperator;
if ($iOp == Operator::NONE) {
$iOp = Operator::NEAR;
}
$oSearch->iSearchRank += 2;
+ } else if (!$bFirstToken && !$bLastToken) {
+ $oSearch->iSearchRank += 2;
+ }
+ if ($this->sHouseNumber) {
+ $oSearch->iSearchRank++;
}
$oSearch->setPoiSearch(
$oSearch->aAddress[$iWordID] = $iWordID;
$aNewSearches[] = $oSearch;
}
- } else {
+ } else if (empty($this->aNameNonSearch)) {
$oSearch = clone $this;
$oSearch->iSearchRank++;
$oSearch->aName = array($iWordID => $iWordID);
if ((!$bStructuredPhrases || $iPhrase > 0)
&& (!empty($this->aName))
- && strpos($sToken, ' ') === false
) {
+ $oSearch = clone $this;
+ $oSearch->iSearchRank++;
+ if (preg_match('#^[0-9 ]+$#', $sToken)) {
+ $oSearch->iSearchRank++;
+ }
if ($oSearchTerm->iSearchNameCount < CONST_Max_Word_Frequency) {
- $oSearch = clone $this;
- $oSearch->iSearchRank += $oSearchTerm->iTermCount + 1;
- if (empty($this->aName)) {
- $oSearch->iSearchRank++;
- }
- if (preg_match('#^[0-9]+$#', $sToken)) {
- $oSearch->iSearchRank++;
- }
$oSearch->aAddress[$iWordID] = $iWordID;
- $aNewSearches[] = $oSearch;
} else {
- $oSearch = clone $this;
- $oSearch->iSearchRank += $oSearchTerm->iTermCount + 1;
$oSearch->aAddressNonSearch[$iWordID] = $iWordID;
if (!empty($aFullTokens)) {
$oSearch->iSearchRank++;
}
- $aNewSearches[] = $oSearch;
-
- // revert to the token version?
- foreach ($aFullTokens as $oSearchTermToken) {
- if (is_a($oSearchTermToken, '\Nominatim\Token\Word')) {
- $oSearch = clone $this;
- $oSearch->iSearchRank += 3;
- $oSearch->aAddress[$oSearchTermToken->iId]
- = $oSearchTermToken->iId;
- $aNewSearches[] = $oSearch;
- }
- }
}
+ $aNewSearches[] = $oSearch;
}
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 += 2;
- if (empty($this->aName)) {
- $oSearch->iSearchRank += 1;
+ $oSearch->iSearchRank++;
+ if (empty($this->aName) && empty($this->aNameNonSearch)) {
+ $oSearch->iSearchRank++;
}
- if (preg_match('#^[0-9]+$#', $sToken)) {
- $oSearch->iSearchRank += 2;
+ if (preg_match('#^[0-9 ]+$#', $sToken)) {
+ $oSearch->iSearchRank++;
}
if ($oSearchTerm->iSearchNameCount < CONST_Max_Word_Frequency) {
if (empty($this->aName)
}
$oSearch->aName[$iWordID] = $iWordID;
} else {
+ if (!empty($aFullTokens)) {
+ $oSearch->iSearchRank++;
+ }
$oSearch->aNameNonSearch[$iWordID] = $iWordID;
}
$oSearch->iNamePhrase = $iPhrase;