# Aggs like Amazon

**URL:** https://discuss.elastic.co/t/aggs-like-amazon/36111
**Category:** Elasticsearch
**Created:** [December 2, 2015, 1:19am UTC](https://discuss.elastic.co/t/aggs-like-amazon/36111 "2015-12-02T01:19:09Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![diego.bernardes](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@diego.bernardes](https://discuss.elastic.co/u/diego.bernardes)
#### Post date: [December 2, 2015, 1:19am UTC](https://discuss.elastic.co/t/aggs-like-amazon/36111/1 "2015-12-02T01:19:09Z")

</div>

If we go to Amazon and search for **tablet** we get a list of tablets and on the left of screen we get facets to filter the query, like this:

[http://imgur.com/9BM0Bpg](http://imgur.com/9BM0Bpg)

I know how to do facets (aggs) on elasticsearch, but looking at the results, seems that Amazon is doing a first query with a single aggs on category, and than it take the top categories and do another query with the custom aggs from categories.

The question is, can i do this with only one query or i need always to perform two queries? One to get the categories and another to get the aggs?

---

<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 5, 2017, 11:34pm UTC](https://discuss.elastic.co/t/aggs-like-amazon/36111/2 "2017-07-05T23:34:18Z")

</div>


