if (!empty($aResults)) {
$aSplitResults = Result::splitResults($aResults);
Debug::printVar('Split results', $aSplitResults);
- if ($iGroupLoop <= 4 && empty($aSplitResults['tail'])
- && reset($aSplitResults['head'])->iResultRank > 0) {
+ if ($iGroupLoop <= 4
+ && reset($aSplitResults['head'])->iResultRank > 0
+ && $iGroupedRank !== array_key_last($aGroupedSearches)) {
// Haven't found an exact match for the query yet.
// Therefore add result from the next group level.
$aNextResults = $aSplitResults['head'];
foreach ($aNextResults as $oRes) {
$oRes->iResultRank--;
}
+ foreach ($aSplitResults['tail'] as $oRes) {
+ $oRes->iResultRank--;
+ $aNextResults[$oRes->iId] = $oRes;
+ }
$aResults = array();
} else {
$aResults = $aSplitResults['head'];