# How to implement query termsAgregation to get the documents for each of the buckets that the query generates. I am using java spring boot

**URL:** <https://discuss.elastic.co/t/how-to-implement-query-termsagregation-to-get-the-documents-for-each-of-the-buckets-that-the-query-generates-i-am-using-java-spring-boot/313883>\
**Category:** Elasticsearch\
**Created:** [September 7, 2022, 12:31pm UTC](https://discuss.elastic.co/t/how-to-implement-query-termsagregation-to-get-the-documents-for-each-of-the-buckets-that-the-query-generates-i-am-using-java-spring-boot/313883 "2022-09-07T12:31:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ernesto\_Rodolfo\_Cast](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ernesto_rodolfo_cast/32/99049_2.png) [@Ernesto\_Rodolfo\_Cast](https://discuss.elastic.co/u/Ernesto_Rodolfo_Cast)\
**Post date:** [September 7, 2022, 12:31pm UTC](https://discuss.elastic.co/t/how-to-implement-query-termsagregation-to-get-the-documents-for-each-of-the-buckets-that-the-query-generates-i-am-using-java-spring-boot/313883/1 "2022-09-07T12:31:05Z")

</div>

Hi, I am trying to get each of the elements that the elasticsearch group by generates. What I get now is the key and the amount of elements for each of the buckets, my interest is to get each of those elements that contain the buckets.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 5, 2022, 12:32pm UTC](https://discuss.elastic.co/t/how-to-implement-query-termsagregation-to-get-the-documents-for-each-of-the-buckets-that-the-query-generates-i-am-using-java-spring-boot/313883/2 "2022-10-05T12:32:04Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
