    (s/optional-key :body) s/Str ; search results don't have a body
    :categories (s/pred not-empty #{s/Str})})
 
-(def SolrFacetPair
-  [(s/one s/Str "facet") (s/one s/Int 1)])
-
-;; A facet could have zero results.
-(def SolrFacetResult
-  [SolrFacetPair])
-
-(def SolrFacetFields
-  "a schema for a range of facets"
-  {:author SolrFacetResult})
 
 (defn transform-doc [doc]
   (-> doc


(def result-fields [:id :title :author :categories :created-on])
(def document-fields [:id :title :body :author :categories :created-on])
(def facet-document-fields [:author :categories :created-on-year])

(defn create-field-param [fields]
  (string/join " " (map csk/->snake_case_string fields)))

(defn search-params [{:keys [text page page-size fields]}]
  (let [params {:q text

                :hl.fragsize 300
                :fl (create-field-param result-fields)
                :facet true
                :facet.field (map csk/->snake_case_string facet-document-fields)
                :facet.mincount 1}]
    (assoc params :fq
           (->> fields
                (map (fn [[field values]]
                       (map (fn [value]
                              (str (csk/->snake_case_string field) ":\"" value "\"")))))
                (concat)))))
