Skip to content

Commit 8e09476

Browse files
committed
Simplified agg conditions
1 parent 42e4bd8 commit 8e09476

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/searchkick/query.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,10 +909,15 @@ def where_without_field(where, field)
909909
result = {}
910910
where.each do |f, v|
911911
case f
912-
when :_and, :_or
913-
result[f] = v.map { |v2| where_without_field(v2, field) }
912+
when :_and
913+
r = v.map { |v2| where_without_field(v2, field) }.reject(&:empty?)
914+
result[f] = r unless r.empty?
915+
when :_or
916+
r = v.map { |v2| where_without_field(v2, field) }
917+
result[f] = r unless r.any?(&:empty?)
914918
when :_not
915-
result[f] = where_without_field(v, field)
919+
r = where_without_field(v, field)
920+
result[f] = r unless r.empty?
916921
when :_script
917922
result[f] = v
918923
else

0 commit comments

Comments
 (0)