 (defn- range-condition->elastic
   "Convert a range condition to an elastic search condition. Execution
   should either by 'fielddata' or 'index'."
-  [field min-value max-value execution]
-  (cond
-    (and min-value max-value)
-    {:range {field {:gte min-value :lte max-value}
-             :execution execution}}
-
-    min-value
-    {:range {field {:gte min-value}
-             :execution execution}}
-
-    max-value
-    {:range {field {:lte max-value}
-             :execution execution}}
-
-    :else
-    (errors/internal-error! (m/nil-min-max-msg))))
+  ([field min-value max-value execution]
+   (range-condition->elastic field min-value max-value execution true))
+  ([field min-value max-value execution use-cache]
+   (cond
+     (and min-value max-value)
+     {:range {field {:gte min-value :lte max-value}
+              :execution execution
+              :_cache use-cache}}
+
+     min-value
+     {:range {field {:gte min-value}
+              :execution execution
+              :_cache use-cache}}
+
+     max-value
+     {:range {field {:lte max-value}
+              :execution execution
+              :_cache use-cache}}
+
+     :else
+     (errors/internal-error! (m/nil-min-max-msg)))))
 
 (extend-protocol ConditionToElastic
   cmr.search.models.query.ConditionGroup

            [cmr.search.data.datetime-helper :as h]
            [cmr.common.services.errors :as errors]
            [cmr.search.data.messages :as m]
            [cmr.search.data.keywords-to-elastic :as k2e]))

(def field-mappings
  "A map of fields in the query to the field name in elastic. Field names are excluded from this

    {:or [(range-condition->elastic (query-field->elastic-field min-field concept-type)
                                    min-value
                                    max-value
                                    (numeric-range-execution-mode)
                                    (numeric-range-use-cache))
          (range-condition->elastic (query-field->elastic-field max-field concept-type)
                                    min-value
                                    max-value
                                    (numeric-range-execution-mode)
                                    (numeric-range-use-cache))
          {:and [(range-condition->elastic (query-field->elastic-field min-field concept-type)
                                           nil
                                           min-value
                                           (numeric-range-execution-mode)
                                           (numeric-range-use-cache))
                 (range-condition->elastic (query-field->elastic-field max-field concept-type)
                                           max-value
                                           nil
                                           (numeric-range-execution-mode)
                                           (numeric-range-use-cache))]}]})

  cmr.search.models.query.StringRangeCondition
  (condition->elastic
