# Retrieve objects from arrays using the fields syntax

**URL:** <https://discuss.elastic.co/t/retrieve-objects-from-arrays-using-the-fields-syntax/5360>\
**Category:** Elasticsearch\
**Created:** [September 12, 2011, 4:28pm UTC](https://discuss.elastic.co/t/retrieve-objects-from-arrays-using-the-fields-syntax/5360 "2011-09-12T16:28:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felix\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felix_s/32/2933_2.png) [@Felix\_S](https://discuss.elastic.co/u/Felix_S)\
**Post date:** [September 12, 2011, 4:28pm UTC](https://discuss.elastic.co/t/retrieve-objects-from-arrays-using-the-fields-syntax/5360/1 "2011-09-12T16:28:49Z")

</div>

Hi!

I have a number of objects nested into an array (though not of type  
nested); i'm using IndexRequestBuilder.addField() to retrieve certain  
fields together with the search results. This works perfectly well  
when specifying an array of, say, plain strings, i'm getting an array  
of strings back.  
However, on an array filled with objects, nothing at all is being  
returned, even if the array contains but one object and I'm specifying  
the path to some string-typed field of the object itself (e.g.  
"my\_array.some\_object\_field") - why is that? is there any way to work  
around this?

Thanks!

Felix

---

<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:** [September 12, 2011, 11:44pm UTC](https://discuss.elastic.co/t/retrieve-objects-from-arrays-using-the-fields-syntax/5360/2 "2011-09-12T23:44:45Z")

</div>

Can you prefix it with \_source? Something like:  
\_source.my\_array.some\_object\_field?

On Mon, Sep 12, 2011 at 7:28 PM, Felix Sappelt [f.sappelt@clueda.com](mailto:f.sappelt@clueda.com) wrote:

> Hi!
> 
> I have a number of objects nested into an array (though not of type  
> nested); i'm using IndexRequestBuilder.addField() to retrieve certain  
> fields together with the search results. This works perfectly well  
> when specifying an array of, say, plain strings, i'm getting an array  
> of strings back.  
> However, on an array filled with objects, nothing at all is being  
> returned, even if the array contains but one object and I'm specifying  
> the path to some string-typed field of the object itself (e.g.  
> "my\_array.some\_object\_field") - why is that? is there any way to work  
> around this?
> 
> Thanks!
> 
> Felix

---

<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:54am UTC](https://discuss.elastic.co/t/retrieve-objects-from-arrays-using-the-fields-syntax/5360/3 "2017-07-06T03:54:38Z")

</div>


