# ES Count Query Help

**URL:** <https://discuss.elastic.co/t/es-count-query-help/22928>\
**Category:** Elasticsearch\
**Created:** [March 26, 2015, 6:08pm UTC](https://discuss.elastic.co/t/es-count-query-help/22928 "2015-03-26T18:08:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stang07](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@stang07](https://discuss.elastic.co/u/stang07)\
**Post date:** [March 26, 2015, 6:08pm UTC](https://discuss.elastic.co/t/es-count-query-help/22928/1 "2015-03-26T18:08:35Z")

</div>

Friends,

I am trying to query ES _every minute_ for count. I have the following  
code. I am having tough time adding the _time filter._ Looks like lot has  
changed since 1.1.0 java elasticsearch api. Can you point me to the right  
directions?

Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name",  
"test").build();  
Client esClient = new TransportClient(settings).addTransportAddress(new  
InetSocketTransportAddress("myhostname", port));

//FieldQueryBuilder hotelQuery=QueryBuilders.fieldQuery("prodName","Air");

CountResponse cr = esClient.prepareCount("test").setIndices("myindex").  
setQuery(termQuery("\_type","mytype")).execute().actionGet();

System.out.println(cr.getCount());

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/281b53a3-da04-48a2-a90a-05198931df73%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/281b53a3-da04-48a2-a90a-05198931df73%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:23am UTC](https://discuss.elastic.co/t/es-count-query-help/22928/2 "2017-07-06T00:23:37Z")

</div>

Closed on July 6, 2017, 12:23am UTC


