nested-aggregation.asciidoc 941 B

123456789101112131415161718192021222324252627282930313233343536
  1. [[java-aggs-bucket-nested]]
  2. ==== Nested Aggregation
  3. Here is how you can use
  4. {ref}/search-aggregations-bucket-nested-aggregation.html[Nested Aggregation]
  5. with Java API.
  6. ===== Prepare aggregation request
  7. Here is an example on how to create the aggregation request:
  8. [source,java]
  9. --------------------------------------------------
  10. AggregationBuilders
  11. .nested("agg")
  12. .path("resellers");
  13. --------------------------------------------------
  14. ===== Use aggregation response
  15. Import Aggregation definition classes:
  16. [source,java]
  17. --------------------------------------------------
  18. import org.elasticsearch.search.aggregations.bucket.nested.Nested;
  19. --------------------------------------------------
  20. [source,java]
  21. --------------------------------------------------
  22. // sr is here your SearchResponse object
  23. Nested agg = sr.getAggregations().get("agg");
  24. agg.getDocCount(); // Doc count
  25. --------------------------------------------------