[[java-aggs-bucket-missing]]
==== Missing Aggregation

Here is how you can use
{ref}/search-aggregations-bucket-missing-aggregation.html[Missing Aggregation]
with Java API.


===== Prepare aggregation request

Here is an example on how to create the aggregation request:

[source,java]
--------------------------------------------------
AggregationBuilders.missing("agg").field("gender");
--------------------------------------------------


===== Use aggregation response

Import Aggregation definition classes:

[source,java]
--------------------------------------------------
import org.elasticsearch.search.aggregations.bucket.missing.Missing;
--------------------------------------------------

[source,java]
--------------------------------------------------
// sr is here your SearchResponse object
Missing agg = sr.getAggregations().get("agg");
agg.getDocCount(); // Doc count
--------------------------------------------------