Retrieve objects from arrays using the fields syntax


(Felix S.) #1

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


(Shay Banon) #2

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


(system) #3