Commit bfde6fbfd3579a2c00f8b351f0bca857572d6a29
1 parent
ac6aed3d
Exists in
master
and in
21 other branches
Replaced all calls to to_h - closes #559
Showing
2 changed files
with
4 additions
and
4 deletions
Show diff stats
lib/searchkick/query.rb
... | ... | @@ -347,7 +347,7 @@ module Searchkick |
347 | 347 | aggs = options[:aggs] |
348 | 348 | payload[:aggs] = {} |
349 | 349 | |
350 | - aggs = aggs.map { |f| [f, {}] }.to_h if aggs.is_a?(Array) # convert to more advanced syntax | |
350 | + aggs = Hash[aggs.map { |f| [f, {}] }] if aggs.is_a?(Array) # convert to more advanced syntax | |
351 | 351 | |
352 | 352 | aggs.each do |field, agg_options| |
353 | 353 | size = agg_options[:limit] ? agg_options[:limit] : 100_000 | ... | ... |
test/aggs_test.rb
... | ... | @@ -95,7 +95,7 @@ class AggsTest < Minitest::Test |
95 | 95 | protected |
96 | 96 | |
97 | 97 | def buckets_as_hash(agg) |
98 | - agg["buckets"].map { |v| [v["key"], v["doc_count"]] }.to_h | |
98 | + Hash[agg["buckets"].map { |v| [v["key"], v["doc_count"]] }] | |
99 | 99 | end |
100 | 100 | |
101 | 101 | def store_agg(options, agg_key = "store_id") |
... | ... | @@ -104,8 +104,8 @@ class AggsTest < Minitest::Test |
104 | 104 | end |
105 | 105 | |
106 | 106 | def store_multiple_aggs(options) |
107 | - Product.search("Product", options).aggs.map do |field, filtered_agg| | |
107 | + Hash[Product.search("Product", options).aggs.map do |field, filtered_agg| | |
108 | 108 | [field, buckets_as_hash(filtered_agg)] |
109 | - end.to_h | |
109 | + end] | |
110 | 110 | end |
111 | 111 | end | ... | ... |