 (defn get-tags-mentions-matches
   "Extract matching timestamps for query."
   [g query]
-  (let [t-matched (map #(set (map :dest (uber/find-edges g {:src          {:tag %}
-                                                            :relationship :CONTAINS})))
-                       (:tags query))
-        m-matched (map #(set (map :dest (uber/find-edges g {:src          {:mention %}
-                                                            :relationship :CONTAINS})))
-                       (:mentions query))]
+  (let [mapper (fn [tag-type]
+                 (fn [tag]
+                   (set (map :dest (uber/find-edges g {:src          {tag-type tag}
+                                                       :relationship :CONTAINS})))))
+        t-matched (map (mapper :tag) (map s/lower-case (:tags query)))
+        m-matched (map (mapper :mention) (map s/lower-case (:mentions query)))]
     (apply set/intersection
            (concat t-matched m-matched))))
 

  [graph entry]
  (let [tags (:tags entry)]
    (reduce (fn [acc tag]
              (let [tag (s/lower-case tag)]
                (-> acc
                    (uber/add-nodes :hashtags {:tag tag})
                    (uber/add-edges [{:tag tag} (:timestamp entry) {:relationship :CONTAINS}]
                                    [:hashtags {:tag tag} {:relationship :IS}]))))
            graph
            tags)))


        old-entry (when (uber/has-node? graph ts) (uber/attrs graph ts))
        tags-not-in-new (set/difference (:tags old-entry) (:tags entry))
        mentions-not-in-new (set/difference (:mentions old-entry) (:mentions entry))
        remove-tag-edges (fn [g tags k]
                           (reduce #(uber/remove-edges %1 [(:timestamp entry) {k %2}]) g tags))]
    (-> current-state
        (update-in [:graph] #(uber/add-nodes-with-attrs % [ts (merge old-entry entry)]))
        (update-in [:graph] remove-tag-edges tags-not-in-new :tag)
