diff --git a/src/engine/imap-db/imap-db-account.vala b/src/engine/imap-db/imap-db-account.vala
index 9e29cfa..8261afd 100644
--- a/src/engine/imap-db/imap-db-account.vala
+++ b/src/engine/imap-db/imap-db-account.vala
@@ -995,28 +995,25 @@ private class Geary.ImapDB.Account : BaseObject {
                 }
             }
             
-            phrases.set(field ?? "MessageSearchTable", builder.str);
+            phrases.set(field ?? "", builder.str);
         }
         
         return phrases;
     }
     
-    private void sql_add_query_phrases(StringBuilder sql, Gee.HashMap<string, string> query_phrases) {
-        foreach (string field in query_phrases.keys)
-            sql.append(" AND %s MATCH ?".printf(field));
-    }
-    
     private int sql_bind_query_phrases(Db.Statement stmt, int start_index,
         Gee.HashMap<string, string> query_phrases) throws Geary.DatabaseError {
         int i = start_index;
+        StringBuilder query_expression = new StringBuilder();
         // This relies on the keys being returned in the same order every time
         // from the same map.  It might not be guaranteed, but I feel pretty
         // confident it'll work unless you change the map in between.
         foreach (string field in query_phrases.keys)
-            stmt.bind_string(i++, query_phrases.get(field));
+            query_expression.append_printf("%s:%s ", field, query_phrases.get(field));
+        stmt.bind_string(i++, query_expression.str);
         return i - start_index;
     }
-    
+
     // Append each id in the collection to the StringBuilder, in a format
     // suitable for use in an SQL statement IN (...) clause.
     private void sql_append_ids(StringBuilder s, Gee.Iterable<int64?> ids) {
@@ -1105,10 +1102,10 @@ private class Geary.ImapDB.Account : BaseObject {
                 WHERE id IN (
                     SELECT docid
                     FROM MessageSearchTable
-                    WHERE 1=1
+                    WHERE MessageSearchTable
+                    MATCH ?
+                )
             """);
-            sql_add_query_phrases(sql, query_phrases);
-            sql.append(")");
             
             if (blacklisted_ids_sql != "")
                 sql.append(" AND id NOT IN (%s)".printf(blacklisted_ids_sql));
@@ -1809,8 +1806,11 @@ private class Geary.ImapDB.Account : BaseObject {
             WHERE docid IN (
         """);
         sql_append_ids(sql, id_map.keys);
-        sql.append(")");
-        sql_add_query_phrases(sql, query_phrases);
+        sql.append("""
+            )
+            AND MessageSearchTable
+            MATCH ?
+        """);
         
         Db.Statement stmt = cx.prepare(sql.str);
         sql_bind_query_phrases(stmt, 0, query_phrases);
