                             :failures 0}))
 
 (defn get-classifier
-  "Gets the classifier needed for the specified user/phrase."
+  "Gets the classifier needed for the specified user/phrase. If the classifier
+  is not found in the database then generate one."
   [user-id phrase]
   (if-let [result (mc/find-one-as-map "classifiers"
                                       {:user_id user-id :phrase phrase})]

  []
  ; Set up an index on random_point for cadence and phrases so we can
  ; *randomlyish* select a few of them.
  (mc/ensure-index "cadences" {:phrase 1
                               :user_id 1
                               :random_point "2d"})
  (mc/ensure-index "phrases" {:random_point "2d", :users 1})
  (mc/ensure-index "phrases" {:usersCount 1})
  (mc/ensure-index "phrases" {:phrase-id 1})
  (mc/ensure-index "phrases" {:phrase 1} {:unique 1 :dropDups 1})
  (mc/ensure-index "classifiers" {:user_id 1
                                  :phrase 1})
  ; The `username` key should be unique.
  (mc/ensure-index "users" {:username 1} {:unique 1 :dropDups 1}))


  (let [find-cadences (fn [by-user lim]
                        (mq/with-collection "cadences"
                          (mq/find {:phrase phrase
                                    :user_id (if by-user
                                               user-id
                                               {$ne user-id})
                                    :random_point {"$near" [(rand) 0]}})
                          (mq/fields [:timeline :phrase])
                          (mq/limit lim)
                          (mq/snapshot)))]
