| 1234567891011121314151617181920212223242526272829303132333435363738 | [[count]]== Count APIThe count API allows to easily execute a query and get the number ofmatches for that query. It can be executed across one or more indicesand across one or more types. The query can be provided using the{ref}/query-dsl.html[Query DSL].[source,java]--------------------------------------------------import static org.elasticsearch.index.query.xcontent.FilterBuilders.*;import static org.elasticsearch.index.query.xcontent.QueryBuilders.*;CountResponse response = client.prepareCount("test")        .setQuery(termQuery("_type", "type1"))        .execute()        .actionGet();--------------------------------------------------For more information on the count operation, check out the REST{ref}/search-count.html[count] docs.=== Operation ThreadingThe count API allows to set the threading model the operation will beperformed when the actual execution of the API is performed on the samenode (the API is executed on a shard that is allocated on the sameserver).There are three threading modes.The `NO_THREADS` mode means that thecount operation will be executed on the calling thread. The`SINGLE_THREAD` mode means that the count operation will be executed ona single different thread for all local shards. The `THREAD_PER_SHARD`mode means that the count operation will be executed on a differentthread for each local shard.The default mode is `SINGLE_THREAD`.
 |