# Aggregates, facets, filters, buckets

**URL:** <https://discuss.elastic.co/t/aggregates-facets-filters-buckets/20924>\
**Category:** Elasticsearch\
**Created:** [November 25, 2014, 12:03am UTC](https://discuss.elastic.co/t/aggregates-facets-filters-buckets/20924 "2014-11-25T00:03:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toni\_Alfirevic](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@Toni\_Alfirevic](https://discuss.elastic.co/u/Toni_Alfirevic)\
**Post date:** [November 25, 2014, 12:03am UTC](https://discuss.elastic.co/t/aggregates-facets-filters-buckets/20924/1 "2014-11-25T00:03:51Z")

</div>

Hi,  
I can't seem to wrap my head around all the concepts mentioned so I'll  
start by explaining my setup and goal.

- Elasticsearch 1.4.x
- 4 indices. Fairy small (couple of thousand documents in each). Lets  
call them "Books", "Users", "Novels", "Poems"
- NEST client library 1.2.3

Goal is pretty simple: search across those 4 indices in one request and  
somehow group results documents by type.  
What a end user would like to see is (paginated) list of all documents, and  
user should be able to "filter" (consider this a generic concept,  
not necessarily a ES filter).  
Even more specific... Imagine a search result web page with 5 filters  
"All", "Books", "Users", "Novels", "Poems".

I've been fiddling around a lot with aggregates/facets and I can't seem to  
get the result I want.

Closest thing was adding aggregate by type to my  
query .Aggregations(ag=\>ag.Terms("types",t=\>t.Field("\_type")))

In the response I get aggregate "types", and for each item in types it says  
how many documents are there (great!)... "only" thing is, at this point I  
don't know how to /get/ those documents by facet key.

It's probably not the way I should go about this problem, so please do  
point me to the right direction... Give me a mock query, suggestion,  
anything...

Cheers,  
T.

--  
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/e751efc6-c2bd-42cd-a03e-8d552a583133%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e751efc6-c2bd-42cd-a03e-8d552a583133%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:47am UTC](https://discuss.elastic.co/t/aggregates-facets-filters-buckets/20924/2 "2017-07-06T00:47:56Z")

</div>


