missing-aggregation.asciidoc 937 B

12345678910111213141516171819202122232425262728293031323334
  1. [[java-aggs-bucket-missing]]
  2. ==== Missing Aggregation
  3. Here is how you can use
  4. {ref}/search-aggregations-bucket-missing-aggregation.html[Missing 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.missing("agg").field("gender");
  11. --------------------------------------------------
  12. ===== Use aggregation response
  13. Import Aggregation definition classes:
  14. [source,java]
  15. --------------------------------------------------
  16. import org.elasticsearch.search.aggregations.bucket.missing.Missing;
  17. --------------------------------------------------
  18. [source,java]
  19. --------------------------------------------------
  20. // sr is here your SearchResponse object
  21. Missing agg = sr.getAggregations().get("agg");
  22. agg.getDocCount(); // Doc count
  23. --------------------------------------------------