lib/search_flip/aggregatable.rb in search_flip-3.0.0.beta3 vs lib/search_flip/aggregatable.rb in search_flip-3.0.0.beta4
- old
+ new
@@ -56,13 +56,14 @@
if block
aggregation = yield(SearchFlip::Aggregation.new(target: target))
if field_or_hash.is_a?(Hash)
- value = field_or_hash.values.first
- value = value.values.first if value.is_a?(Hash) && !value.empty?
+ aggregation_hash = field_or_hash.values.first
+ aggregation_hash = aggregation_hash[:top_hits] if aggregation_hash.is_a?(Hash) && aggregation_hash.key?(:top_hits)
+ aggregation_hash = aggregation_hash["top_hits"] if aggregation_hash.is_a?(Hash) && aggregation_hash.key?("top_hits")
- value.merge!(aggregation.to_hash)
+ aggregation_hash.merge!(aggregation.to_hash)
else
hash[field_or_hash].merge!(aggregation.to_hash)
end
end