]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/Geocode.php
downgrade housenumbers without numbers
[nominatim.git] / 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;
                 }