]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/SearchDescription.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib / SearchDescription.php
index 5431b3eb957907417d38f130a3dd91abeb6bfc6f..a1910231ef8b53285ff561b52f1a00a1191c88ab 100644 (file)
@@ -58,7 +58,7 @@ class SearchDescription
     /**
      * Get current search rank.
      *
-     * The higher the search rank the lower the likelyhood that the
+     * The higher the search rank the lower the likelihood that the
      * search is a correct interpretation of the search query.
      *
      * @return integer Search rank.
@@ -289,10 +289,14 @@ class SearchDescription
                     $this->aFullNameAddress[$iWordID] = $iWordID;
                 }
             } else {
-                $oSearch = clone $this;
-                $oSearch->iSearchRank++;
-                $oSearch->aName = array($iWordID => $iWordID);
-                $aNewSearches[] = $oSearch;
+                // in structured search only the first phrase can be the
+                // designated name
+                if ($sPhraseType == '' || $bFirstPhrase) {
+                    $oSearch = clone $this;
+                    $oSearch->iSearchRank++;
+                    $oSearch->aName = array($iWordID => $iWordID);
+                    $aNewSearches[] = $oSearch;
+                }
             }
         }
 
@@ -675,7 +679,7 @@ class SearchDescription
         if ($this->sHouseNumber) {
             $sImportanceSQL = '- abs(26 - address_rank) + 3';
         } else {
-            $sImportanceSQL = '(CASE WHEN importance = 0 OR importance IS NULL THEN 0.75-(search_rank::float/40) ELSE importance END)';
+            $sImportanceSQL = '(CASE WHEN importance = 0 OR importance IS NULL THEN 0.75001-(search_rank::float/40) ELSE importance END)';
         }
         $sImportanceSQL .= $this->oContext->viewboxImportanceSQL('centroid');
         $aOrder[] = "$sImportanceSQL DESC";