]> git.openstreetmap.org Git - nominatim.git/commitdiff
second attempt at strict names in structured queries
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 1 Mar 2018 23:26:48 +0000 (00:26 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 1 Mar 2018 23:26:48 +0000 (00:26 +0100)
If a term does not go into names it should go into
address terms.

lib/SearchDescription.php

index a1910231ef8b53285ff561b52f1a00a1191c88ab..2e72deccc4792908b8067c9cdd30f0a8762a60ad 100644 (file)
@@ -276,11 +276,12 @@ class SearchDescription
                   && $sPhraseType != 'country'
         ) {
             $iWordID = $aSearchTerm['word_id'];
-            if (sizeof($this->aName)) {
-                if (($sPhraseType == '' || !$bFirstPhrase)
-                    && $sPhraseType != 'country'
-                    && !$bHasPartial
-                ) {
+            // Full words can only be a name if they appear at the beginning
+            // of the phrase. In structured search the name must forcably in
+            // the first phrase. In unstructured search it may be in a later
+            // phrase when the first phrase is a house number.
+            if (sizeof($this->aName) || !($bFirstPhrase || $sPhraseType == '')) {
+                if (($sPhraseType == '' || !$bFirstPhrase) && !$bHasPartial) {
                     $oSearch = clone $this;
                     $oSearch->iSearchRank++;
                     $oSearch->aAddress[$iWordID] = $iWordID;
@@ -289,14 +290,10 @@ class SearchDescription
                     $this->aFullNameAddress[$iWordID] = $iWordID;
                 }
             } else {
-                // 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;
-                }
+                $oSearch = clone $this;
+                $oSearch->iSearchRank++;
+                $oSearch->aName = array($iWordID => $iWordID);
+                $aNewSearches[] = $oSearch;
             }
         }