# Facets and doing some filtering based on facets

**URL:** <https://discuss.elastic.co/t/facets-and-doing-some-filtering-based-on-facets/226429>\
**Category:** Elasticsearch\
**Created:** [April 3, 2020, 3:20pm UTC](https://discuss.elastic.co/t/facets-and-doing-some-filtering-based-on-facets/226429 "2020-04-03T15:20:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lalit\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lalit_kumar/32/48738_2.png) [@Lalit\_Kumar](https://discuss.elastic.co/u/Lalit_Kumar)\
**Post date:** [April 3, 2020, 3:20pm UTC](https://discuss.elastic.co/t/facets-and-doing-some-filtering-based-on-facets/226429/1 "2020-04-03T15:20:39Z")

</div>

I have a question about facets and doing some filtering based on facets.  
i know this is a repeated question but i am unable find the answer.

i would like to know how can i implement the same functionality in elastic search.

lets asume that I have an index about cars and some facets -- eg. model and  
color.

**color**

red (10)

blue (5)

green (2)

**model**

bmw (4)

vw (5)

ford (8)

if I select a model I would like to get only color facets for that model,  
but I still would like to get facets for all models. eg:

**color**

red (2)

blue (2)

green (1)

**model**

bmw (4)

vw (5)

ford (8)

I have searched I did not find an example about this use-case. Is this  
possible and if yes, how do I filter a query to get these results?

Kind regards

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 6, 2020, 2:19pm UTC](https://discuss.elastic.co/t/facets-and-doing-some-filtering-based-on-facets/226429/2 "2020-04-06T14:19:58Z")

</div>

Hey,

this means a more complex query for your aggregations. Basically you need to keep your query the same (to return the documents for `Vw` as model`), but the aggregation for model cannot have such a filter, where the aggregation for color has to to have that one. Basically each aggregation needs a different filter, which excludes its own filter (for the model agg, you cannot filter by model, but by all other criterias).

hope this helps!

---

<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:** [May 4, 2020, 2:20pm UTC](https://discuss.elastic.co/t/facets-and-doing-some-filtering-based-on-facets/226429/3 "2020-05-04T14:20:01Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
