]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib-php/Geocode.php
Merge pull request #2228 from AntoJvlt/import-special-phrases-porting-python
[nominatim.git] / lib-php / Geocode.php
index 12f9da37550f856e47a128641a275813d9c4e9de..f638af9a9a300a927f066a59690c23b6ee58e966 100644 (file)
@@ -778,14 +778,19 @@ class Geocode
                 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'];