diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index d20674e..97b3a7c 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -347,7 +347,7 @@ module Searchkick aggs = options[:aggs] payload[:aggs] = {} - aggs = aggs.map { |f| [f, {}] }.to_h if aggs.is_a?(Array) # convert to more advanced syntax + aggs = Hash[aggs.map { |f| [f, {}] }] if aggs.is_a?(Array) # convert to more advanced syntax aggs.each do |field, agg_options| size = agg_options[:limit] ? agg_options[:limit] : 100_000 diff --git a/test/aggs_test.rb b/test/aggs_test.rb index cf36efc..b95feb1 100644 --- a/test/aggs_test.rb +++ b/test/aggs_test.rb @@ -95,7 +95,7 @@ class AggsTest < Minitest::Test protected def buckets_as_hash(agg) - agg["buckets"].map { |v| [v["key"], v["doc_count"]] }.to_h + Hash[agg["buckets"].map { |v| [v["key"], v["doc_count"]] }] end def store_agg(options, agg_key = "store_id") @@ -104,8 +104,8 @@ class AggsTest < Minitest::Test end def store_multiple_aggs(options) - Product.search("Product", options).aggs.map do |field, filtered_agg| + Hash[Product.search("Product", options).aggs.map do |field, filtered_agg| [field, buckets_as_hash(filtered_agg)] - end.to_h + end] end end -- libgit2 0.21.0