# Querying on nested arrays?

**URL:** <https://discuss.elastic.co/t/querying-on-nested-arrays/13300>\
**Category:** Elasticsearch\
**Created:** [August 22, 2013, 1:22pm UTC](https://discuss.elastic.co/t/querying-on-nested-arrays/13300 "2013-08-22T13:22:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dantuff](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@dantuff](https://discuss.elastic.co/u/dantuff)\
**Post date:** [August 22, 2013, 1:22pm UTC](https://discuss.elastic.co/t/querying-on-nested-arrays/13300/1 "2013-08-22T13:22:28Z")

</div>

I have an index that is made up of nested arrays, I have added an example  
document and mapping below. I would like to do a query within the nested  
array on one of the fields, here is my query:

{  
"query" : {  
"bool" : {  
"must" : {  
"terms" : {  
"chapter[0].images[0].href.last\_part\_of\_url" : ["\*"]  
}  
}  
}  
}  
}

The above query doesn't return anything, the I'm not sure if I am going  
about this in the right way. How can I do a query on the values that are  
indexed in the 'last\_part\_of\_url' field?

Document:

{  
"book":{  
"chapter": [{  
"id":"1",  
"name": "Part 1",  
"images":[{  
"href":"[http://somehost/somepath](http://somehost/somepath)",  
"type":"image/png"  
}]  
}],  
}  
}

Mapping:

{  
"book":{  
"chapter":{  
"properties":{  
"id":{  
"type": "string",  
"index": "analyzed"  
},  
"name":{  
"type": "string",  
"index": "analyzed"  
},  
"images":{  
"properties": {  
"href":{  
"type":"multi\_field",  
"fields":{  
"href":{  
"type": "string",  
"index": "analyzed"  
},  
"last\_part\_of\_url":{  
"type": "string",  
"analyzer": "some\_analyzer"  
}  
}  
}  
}  
}  
}  
}  
}  
}

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![sina\_tamanna](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@sina\_tamanna](https://discuss.elastic.co/u/sina_tamanna)\
**Post date:** [August 23, 2013, 6:56am UTC](https://discuss.elastic.co/t/querying-on-nested-arrays/13300/2 "2013-08-23T06:56:19Z")

</div>

Take a look at nested  
mapping: [http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)  
and nested  
query: [http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:20am UTC](https://discuss.elastic.co/t/querying-on-nested-arrays/13300/3 "2017-07-06T02:20:02Z")

</div>


