Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Results::Aggregations wrapper #55

Open
esmarkowski opened this issue Mar 10, 2024 · 0 comments
Open

Add Results::Aggregations wrapper #55

esmarkowski opened this issue Mar 10, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@esmarkowski
Copy link
Member

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)
@esmarkowski esmarkowski added the enhancement New feature or request label Mar 10, 2024
@esmarkowski esmarkowski added this to the v0.6.0 milestone Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant