# Filter facet values on another field

**URL:** <https://discuss.elastic.co/t/filter-facet-values-on-another-field/12405>\
**Category:** Elasticsearch\
**Created:** [June 13, 2013, 7:11pm UTC](https://discuss.elastic.co/t/filter-facet-values-on-another-field/12405 "2013-06-13T19:11:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ron](https://avatars.discourse-cdn.com/v4/letter/r/ecae2f/32.png) [@Ron](https://discuss.elastic.co/u/Ron)\
**Post date:** [June 13, 2013, 7:11pm UTC](https://discuss.elastic.co/t/filter-facet-values-on-another-field/12405/1 "2013-06-13T19:11:23Z")

</div>

Hi,

We store in arrays values with related flags. The following example stores  
if a book is available in a specific format (we need this format for the  
none ElasticSearch-part of our application):

{  
"formats" : [  
{ "name" : "paperback" , "available" : true },  
{ "name" : "hardcover" , "available" : false }  
]  
}

We want to create facets for "available formats" (would contain  
"paperback") and "unavailable formats" (would contain "hardcover"), i.e. if  
a "name" is included as a facet value depends on the field "available".

What's the best way to achieve this with ElasticSearch? Can we create a  
mapping which tells the indexer to add only "name" values into a field  
"available\_formats" if the related "available" value is true? Or would we  
have to do this separation already before the data is send to ElasticSearch?

Many thanks!

Ron

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:31am UTC](https://discuss.elastic.co/t/filter-facet-values-on-another-field/12405/2 "2017-07-06T02:31:21Z")

</div>


