Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify extra filters #1436

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ctia/stores/es/crud.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/ctia/stores/es/crud_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading