Comparing two fields of the same document, where one of the fields is inside a nested document

Consider the following document:

"group" : "fans",
"preferredFanId" : 1,
"user" : [
"fanId" : 1,
"first" : "John",
"last" : "Smith"
"fanId" : 2,
"first" : "Alice",
"last" : "White"

where "user" is a nested document. I want to get inner_hits (from
2.0.0-SNAPSHOT) where preferredFanId == user.fanId , and so I want only the
John Smith record returned in the inner_hits. Is it possible? I've tried
several approaches like using "include_in_parent" or "_source", but nothing
seems to work.

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
To view this discussion on the web visit
For more options, visit