# Filtering in nested results

**URL:** <https://discuss.elastic.co/t/filtering-in-nested-results/164500>\
**Category:** Elasticsearch\
**Created:** [January 16, 2019, 4:14pm UTC](https://discuss.elastic.co/t/filtering-in-nested-results/164500 "2019-01-16T16:14:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nils\_Nilsson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nils_nilsson/32/39850_2.png) [@Nils\_Nilsson](https://discuss.elastic.co/u/Nils_Nilsson)\
**Post date:** [January 16, 2019, 4:14pm UTC](https://discuss.elastic.co/t/filtering-in-nested-results/164500/1 "2019-01-16T16:14:03Z")

</div>

I'm quite new to this, but so far I love it. Here's the issue where I'm stuck at.

I have a type Product which has many colors.

I'm making a regular search for Product.name and the result might look like this

Product =\> [  
'name' =\> 'The Product',  
'Color' =\> [  
[  
'id' =\> 13,  
'name' =\> 'Red'  
],  
[  
'id' =\> 14,  
'name' =\> 'Blue  
]  
]  
]

However, sometimes I filter among the colors. So I only want blue products. Fair enough, I get the same result. However, I would like for the Color nest only to contain the blue object (or put it on top, whichever is less time consuming). So, removing all other colors leaving the array as below. Is this possible in a search query way?

Product =\> [  
'name' =\> 'The Product',  
'Color' =\> [  
[  
'id' =\> 14,  
'name' =\> 'Blue  
]  
]  
]

---

<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:** [February 13, 2019, 4:14pm UTC](https://discuss.elastic.co/t/filtering-in-nested-results/164500/2 "2019-02-13T16:14:06Z")

</div>

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