if (!empty($aResults)) {
$aSplitResults = Result::splitResults($aResults);
Debug::printVar('Split results', $aSplitResults);
- if ($iGroupLoop <= 4 && empty($aSplitResults['tail'])
+ if ($iGroupLoop <= 4
&& reset($aSplitResults['head'])->iResultRank > 0) {
// Haven't found an exact match for the query yet.
// Therefore add result from the next group level.
foreach ($aNextResults as $oRes) {
$oRes->iResultRank--;
}
+ foreach ($aSplitResults['tail'] as $oRes) {
+ $oRes->iResultRank--;
+ $aNextResults[$oRes->iId] = $oRes;
+ }
$aResults = array();
} else {
$aResults = $aSplitResults['head'];
public $iExactMatches = 0;
/// Subranking within the results (the higher the worse).
public $iResultRank = 0;
+ /// Address rank of the result.
+ public $iAddressRank;
public function debugInfo()
{
foreach ($aResults as $oRes) {
if ($oRes->iResultRank < $iMinRank) {
- $aTail = array_merge($aTail, $aHead);
+ $aTail += $aHead;
$aHead = array($oRes->iId => $oRes);
$iMinRank = $oRes->iResultRank;
} elseif ($oRes->iResultRank == $iMinRank) {
// Downgrade the rank of the street results, they are missing
// the housenumber.
foreach ($aResults as $oRes) {
- $oRes->iResultRank++;
+ if ($oRes->iAddressRank >= 26) {
+ $oRes->iResultRank++;
+ } else {
+ $oRes->iResultRank += 2;
+ }
}
$aHnResults = $this->queryHouseNumber($oDB, $aResults);
$aResults = array();
if (!empty($aTerms)) {
- $sSQL = 'SELECT place_id,'.$sExactMatchSQL;
+ $sSQL = 'SELECT place_id, address_rank,'.$sExactMatchSQL;
$sSQL .= ' FROM search_name';
$sSQL .= ' WHERE '.join(' and ', $aTerms);
$sSQL .= ' ORDER BY '.join(', ', $aOrder);
foreach ($aDBResults as $aResult) {
$oResult = new Result($aResult['place_id']);
$oResult->iExactMatches = $aResult['exactmatch'];
+ $oResult->iAddressRank = $aResult['address_rank'];
$aResults[$aResult['place_id']] = $oResult;
}
}