]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/SearchDescription.php
for structured search only accept name terms from the first phrase
[nominatim.git] / lib / SearchDescription.php
index bf45dadaf41adad4f1d586b56a3674baa9590388..c379fdf3bec852895d6eca462ddee97a3d8f8d12 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.
@@ -262,7 +262,7 @@ class SearchDescription
 
                 $iOp = Operator::NEAR; // near == in for the moment
                 if ($aSearchTerm['operator'] == '') {
-                    if (sizeof($this->aName)) {
+                    if (sizeof($this->aName) || $this->oContext->isBoundedSearch()) {
                         $iOp = Operator::NAME;
                     }
                     $oSearch->iSearchRank += 2;
@@ -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;
+                }
             }
         }
 
@@ -326,7 +330,7 @@ class SearchDescription
         ) {
             if ($aSearchTerm['search_name_count'] + 1 < CONST_Max_Word_Frequency) {
                 $oSearch = clone $this;
-                $oSearch->iSearchRank++;
+                $oSearch->iSearchRank += 2;
                 $oSearch->aAddress[$iWordID] = $iWordID;
                 $aNewSearches[] = $oSearch;
             } else {
@@ -360,7 +364,7 @@ class SearchDescription
             && (!sizeof($this->aName) || $this->iNamePhrase == $iPhrase)
         ) {
             $oSearch = clone $this;
-            $oSearch->iSearchRank++;
+            $oSearch->iSearchRank += 2;
             if (!sizeof($this->aName)) {
                 $oSearch->iSearchRank += 1;
             }