Querying multiple properties of arrays of child items

{
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".

It sounds like you are looking for Nested Query

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".

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

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".