# Must filter on nested fields from different hierarchies

**URL:** <https://discuss.elastic.co/t/must-filter-on-nested-fields-from-different-hierarchies/23401>\
**Category:** Elasticsearch\
**Created:** [April 26, 2015, 3:32pm UTC](https://discuss.elastic.co/t/must-filter-on-nested-fields-from-different-hierarchies/23401 "2015-04-26T15:32:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edi\_Buslovich](https://avatars.discourse-cdn.com/v4/letter/e/43a26b/32.png) [@Edi\_Buslovich](https://discuss.elastic.co/u/Edi_Buslovich)\
**Post date:** [April 26, 2015, 3:32pm UTC](https://discuss.elastic.co/t/must-filter-on-nested-fields-from-different-hierarchies/23401/1 "2015-04-26T15:32:53Z")

</div>

Hello,

I have the following object in my index:  
{  
"user" : {  
"info" : {  
"fname" : "John",  
"lname" : "Stark"  
},  
"settings" : {  
"hide\_menu" : true,  
"time\_offset" : 3  
}  
},  
"views" : [  
]  
}

And I'd like to create a filter to find all the users whose first name is  
John and have time\_offset=3  
So I need to build a must filter, but the problem is that these 2 fields  
are nested on different hierarchies: user.info and user.settings

How can I make a must filter (AND) with both of them?

Thanks,  
Edi Buslovich.

--  
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/be0aaf35-212b-46a1-8430-21879881e147%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/be0aaf35-212b-46a1-8430-21879881e147%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Edi\_Buslovich](https://avatars.discourse-cdn.com/v4/letter/e/43a26b/32.png) [@Edi\_Buslovich](https://discuss.elastic.co/u/Edi_Buslovich)\
**Post date:** [April 27, 2015, 1:03pm UTC](https://discuss.elastic.co/t/must-filter-on-nested-fields-from-different-hierarchies/23401/2 "2015-04-27T13:03:56Z")

</div>

Was answered for me on stackoverflow:

> <https://stackoverflow.com/questions/29888492/how-to-make-a-query-with-a-must-filter-on-nested-fields-from-different-hierarchi>

Thanks.

On Sunday, April 26, 2015 at 6:32:53 PM UTC+3, Edi Buslovich wrote:

> Hello,
> 
> I have the following object in my index:  
> {  
> "user" : {  
> "info" : {  
> "fname" : "John",  
> "lname" : "Stark"  
> },  
> "settings" : {  
> "hide\_menu" : true,  
> "time\_offset" : 3  
> }  
> },  
> "views" : [  
> ]  
> }
> 
> And I'd like to create a filter to find all the users whose first name is  
> John and have time\_offset=3  
> So I need to build a must filter, but the problem is that these 2 fields  
> are nested on different hierarchies: user.info and user.settings
> 
> How can I make a must filter (AND) with both of them?
> 
> Thanks,  
> Edi Buslovich.

--  
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/606d4082-9845-4b01-ad2c-761678bf398e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/606d4082-9845-4b01-ad2c-761678bf398e%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:17am UTC](https://discuss.elastic.co/t/must-filter-on-nested-fields-from-different-hierarchies/23401/3 "2017-07-06T00:17:35Z")

</div>


