diff --git a/src/ctia/stores/es/crud.clj b/src/ctia/stores/es/crud.clj index 434a2af43..640f0b547 100644 --- a/src/ctia/stores/es/crud.clj +++ b/src/ctia/stores/es/crud.clj @@ -723,7 +723,7 @@ It returns the documents with full hits meta data including the real index in wh :as agg-query} :- AggQuery] (cond-> (or (some-> (not-empty aggs) aggregation-filters) []) - (= :avg agg-type) (conj {:bool {:must {:exists {:field (:aggregate-on agg-query)}}}}))) + (some? agg-type) (conj {:exists {:field (:aggregate-on agg-query)}}))) (defn format-agg-result [agg-type diff --git a/test/ctia/stores/es/crud_test.clj b/test/ctia/stores/es/crud_test.clj index a7fc8557a..d56b37b46 100644 --- a/test/ctia/stores/es/crud_test.clj +++ b/test/ctia/stores/es/crud_test.clj @@ -615,19 +615,19 @@ :aggregate-on "title" :limit 20 :sort_order :desc}))) - (is (= [{:bool {:must {:exists {:field "intervals.something"}}}}] + (is (= [{:exists {:field "intervals.something"}}] (sut/aggregation-filters {:agg-type :avg :aggregate-on "intervals.something"}))) - (is (= [{:bool {:must {:exists {:field "intervals.something2"}}}} - {:bool {:must {:exists {:field "intervals.something1"}}}}] + (is (= [{:exists {:field "intervals.something2"}} + {:exists {:field "intervals.something1"}}] (sut/aggregation-filters {:agg-type :avg :aggregate-on "intervals.something1" :aggs {:agg-type :avg :aggregate-on "intervals.something2"}}))) - (is (= [{:bool {:must {:exists {:field "intervals.something2"}}}} - {:bool {:must {:exists {:field "intervals.something1"}}}}] + (is (= [{:exists {:field "intervals.something2"}} + {:exists {:field "intervals.something1"}}] (sut/aggregation-filters {:agg-type :avg :aggregate-on "intervals.something1"