Im working on implementing searchkick in my project and got the search to work fine. Now Im trying to implement a filter system and use the aggs to display the filter criteria. The array that the aggs returns is a little complex for me and trying to figure out how to cycle through the specific parts. Heres the aggs it returns:
{"techniques"=>{"doc_count_error_upper_bound"=>0, "sum_other_doc_count"=>0, "buckets"=>[{"key"=>"Frying", "doc_count"=>1}, {"key"=>"Searing", "doc_count"=>1}]}, "ingredients"=>{"doc_count_error_upper_bound"=>0, "sum_other_doc_count"=>0, "buckets"=>[{"key"=>"Furikake, for serving", "doc_count"=>1}, {"key"=>"Kosher salt and ground black pepper", "doc_count"=>1}, {"key"=>"Salmon fillets", "doc_count"=>1}, {"key"=>"avocado, diced", "doc_count"=>1}, {"key"=>"cooked white rice", "doc_count"=>1}, {"key"=>"japanese cucumber", "doc_count"=>1}, {"key"=>"teriyaki sauce", "doc_count"=>1}, {"key"=>"to 8 scallions, thinly sliced", "doc_count"=>1}, {"key"=>"vegetable oil", "doc_count"=>1}]}, "cuisines"=>{"doc_count_error_upper_bound"=>0, "sum_other_doc_count"=>0, "buckets"=>[{"key"=>"Asian", "doc_count"=>1}, {"key"=>"Japanese", "doc_count"=>1}]}}
How would I write a do loop to cycle through just the cuisines part and pull out the individual names and counts from the buckets:
"cuisines"=>{"doc_count_error_upper_bound"=>0, "sum_other_doc_count"=>0, "buckets"=>[{"key"=>"Asian", "doc_count"=>1}, {"key"=>"Japanese", "doc_count"=>1}]}}
So basically I want a list that would look like this: Asian(1) Japanese(1)