From 7c89b2349cfb7e9d7374bebdbff5b592ff5f0802 Mon Sep 17 00:00:00 2001 From: Rok Garbas Date: Sun, 7 Feb 2021 19:24:00 +0100 Subject: [PATCH] Filter on buckets only when there is some bucket selected (#289) otherwise the query is malformed --- src/Search.elm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Search.elm b/src/Search.elm index 5397035..42eba41 100644 --- a/src/Search.elm +++ b/src/Search.elm @@ -1095,9 +1095,15 @@ makeRequestBody query from sizeRaw sort type_ sortField otherSortFields bucketsF , Json.Encode.object [ ( "filter" , Json.Encode.list Json.Encode.object - [ filterByType type_ - , filterByBuckets - ] + (List.append + [ filterByType type_ ] + (if List.isEmpty filterByBuckets then + [] + + else + [ filterByBuckets ] + ) + ) ) , ( "must" , Json.Encode.list Json.Encode.object