# Facet with an async search

**URL:** <https://discuss.elastic.co/t/facet-with-an-async-search/8140>\
**Category:** Elasticsearch\
**Created:** [June 18, 2012, 8:05am UTC](https://discuss.elastic.co/t/facet-with-an-async-search/8140 "2012-06-18T08:05:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![komaln](https://avatars.discourse-cdn.com/v4/letter/k/8797f3/32.png) [@komaln](https://discuss.elastic.co/u/komaln)\
**Post date:** [June 18, 2012, 8:05am UTC](https://discuss.elastic.co/t/facet-with-an-async-search/8140/1 "2012-06-18T08:05:58Z")

</div>

I am aware of how using the facet feature of elasticsearch, we can get the  
aggregated value of values for a specified field/s based on search query  
result data.

I have an application where I am monitoring logs and using elasticsearch to  
search through the log entries. On UI front I have a paging mechanism in  
place and hence using async feature of the search to fetch 'n' entries at a  
time.

So my question is, if I modify my async search query to fetch the facet  
information for certain fields, will it give the aggregated value for the  
sub-set of result that is fetched as a result of an async query. or will it  
get the aggregated value for the entire search result (and not the sub-set  
which is returned to user).

Many thanks and regards,  
Komal

---

<div class="post-metadata">

**Author:** ![andym](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@andym](https://discuss.elastic.co/u/andym)\
**Post date:** [June 18, 2012, 11:22pm UTC](https://discuss.elastic.co/t/facet-with-an-async-search/8140/2 "2012-06-18T23:22:17Z")

</div>

Hi Komal,

Let me make sure I understand your question correctly -- you have a  
search query which returns N results, and you page through it M  
results per page.

If you modify the original query to add facets, it will return  
aggregated data for all N results (as opposed to M results displayed  
to the user at a time)

-- Andy

On Jun 18, 1:05 am, Komal [komal.nawan...@gmail.com](mailto:komal.nawan...@gmail.com) wrote:

> I am aware of how using the facet feature of elasticsearch, we can get the  
> aggregated value of values for a specified field/s based on search query  
> result data.
> 
> I have an application where I am monitoring logs and using elasticsearch to  
> search through the log entries. On UI front I have a paging mechanism in  
> place and hence using async feature of the search to fetch 'n' entries at a  
> time.
> 
> So my question is, if I modify my async search query to fetch the facet  
> information for certain fields, will it give the aggregated value for the  
> sub-set of result that is fetched as a result of an async query. or will it  
> get the aggregated value for the entire search result (and not the sub-set  
> which is returned to user).
> 
> Many thanks and regards,  
> Komal

---

<div class="post-metadata">

**Author:** ![komaln](https://avatars.discourse-cdn.com/v4/letter/k/8797f3/32.png) [@komaln](https://discuss.elastic.co/u/komaln)\
**Post date:** [June 19, 2012, 7:52am UTC](https://discuss.elastic.co/t/facet-with-an-async-search/8140/3 "2012-06-19T07:52:40Z")

</div>

Hi Andy,

Yes thats what I meant. I am getting the results in chunks using the scroll  
[http://www.elasticsearch.org/guide/reference/api/search/scroll.html](http://www.elasticsearch.org/guide/reference/api/search/scroll.html)feature  
of elasticsearch.  
Even I experimented and saw that we always get facet for entire result set.

Many thanks!  
Komal.

On Tuesday, June 19, 2012 4:52:17 AM UTC+5:30, andym wrote:

> Hi Komal,
> 
> Let me make sure I understand your question correctly -- you have a  
> search query which returns N results, and you page through it M  
> results per page.
> 
> If you modify the original query to add facets, it will return  
> aggregated data for all N results (as opposed to M results displayed  
> to the user at a time)
> 
> -- Andy
> 
> On Jun 18, 1:05 am, Komal [komal.nawan...@gmail.com](mailto:komal.nawan...@gmail.com) wrote:
> 
> > I am aware of how using the facet feature of elasticsearch, we can get  
> > the  
> > aggregated value of values for a specified field/s based on search query  
> > result data.
> > 
> > I have an application where I am monitoring logs and using elasticsearch  
> > to  
> > search through the log entries. On UI front I have a paging mechanism in  
> > place and hence using async feature of the search to fetch 'n' entries  
> > at a  
> > time.
> > 
> > So my question is, if I modify my async search query to fetch the facet  
> > information for certain fields, will it give the aggregated value for  
> > the  
> > sub-set of result that is fetched as a result of an async query. or will  
> > it  
> > get the aggregated value for the entire search result (and not the  
> > sub-set  
> > which is returned to user).
> > 
> > Many thanks and regards,  
> > Komal

---

<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:23am UTC](https://discuss.elastic.co/t/facet-with-an-async-search/8140/4 "2017-07-06T03:23:28Z")

</div>


