]> git.openstreetmap.org Git - nominatim.git/commitdiff
correctly discard partially matching duplicates
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 3 Jan 2019 20:49:50 +0000 (21:49 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 3 Jan 2019 20:49:50 +0000 (21:49 +0100)
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.

lib/Geocode.php

index e2fd7272c34db0deb4220d1ef83a6d95b6dbf9da..8b153d9a2d59a18497d25fd5a9c0c72c46e64085 100644 (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;
                 }