]> git.openstreetmap.org Git - nominatim.git/commitdiff
Experimental option to dry dropping query terms as part of search plan (disabled...
authorBrian Quinion <openstreetmap@brian.quinion.co.uk>
Mon, 3 Dec 2012 17:41:29 +0000 (17:41 +0000)
committerBrian Quinion <openstreetmap@brian.quinion.co.uk>
Mon, 3 Dec 2012 17:41:29 +0000 (17:41 +0000)
settings/settings.php
website/search.php

index a0a884fea587f4f6c320648a85133fae1d8519e7..0a214ce9fa92746432072a5ee848d0b17b69a6ce 100644 (file)
@@ -30,6 +30,7 @@
 
        @define('CONST_Search_AreaPolygons_Enabled', true);
        @define('CONST_Search_AreaPolygons', true);
 
        @define('CONST_Search_AreaPolygons_Enabled', true);
        @define('CONST_Search_AreaPolygons', true);
+       @define('CONST_Search_TryDroppedAddressTerms', false);
 
        @define('CONST_Suggestions_Enabled', false);
 
 
        @define('CONST_Suggestions_Enabled', false);
 
index 9941907de93def39940c20942faa6fc0760d51a5..08c2eee095049c3ff6090c3de03bb42a265e6d8c 100755 (executable)
                                        }
                                }
 
                                        }
                                }
 
+                               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)
                                // Filter out duplicate searches
                                $aSearchHash = array();
                                foreach($aGroupedSearches as $iGroup => $aSearches)