From: Brian Quinion Date: Mon, 3 Dec 2012 17:41:29 +0000 (+0000) Subject: Experimental option to dry dropping query terms as part of search plan (disabled... X-Git-Tag: v2.2.0~173 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/a276b6b53a79bc6bd47861fdee9d2970eb0da691 Experimental option to dry dropping query terms as part of search plan (disabled by default) --- diff --git a/settings/settings.php b/settings/settings.php index a0a884fe..0a214ce9 100644 --- a/settings/settings.php +++ b/settings/settings.php @@ -30,6 +30,7 @@ @define('CONST_Search_AreaPolygons_Enabled', true); @define('CONST_Search_AreaPolygons', true); + @define('CONST_Search_TryDroppedAddressTerms', false); @define('CONST_Suggestions_Enabled', false); diff --git a/website/search.php b/website/search.php index 9941907d..08c2eee0 100755 --- a/website/search.php +++ b/website/search.php @@ -728,6 +728,42 @@ } } + if (CONST_Search_TryDroppedAddressTerms && sizeof($aStructuredQuery) > 0) + { + $aCopyGroupedSearches = $aGroupedSearches; + foreach($aCopyGroupedSearches as $iGroup => $aSearches) + { + foreach($aSearches as $iSearch => $aSearch) + { + $aReductionsList = array($aSearch['aAddress']); + $iSearchRank = $aSearch['iSearchRank']; + while(sizeof($aReductionsList) > 0) + { + $iSearchRank += 5; + if ($iSearchRank > iMaxRank) break 3; + $aNewReductionsList = array(); + foreach($aReductionsList as $aReductionsWordList) + { + for ($iReductionWord = 0; $iReductionWord < sizeof($aReductionsWordList); $iReductionWord++) + { + $aReductionsWordListResult = array_merge(array_slice($aReductionsWordList, 0, $iReductionWord), array_slice($aReductionsWordList, $iReductionWord+1)); + $aReverseSearch = $aSearch; + $aSearch['aAddress'] = $aReductionsWordListResult; + $aSearch['iSearchRank'] = $iSearchRank; + $aGroupedSearches[$iSearchRank][] = $aReverseSearch; + if (sizeof($aReductionsWordListResult) > 0) + { + $aNewReductionsList[] = $aReductionsWordListResult; + } + } + } + $aReductionsList = $aNewReductionsList; + } + } + } + ksort($aGroupedSearches); + } + // Filter out duplicate searches $aSearchHash = array(); foreach($aGroupedSearches as $iGroup => $aSearches)