# Querying multiple properties of arrays of child items

**URL:** https://discuss.elastic.co/t/querying-multiple-properties-of-arrays-of-child-items/7434
**Category:** Elasticsearch
**Created:** [April 22, 2012, 8:19am UTC](https://discuss.elastic.co/t/querying-multiple-properties-of-arrays-of-child-items/7434 "2012-04-22T08:19:19Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Nathan\_Ridley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_ridley/32/2906_2.png) [@Nathan\_Ridley](https://discuss.elastic.co/u/Nathan_Ridley)
#### Post date: [April 22, 2012, 8:19am UTC](https://discuss.elastic.co/t/querying-multiple-properties-of-arrays-of-child-items/7434/1 "2012-04-22T08:19:19Z")

</div>

{  
foo: "bar",  
users: [  
{ "name": "john", "age": 25, "level": 3 },  
{ "name": "bob", "age": 28, "level": 2 },  
{ "name": "jane", "age": 32, "level": 1 },  
{ "name": "mary", "age": 18, "level": 4 }  
]  
}

Given a document structure such as the above, is possible to structure a  
query such that the parent document is only returned if it contains a child  
document matching a set of boolean criteria?

For example, I would want to run a query saying "search for documents  
containing a user who has age\>=25 and level\>=3".

---

<div class="post-metadata">

### Author: ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)
#### Post date: [April 23, 2012, 3:51pm UTC](https://discuss.elastic.co/t/querying-multiple-properties-of-arrays-of-child-items/7434/2 "2012-04-23T15:51:11Z")

</div>

It sounds like you are looking for Nested Query

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

On Sunday, April 22, 2012 4:19:19 AM UTC-4, Nathan Ridley wrote:

> {  
> foo: "bar",  
> users: [  
> { "name": "john", "age": 25, "level": 3 },  
> { "name": "bob", "age": 28, "level": 2 },  
> { "name": "jane", "age": 32, "level": 1 },  
> { "name": "mary", "age": 18, "level": 4 }  
> ]  
> }
> 
> Given a document structure such as the above, is possible to structure a  
> query such that the parent document is only returned if it contains a child  
> document matching a set of boolean criteria?
> 
> For example, I would want to run a query saying "search for documents  
> containing a user who has age\>=25 and level\>=3".

---

<div class="post-metadata">

### Author: ![Nathan\_Ridley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_ridley/32/2906_2.png) [@Nathan\_Ridley](https://discuss.elastic.co/u/Nathan_Ridley)
#### Post date: [April 23, 2012, 7:42pm UTC](https://discuss.elastic.co/t/querying-multiple-properties-of-arrays-of-child-items/7434/3 "2012-04-23T19:42:43Z")

</div>

Yep, cheers!

On Monday, April 23, 2012 4:51:11 PM UTC+1, Igor Motov wrote:

> It sounds like you are looking for Nested Query  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html)
> 
> On Sunday, April 22, 2012 4:19:19 AM UTC-4, Nathan Ridley wrote:
> 
> > {  
> > foo: "bar",  
> > users: [  
> > { "name": "john", "age": 25, "level": 3 },  
> > { "name": "bob", "age": 28, "level": 2 },  
> > { "name": "jane", "age": 32, "level": 1 },  
> > { "name": "mary", "age": 18, "level": 4 }  
> > ]  
> > }
> > 
> > Given a document structure such as the above, is possible to structure a  
> > query such that the parent document is only returned if it contains a child  
> > document matching a set of boolean criteria?
> > 
> > For example, I would want to run a query saying "search for documents  
> > containing a user who has age\>=25 and level\>=3".

---

<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, 3:31am UTC](https://discuss.elastic.co/t/querying-multiple-properties-of-arrays-of-child-items/7434/4 "2017-07-06T03:31:18Z")

</div>


