# Performing several count queries using polling. is there a better way?

**URL:** <https://discuss.elastic.co/t/performing-several-count-queries-using-polling-is-there-a-better-way/7252>\
**Category:** Elasticsearch\
**Created:** [April 6, 2012, 3:44pm UTC](https://discuss.elastic.co/t/performing-several-count-queries-using-polling-is-there-a-better-way/7252 "2012-04-06T15:44:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shane\_Witbeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shane_witbeck/32/2803_2.png) [@Shane\_Witbeck](https://discuss.elastic.co/u/Shane_Witbeck)\
**Post date:** [April 6, 2012, 3:44pm UTC](https://discuss.elastic.co/t/performing-several-count-queries-using-polling-is-there-a-better-way/7252/1 "2012-04-06T15:44:20Z")

</div>

I'm in the process of putting together a web-based dashboard which polls  
and does several count queries based on searches using several fields. Is  
there a more efficient way to do this?

Specifically, is there a way to consolidate the calls to just one call?

I'm also interested if someone has done something similar using websockets  
instead of polling?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 6, 2012, 3:52pm UTC](https://discuss.elastic.co/t/performing-several-count-queries-using-polling-is-there-a-better-way/7252/2 "2012-04-06T15:52:51Z")

</div>

Hi Shane,

Facetting could help you. See

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

[http://www.elasticsearch.org/blog/2011/05/13/data-visualization-with-elasticsearch-and-protovis.html](http://www.elasticsearch.org/blog/2011/05/13/data-visualization-with-elasticsearch-and-protovis.html)  
and

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

[http://www.elasticsearch.org/guide/reference/api/search/facets/index.html](http://www.elasticsearch.org/guide/reference/api/search/facets/index.html)

HTH  
David.

Le 6 avril 2012 à 17:44, Shane Witbeck [shane@digitalsanctum.com](mailto:shane@digitalsanctum.com) a écrit :

> together a web-based dashboard which polls and does several count queries  
> based on searches using several fields. Is there a more efficient way to do  
> this?
> 
> Specifically, is there a way to consolidate the calls to just one call?
> 
> I'm also interested if someone has done something similar using websockets  
> instead of polling?

--  
David Pilato  
[http://dev.david.pilato.fr/](http://dev.david.pilato.fr/)  
Twitter : @dadoonet

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 7, 2012, 3:29pm UTC](https://discuss.elastic.co/t/performing-several-count-queries-using-polling-is-there-a-better-way/7252/3 "2012-04-07T15:29:51Z")

</div>

You can have a single search request running several global scoped facet  
filter to provide counts. Another option is multi search API. With both you  
should use the search\_type set to count. Websockets do not seem relevant  
to this discussion (unless I am missing something).

On Fri, Apr 6, 2012 at 6:44 PM, Shane Witbeck [shane@digitalsanctum.com](mailto:shane@digitalsanctum.com)wrote:

> I'm in the process of putting together a web-based dashboard which polls  
> and does several count queries based on searches using several fields. Is  
> there a more efficient way to do this?
> 
> Specifically, is there a way to consolidate the calls to just one call?
> 
> I'm also interested if someone has done something similar using websockets  
> instead of polling?

---

<div class="post-metadata">

**Author:** ![Shane\_Witbeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shane_witbeck/32/2803_2.png) [@Shane\_Witbeck](https://discuss.elastic.co/u/Shane_Witbeck)\
**Post date:** [April 7, 2012, 5:47pm UTC](https://discuss.elastic.co/t/performing-several-count-queries-using-polling-is-there-a-better-way/7252/4 "2012-04-07T17:47:21Z")

</div>

Thanks to you both for the replies. Always helpful.

I'm still relatively new to ES and haven't used facets or multi search API  
yet but it seems now is my opportunity.

I guess I was thinking that Websockets might be an alternative to several  
clients polling ES for the various count queries. Certain application  
events already trigger re-indexing or deleting of documents and could just  
as easily trigger the count queries.

Thanks again,  
Shane

On Sat, Apr 7, 2012 at 11:29 AM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> You can have a single search request running several global scoped facet  
> filter to provide counts. Another option is multi search API. With both you  
> should use the search\_type set to count. Websockets do not seem relevant  
> to this discussion (unless I am missing something).
> 
> On Fri, Apr 6, 2012 at 6:44 PM, Shane Witbeck [shane@digitalsanctum.com](mailto:shane@digitalsanctum.com)wrote:
> 
> > I'm in the process of putting together a web-based dashboard which polls  
> > and does several count queries based on searches using several fields. Is  
> > there a more efficient way to do this?
> > 
> > Specifically, is there a way to consolidate the calls to just one call?
> > 
> > I'm also interested if someone has done something similar using  
> > websockets instead of polling?

--  
-Shane

---

<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, 3:33am UTC](https://discuss.elastic.co/t/performing-several-count-queries-using-polling-is-there-a-better-way/7252/5 "2017-07-06T03:33:20Z")

</div>


