correctly discard partially matching duplicates

The same result may be found with different result ranks
in the same search loop when housenumber or postcode are
part of the name or address. In this case we need to keep
the result with the lower result rank.

Fixes #1264.
This commit is contained in:
Sarah Hoffmann
2019-01-03 21:49:50 +01:00
parent a0fde50c08
commit 7d74bf781c

View File

@@ -758,13 +758,22 @@ class Geocode
$oValidTokens->debugTokenByWordIdList()
);
$aResults += $oSearch->query(
$aNewResults = $oSearch->query(
$this->oDB,
$this->iMinAddressRank,
$this->iMaxAddressRank,
$this->iLimit
);
// The same result may appear in different rounds, only
// use the one with minimal rank.
foreach ($aNewResults as $iPlace => $oRes) {
if (!isset($aResults[$iPlace])
|| $aResults[$iPlace]->iResultRank > $oRes->iResultRank) {
$aResults[$iPlace] = $oRes;
}
}
if ($iQueryLoop > 20) break;
}