- Java Transport Client (deprecated): other versions:
- Preface
- Maven Repository
- Dealing with JAR dependency conflicts
- Embedding jar with dependencies
- Deploying in JBoss EAP6 module
- Client
- Document APIs
- Search API
- Count API
- Aggregations
- Percolate API
- Query DSL
- Indexed Scripts API
- Java API Administration
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Count API
editCount API
editDeprecated in 2.1.0.
Use the search
api instead and set size
to 0
The count API allows one to easily execute a query and get the number of matches for that query. It can be executed across one or more indices and across one or more types. The query can be provided using the Query DSL.
import static org.elasticsearch.index.query.QueryBuilders.*; CountResponse response = client.prepareCount("test") .setQuery(termQuery("_type", "type1")) .execute() .actionGet();
For more information on the count operation, check out the REST count docs.
Was this helpful?
Thank you for your feedback.