Skip to content

Add Results::Aggregations wrapper #55

Description

@esmarkowski

enable things like iterating over buckets

Iterators

results.aggregations.top_names.each do |bucket|

end
# instead of results.aggregations.top_names.buckets.each

Keyed hash

results.aggregations.top_names.inject({}) { |h,d| h[d["key"]] = d["doc_count"]; h}
# => 
{"Aeroflot"=>179,
 "Military - U.S. Air Force"=>176,
 "Air France"=>70,
 "Deutsche Lufthansa"=>65,
 "Air Taxi"=>44,
 "China National Aviation Corporation"=>44,
 "United Air Lines"=>44,
 "Military - U.S. Army Air Forces"=>43,
 "Pan American World Airways"=>41,
 "American Airlines"=>36} 

Dig

results.aggregations.dig(:top_names, :fatalities)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions