# Query Syntax for arrays and nested objects

**URL:** <https://discuss.elastic.co/t/query-syntax-for-arrays-and-nested-objects/2817>\
**Category:** Elasticsearch\
**Created:** [February 17, 2010, 7:57am UTC](https://discuss.elastic.co/t/query-syntax-for-arrays-and-nested-objects/2817 "2010-02-17T07:57:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eugeis](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@eugeis](https://discuss.elastic.co/u/eugeis)\
**Post date:** [February 17, 2010, 7:57am UTC](https://discuss.elastic.co/t/query-syntax-for-arrays-and-nested-objects/2817/1 "2010-02-17T07:57:42Z")

</div>

Hello,

how can Isearch in array type, e.g. I want to search by "name" field  
of "lists" array

$ curl -XGET [http://localhost:9200/\_search?q=user.lists.name:prog\*](http://localhost:9200/_search?q=user.lists.name:prog*)

{  
tweet : {  
message : "some arrays in this tweet...",  
tags : ["elasticsearch", "wow"],  
lists : [  
{  
name : "progList",  
description : "programming list"  
},  
{  
name : "coolList",  
description : "cool stuff list"  
}  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![eugeis](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@eugeis](https://discuss.elastic.co/u/eugeis)\
**Post date:** [February 17, 2010, 8:02am UTC](https://discuss.elastic.co/t/query-syntax-for-arrays-and-nested-objects/2817/2 "2010-02-17T08:02:08Z")

</div>

And same question for nested objects

e.g. $ curl -XGET [http://localhost:9200/twitter/tweet/\_search?q=person.name:Sh](http://localhost:9200/twitter/tweet/_search?q=person.name:Sh)\*

{  
tweet {  
person : {  
name : {  
firstName : "Shay",  
lastName : "Banon"  
},  
sid : "12345"  
},  
message : "This is a tweet!"  
}  
}

On 17 Feb., 08:57, eugeis [eoeis...@googlemail.com](mailto:eoeis...@googlemail.com) wrote:

> Hello,
> 
> how can Isearch in array type, e.g. I want to search by "name" field  
> of "lists" array
> 
> $ curl -XGEThttp://localhost:9200/\_search?q=user.lists.name:prog\*
> 
> {  
> tweet : {  
> message : "some arrays in this tweet...",  
> tags : ["elasticsearch", "wow"],  
> lists : [  
> {  
> name : "progList",  
> description : "programming list"  
> },  
> {  
> name : "coolList",  
> description : "cool stuff list"  
> }  
> ]  
> }
> 
> }

---

<div class="post-metadata">

**Author:** ![eugeis](https://avatars.discourse-cdn.com/v4/letter/e/278dde/32.png) [@eugeis](https://discuss.elastic.co/u/eugeis)\
**Post date:** [February 17, 2010, 8:03am UTC](https://discuss.elastic.co/t/query-syntax-for-arrays-and-nested-objects/2817/3 "2010-02-17T08:03:28Z")

</div>

Exists an "all" field like in compass?

Thank You

On 17 Feb., 09:02, eugeis [eoeis...@googlemail.com](mailto:eoeis...@googlemail.com) wrote:

> And same question for nested objects
> 
> e.g. $ curl -XGEThttp://localhost:9200/twitter/tweet/\_search?q=person.name:Sh\*
> 
> {  
> tweet {  
> person : {  
> name : {  
> firstName : "Shay",  
> lastName : "Banon"  
> },  
> sid : "12345"  
> },  
> message : "This is a tweet!"  
> }
> 
> }
> 
> On 17 Feb., 08:57, eugeis [eoeis...@googlemail.com](mailto:eoeis...@googlemail.com) wrote:
> 
> > Hello,
> 
> > how can Isearch in array type, e.g. I want to search by "name" field  
> > of "lists" array
> 
> > $ curl -XGEThttp://localhost:9200/\_search?q=user.lists.name:prog\*
> 
> > {  
> > tweet : {  
> > message : "some arrays in this tweet...",  
> > tags : ["elasticsearch", "wow"],  
> > lists : [  
> > {  
> > name : "progList",  
> > description : "programming list"  
> > },  
> > {  
> > name : "coolList",  
> > description : "cool stuff list"  
> > }  
> > ]  
> > }
> 
> > }

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 17, 2010, 1:50pm UTC](https://discuss.elastic.co/t/query-syntax-for-arrays-and-nested-objects/2817/4 "2010-02-17T13:50:00Z")

</div>

There isn't an all field as in Compass, though there will be one in the  
future (a bit more tricky to implement it with recent Lucene efficiently).

But, elasticsearch is agnostic to arrays (as in Compass), so you can have:  
tweet.person.name.firstName:Shay, or person.name.firstName:Shay. With  
arrays, you can have tweet.tags:wow (it will match on either values). I  
explain it a bit more here:  
[Your Data, Your Search | Elastic Blog](http://www.elasticsearch.com/blog/2010/02/12/yourdatayoursearch.html).

-shay.banon

On Wed, Feb 17, 2010 at 10:03 AM, eugeis [eoeisler@googlemail.com](mailto:eoeisler@googlemail.com) wrote:

> Exists an "all" field like in compass?
> 
> Thank You
> 
> On 17 Feb., 09:02, eugeis [eoeis...@googlemail.com](mailto:eoeis...@googlemail.com) wrote:
> 
> > And same question for nested objects
> > 
> > e.g. $ curl  
> > -XGEThttp://localhost:9200/twitter/tweet/\_search?q=person.name:Sh\*
> > 
> > {  
> > tweet {  
> > person : {  
> > name : {  
> > firstName : "Shay",  
> > lastName : "Banon"  
> > },  
> > sid : "12345"  
> > },  
> > message : "This is a tweet!"  
> > }
> > 
> > }
> > 
> > On 17 Feb., 08:57, eugeis [eoeis...@googlemail.com](mailto:eoeis...@googlemail.com) wrote:
> > 
> > > Hello,
> > 
> > > how can Isearch in array type, e.g. I want to search by "name" field  
> > > of "lists" array
> > 
> > > $ curl -XGEThttp://localhost:9200/\_search?q=user.lists.name:prog\*
> > 
> > > {  
> > > tweet : {  
> > > message : "some arrays in this tweet...",  
> > > tags : ["elasticsearch", "wow"],  
> > > lists : [  
> > > {  
> > > name : "progList",  
> > > description : "programming list"  
> > > },  
> > > {  
> > > name : "coolList",  
> > > description : "cool stuff list"  
> > > }  
> > > ]  
> > > }
> > 
> > > }

---

<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, 4:25am UTC](https://discuss.elastic.co/t/query-syntax-for-arrays-and-nested-objects/2817/5 "2017-07-06T04:25:40Z")

</div>


