 (defn apply-sort-options [solr-query this]
   (.setSortField solr-query (get-sort-field this) SolrQuery$ORDER/desc))
 
+(defn apply-highlight-options [solr-query]
+  (doto solr-query
+    (.setHighlight true)
+    (.setHighlightFragsize 120)
+    (.setHighlightRequireFieldMatch true)
+    (.setHighlightSnippets 3)))
+
 (defmulti get-solr-query (fn [this type] type))
 
 (defmethod get-solr-query :simple [this type]

      (log this "Preparing simple search for " (pr-str q))
      (doto (SolrQuery. q)
        (.setQueryType "dismax")
        (apply-sort-options this)))))

(defmethod get-solr-query :boolean [this type]
  (let [params (get-query-params this)]


;;; RENDERING RESULTS

(defn get-snippets [highlights docid]
  (when-let [h (get highlights (str docid))]
    (get h "text")))

(defn prepare-hit [highlights doc]
  (let [docid (.getFieldValue doc "docid")
        name (.getFieldValue doc "name")
        the-name (if (or (nil? name) (empty? name))
                   (str "Untitled #" (.getFieldValue doc "docid"))
                   name)]
  {:docid docid
   :url (format "/v1/cases/%s" docid)
   :size (when-let [size (.getFieldValue doc "size")]
           (int (Math/ceil (/ size 1024.0))))
   :date (date/format-long-date (.getFieldValue doc "date"))
   :court (courts/*court-names* (.getFieldValue doc "court"))
   :name (tmpl/h the-name)
   :citations (map tmpl/h (.getFieldValues doc "citations"))
   :snippets (get-snippets highlights docid)}))

(defn prepare-solr-results [solr-response]
  (let [docs (.getResults solr-response)]
