         text-query (->> parsed
                         (insta/transform
                           {:DOT str
-                           :TAG (constantly "")})
+                           :TAG (constantly "")
+                           :USER (constantly "")})
                         rest
                         (string/join "")
                         squash)
         tag-query (->> parsed
                        (insta/transform
                          {:DOT (constantly nil)
-                          :TAG identity})
+                          :TAG identity
+                          :USER (constantly nil)})
+                       rest
+                       (remove nil?))
+        user-query (->> parsed
+                       (insta/transform
+                         {:DOT (constantly nil)
+                          :TAG (constantly nil)
+                          :USER identity})
                        rest
                        (remove nil?))]
     {:text text-query
-     :tags tag-query}))
+     :tags tag-query
+     :users user-query}))
 
 (defn search-threads-as
   "Return the ids of all threads, visible to the user, in the given group,

  text 'foo'"
  [user-id [query group-id]]
  ; TODO: pagination?
  (let [{:keys [text tags]} (parse-query query)
        search-db (db/db)
        tag-search (when (seq tags)
                     (set (d/q '[:find ?t-id (max ?time)

                                    [(fulltext $ :message/content ?txt) [[?m]]]]
                                  search-db
                                  text
                                  group-id))))
        results [text-search tag-search user-search]]
    (->> (remove nil? results)
         (apply intersection)
         (filter (comp (partial thread/user-can-see-thread? user-id) first))
         ; sorting the ids so we can have a consistent order of results
         (sort-by second #(compare %2 %1))
