]> git.openstreetmap.org Git - nominatim.git/blobdiff - website/search.php
correct penalty for multi-word countries
[nominatim.git] / website / search.php
index f0325f78d1ab1ff440b085ec563670c396acb63a..91869c3efaf22dc26e3f081893ecf948e405035c 100755 (executable)
                                {
                                        $aNewPhraseSearches = array();
 
-                                       foreach($aPhrases[$iPhrase]['wordsets'] as $iWordset => $aWordset)
+                                       foreach($aPhrases[$iPhrase]['wordsets'] as $aWordset)
                                        {
                                                $aWordsetSearches = $aSearches;
 
                                                // Add all words from this wordset
-                                               foreach($aWordset as $sToken)
+                                               foreach($aWordset as $iToken => $sToken)
                                                {
 //echo "<br><b>$sToken</b>";
                                                        $aNewWordsetSearches = array();
                                                                                        {
                                                                                                $aSearch['sCountryCode'] = strtolower($aSearchTerm['country_code']);
                                                                                                // Country is almost always at the end of the string - increase score for finding it anywhere else (optimisation)
-                                                                                               if ($iWordset+1 != sizeof($aPhrases[$iPhrase]['wordsets']) || $iPhrase+1 != sizeof($aPhrases)) $aSearch['iSearchRank'] += 5;
+                                                                                               if ($iToken+1 != sizeof($aWordset) || $iPhrase+1 != sizeof($aPhrases)) $aSearch['iSearchRank'] += 5;
                                                                                                if ($aSearch['iSearchRank'] < $iMaxRank) $aNewWordsetSearches[] = $aSearch;
                                                                                        }
                                                                                }
                                                        else
                                                        {
                                                                $sSQL = "select place_id from placex where class='".$aSearch['sClass']."' and type='".$aSearch['sType']."'";
-                                                               $sSQL .= " and st_contains($sViewboxSmallSQL, centroid)";
+                                                               $sSQL .= " and st_contains($sViewboxSmallSQL, geometry)";
                                                                if ($sCountryCodesSQL) $sSQL .= " and country_code in ($sCountryCodesSQL)";                                                             
                                                                if ($sViewboxCentreSQL) $sSQL .= " order by st_distance($sViewboxCentreSQL, centroid) asc";
                                                                $sSQL .= " limit $iLimit";