]> git.openstreetmap.org Git - nominatim.git/blobdiff - website/search.php
Missing some exact name matches when searching for 'special' phrases
[nominatim.git] / website / search.php
index 541d5ec450e9678622fd171ba0d4ad51fb03474f..c19d1ade4943737a82b22da94eabc0876681b660 100755 (executable)
@@ -40,7 +40,7 @@
           + ($bAsGeoJSON?1:0) 
           + ($bAsKML?1:0) 
           + ($bAsSVG?1:0) 
           + ($bAsGeoJSON?1:0) 
           + ($bAsKML?1:0) 
           + ($bAsSVG?1:0) 
-          + ($bAsTEXT?1:0) 
+          + ($bAsText?1:0) 
                ) > CONST_PolygonOutput_MaximumTypes) {
                if (CONST_PolygonOutput_MaximumTypes) {
                        userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
                ) > CONST_PolygonOutput_MaximumTypes) {
                if (CONST_PolygonOutput_MaximumTypes) {
                        userError("Select only ".CONST_PolygonOutput_MaximumTypes." polgyon output option");
                                                                if (!$aSearch['sClass']) continue;
                                                                if (CONST_Debug) var_dump('<hr>',$aSearch);
                                                                if (CONST_Debug) _debugDumpGroupedSearches(array($iGroupedRank => array($aSearch)), $aValidTokens);     
                                                                if (!$aSearch['sClass']) continue;
                                                                if (CONST_Debug) var_dump('<hr>',$aSearch);
                                                                if (CONST_Debug) _debugDumpGroupedSearches(array($iGroupedRank => array($aSearch)), $aValidTokens);     
-
                                                                $sSQL = "select count(*) from pg_tables where tablename = 'place_classtype_".$aSearch['sClass']."_".$aSearch['sType']."'";
                                                                if ($oDB->getOne($sSQL))
                                                                {
                                                                $sSQL = "select count(*) from pg_tables where tablename = 'place_classtype_".$aSearch['sClass']."_".$aSearch['sType']."'";
                                                                if ($oDB->getOne($sSQL))
                                                                {
                                                        {
                                                                $sPlaceIDs = join(',',$aPlaceIDs);
 
                                                        {
                                                                $sPlaceIDs = join(',',$aPlaceIDs);
 
+                                                               $aResultPlaceIDs = array();
+
                                                                if (!$aSearch['sOperator'] || $aSearch['sOperator'] == 'name')
                                                                {
                                                                        // If they were searching for a named class (i.e. 'Kings Head pub') then we might have an extra match
                                                                if (!$aSearch['sOperator'] || $aSearch['sOperator'] == 'name')
                                                                {
                                                                        // If they were searching for a named class (i.e. 'Kings Head pub') then we might have an extra match
                                                                        if ($sCountryCodesSQL) $sSQL .= " and country_code in ($sCountryCodesSQL)";                                                             
                                                                        $sSQL .= " order by rank_search asc limit $iLimit";
                                                                        if (CONST_Debug) var_dump($sSQL);
                                                                        if ($sCountryCodesSQL) $sSQL .= " and country_code in ($sCountryCodesSQL)";                                                             
                                                                        $sSQL .= " order by rank_search asc limit $iLimit";
                                                                        if (CONST_Debug) var_dump($sSQL);
-                                                                       $aPlaceIDs = $oDB->getCol($sSQL);
+                                                                       $aResultPlaceIDs = $oDB->getCol($sSQL);
                                                                }
                                                                
                                                                if (!$aSearch['sOperator'] || $aSearch['sOperator'] == 'near') // & in
                                                                }
                                                                
                                                                if (!$aSearch['sOperator'] || $aSearch['sOperator'] == 'near') // & in
                                                                        else
                                                                        {
                                                                                $iMaxRank += 5;
                                                                        else
                                                                        {
                                                                                $iMaxRank += 5;
-                                                                       $sSQL = "select place_id from placex where place_id in ($sPlaceIDs) and rank_search < $iMaxRank";
-                                                                       if (CONST_Debug) var_dump($sSQL);
-                                                                       $aPlaceIDs = $oDB->getCol($sSQL);
-                                                                       $sPlaceIDs = join(',',$aPlaceIDs);
+                                                                               $sSQL = "select place_id from placex where place_id in ($sPlaceIDs) and rank_search < $iMaxRank";
+                                                                               if (CONST_Debug) var_dump($sSQL);
+                                                                               $aPlaceIDs = $oDB->getCol($sSQL);
+                                                                               $sPlaceIDs = join(',',$aPlaceIDs);
                                                                        }
 
                                                                        if ($sPlaceIDs || $sPlaceGeom)
                                                                        }
 
                                                                        if ($sPlaceIDs || $sPlaceGeom)
                                                                                else if ($sPlaceIDs) $sOrderBySQL = "ST_Distance(l.centroid, f.geometry)";
                                                                                else if ($sPlaceGeom) $sOrderBysSQL = "ST_Distance(st_centroid('".$sPlaceGeom."'), l.centroid)";
                                                                                
                                                                                else if ($sPlaceIDs) $sOrderBySQL = "ST_Distance(l.centroid, f.geometry)";
                                                                                else if ($sPlaceGeom) $sOrderBysSQL = "ST_Distance(st_centroid('".$sPlaceGeom."'), l.centroid)";
                                                                                
-                                                                               $sSQL = "select distinct l.place_id".($sOrderBysSQL?','.$sOrderBysSQL:'')." from place_classtype_".$aSearch['sClass']."_".$aSearch['sType']." as l";
+                                                                               $sSQL = "select distinct l.place_id".($sOrderBySQL?','.$sOrderBySQL:'')." from place_classtype_".$aSearch['sClass']."_".$aSearch['sType']." as l";
                                                                                if ($sCountryCodesSQL) $sSQL .= " join placex as lp using (place_id)";
                                                                                if ($sPlaceIDs)
                                                                                {
                                                                                if ($sCountryCodesSQL) $sSQL .= " join placex as lp using (place_id)";
                                                                                if ($sPlaceIDs)
                                                                                {
                                                                                        $sSQL .= " and l.place_id not in (".join(',',$aExcludePlaceIDs).")";
                                                                                }
                                                                                if ($sCountryCodesSQL) $sSQL .= " and lp.country_code in ($sCountryCodesSQL)";
                                                                                        $sSQL .= " and l.place_id not in (".join(',',$aExcludePlaceIDs).")";
                                                                                }
                                                                                if ($sCountryCodesSQL) $sSQL .= " and lp.country_code in ($sCountryCodesSQL)";
-                                                                               if ($sOrderBy) $sSQL .= "order by ".$OrderBysSQL." asc";
+                                                                               if ($sOrderBySQL) $sSQL .= "order by ".$sOrderBySQL." asc";
                                                                                if ($iOffset) $sSQL .= " offset $iOffset";
                                                                                $sSQL .= " limit $iLimit";
                                                                                if (CONST_Debug) var_dump($sSQL);
                                                                                if ($iOffset) $sSQL .= " offset $iOffset";
                                                                                $sSQL .= " limit $iLimit";
                                                                                if (CONST_Debug) var_dump($sSQL);
-                                                                               $aPlaceIDs = $oDB->getCol($sSQL);
+                                                                               $aResultPlaceIDs = array_merge($aResultPlaceIDs, $oDB->getCol($sSQL));
                                                                        }
                                                                        else
                                                                        {
                                                                        }
                                                                        else
                                                                        {
                                                                                if ($iOffset) $sSQL .= " offset $iOffset";
                                                                                $sSQL .= " limit $iLimit";
                                                                                if (CONST_Debug) var_dump($sSQL);
                                                                                if ($iOffset) $sSQL .= " offset $iOffset";
                                                                                $sSQL .= " limit $iLimit";
                                                                                if (CONST_Debug) var_dump($sSQL);
-                                                                               $aPlaceIDs = $oDB->getCol($sSQL);
+                                                                               $aResultPlaceIDs = array_merge($aResultPlaceIDs, $oDB->getCol($sSQL));
                                                                        }
                                                                        }
                                                                }
                                                                        }
                                                                        }
                                                                }
+
+                                                               $aPlaceIDs = $aResultPlaceIDs;
+
                                                        }
                                                
                                                }
                                                        }
                                                
                                                }