 
 (def query (reagent/atom ""))
 (def query-immediate (reagent/atom nil))
-(def query-timeout (reagent/atom nil))
 (def nonfts-results (reagent/atom []))
+(def nonfts-keys (atom #{}))
 (def nonfts-cursor (atom nil))
 (def results (reagent/atom []))
 (def search-results (reagent/atom []))

(defn match-chunks [entries query]
  (if (not (nil? @query-immediate))
    (.clearImmediate js/window @query-immediate))
  (if (not (nil? @query-timeout))
    (.clearTimeout js/window @query-timeout))
  (reset! nonfts-cursor (partition-all 2000 entries))
  (reset! query-timeout
          (.setTimeout js/window #(do-match-chunks query true) 0)))

(defn set-query [q]
  (reset! query q)


        @score))))

(defn do-match-chunks [query reset just-for-next-queries]
  (if (not-empty @nonfts-cursor)
    (let [chunk (first @nonfts-cursor)
          key #(str (.-docset %) "/" (.-path (.-contents %)))
          new-results
          (->>
            chunk
            (filter #(not (contains? @nonfts-keys (key %))))
            (map (fn [v] [(score-exact (.-name (.-contents v)) query) v]))
            (filter #(> (first %) 0))
            (take 100))]
