Bug 738961 - Awesomebar filter should treat space-separated words as separate filters. r=lucasr
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Mon, 02 Apr 2012 11:56:48 -0700
changeset 94170 823ab3b9d814478813d49e273ec63a0d5da4309c
parent 94169 d30a86bb54083084f9f7257b88c9a8daf30109e7
child 94171 dc634206d156893059c17882a9afa47e60da2059
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslucasr
bugs738961
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 738961 - Awesomebar filter should treat space-separated words as separate filters. r=lucasr
mobile/android/base/db/LocalBrowserDB.java
--- a/mobile/android/base/db/LocalBrowserDB.java
+++ b/mobile/android/base/db/LocalBrowserDB.java
@@ -138,23 +138,29 @@ public class LocalBrowserDB implements B
     }
 
     private Uri appendProfile(Uri uri) {
         return uri.buildUpon().appendQueryParameter(BrowserContract.PARAM_PROFILE, mProfile).build();
     }
 
     private Cursor filterAllSites(ContentResolver cr, String[] projection, CharSequence constraint,
             int limit, CharSequence urlFilter) {
-        // The combined history/bookmarks selection queries for sites with a url or title
-        // containing the constraint string
-        String selection = "(" + Combined.URL + " LIKE ? OR " +
-                                 Combined.TITLE + " LIKE ?)";
+        String selection = "";
+        String[] selectionArgs = null;
 
-        final String historySelectionArg = "%" + constraint.toString() + "%";
-        String[] selectionArgs = new String[] { historySelectionArg, historySelectionArg };
+        // The combined history/bookmarks selection queries for sites with a url or title containing
+        // the constraint string(s), treating space-separated words as separate constraints
+        String[] constraintWords = constraint.toString().split(" ");
+        for (int i = 0; i < constraintWords.length; i++) {
+            selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " LIKE ? OR " +
+                                                                  Combined.TITLE + " LIKE ?)");
+            String constraintWord =  "%" + constraintWords[i] + "%";
+            selectionArgs = DBUtils.appendSelectionArgs(selectionArgs,
+                new String[] { constraintWord, constraintWord });
+        }
 
         if (urlFilter != null) {
             selection = DBUtils.concatenateWhere(selection, "(" + Combined.URL + " NOT LIKE ?)");
             selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, new String[] { urlFilter.toString() });
         }
 
         // Our version of frecency is computed by scaling the number of visits by a multiplier
         // that approximates Gaussian decay, based on how long ago the entry was last visited.