                             hierarchical-fields))]
     (assoc v2-facets-root :children facets)))
 
-; (defn create-v2-facets-orig
-;   "Create the facets v2 response. Takes an elastic aggregations result and returns the facets."
-;   [elastic-aggregations]
-;   (println "Elastic aggregations response" elastic-aggregations)
-;   (concat (frf/bucket-map->facets (apply dissoc elastic-aggregations [:science-keywords])
-;                                   [:data-center :project :platform :instrument :processing-level-id])
-;           (map (fn [field]
-;                  (assoc (frf/hierarchical-bucket-map->facets field (field elastic-aggregations))
-;                         :field (csk/->snake_case_string field)))
-;                [:science-keywords])))
-
 (defmethod query-execution/pre-process-query-result-feature :facets-v2
   [context query feature]
   (assoc query :aggregations (facets-v2-aggregations DEFAULT_TERMS_SIZE)))

  names. Returns a facet map of those specific names with value count pairs"
  [bucket-map field-names]
  (for [field-name field-names
        ; :let [value-counts (frf/buckets->value-count-pairs (get bucket-map field-name))]
        :let [value-counts (frf/buckets->value-count-pairs (field-name bucket-map))
              has-children (some? (seq value-counts))
              ; base-node {:title (get fields->human-readable-label (keyword field-name))}
              base-node {:title (field-name fields->human-readable-label)
                         :type :group
                         ;; TODO with another ticket
                         ;  :applied ;; either true or false
                         :has_children has-children}]]
    ; (println "The field name is ")
    (if has-children
      (assoc base-node :children (map (fn [[term count]]
                                        {:title term

  (:require [cmr.common-app.services.search.query-execution :as query-execution]
            [cmr.common-app.services.kms-fetcher :as kms-fetcher]
            [cmr.search.services.query-execution.facets-results-feature :as frf]
            [camel-snake-kebab.core :as csk]
            [cmr.common.util :as util]))


(def UNLIMITED_TERMS_SIZE
