# Filter facet values on another field

**URL:** <https://discuss.elastic.co/t/filter-facet-values-on-another-field/12398>\
**Category:** Elasticsearch\
**Created:** [June 13, 2013, 3:10pm UTC](https://discuss.elastic.co/t/filter-facet-values-on-another-field/12398 "2013-06-13T15:10:05Z")\
**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, 3:10pm UTC](https://discuss.elastic.co/t/filter-facet-values-on-another-field/12398/1 "2013-06-13T15:10:05Z")

</div>

Hi,

We have arrays that contain a flag next to the value, e.g. to store the  
availability of each book format (we need to store the raw data in this  
particular format):

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

We would like to create facets "Available format" (which would contain only  
"paperback") and "Unavailable format" (which would only contain  
"hardcover").

What's the best approach to create these facets in ElasticSearch? For  
example: Could we define in the mapping that only format names should be  
included in the index "available\_formats" if the flag "available" is true  
for this particular format? Or do we need to split this out already before  
entering the data into 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/12398/2 "2017-07-06T02:31:25Z")

</div>


