Possible to use boolean on both nested and container doc fields?

Is it possible to perform a boolean filter on fields in a nested document as well as its container document? Can I use _parent in that situation?

I've been trying something similar to the following with no luck. If I only check the nested doc's properties, it is successful, however.

"nested": {
"path": "nestedObj",
"query": {
"match_all": {}
},
"filter": {
"bool": {
"should" : [
{"term" : {"fieldname" : "value1"}},
{"term" : {"_parent.fieldname" : "value2"}}
]
}
}
}

Thanks,
Chris

You can't do a filter on a "parent" within a nested element, but, you can
combine a non nested filter and a nested one (or query).

On Thu, Dec 8, 2011 at 5:37 AM, Schnyder <
chris.schnyder@cardinal-holdings.com> wrote:

Is it possible to perform a boolean filter on fields in a nested document
as
well as its container document? Can I use _parent in that situation?

I've been trying something similar to the following with no luck. If I
only
check the nested doc's properties, it is successful, however.

"nested": {
"path": "nestedObj",
"query": {
"match_all": {}
},
"filter": {
"bool": {
"should" : [
{"term" : {"fieldname" : "value1"}},
{"term" : {"_parent.fieldname" : "value2"}}
]
}
}
}

Thanks,
Chris

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Possible-to-use-boolean-on-both-nested-and-container-doc-fields-tp3569323p3569323.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

Thanks Shay, but I need to do an "or" operation on these two fields (one
field from the parent, and one field from the nested child). I don't think
your solution would allow that, if I understand you correctly.

You can do an or between a nested query on that nested field, and a parent
query on that parent field, no?

On Sat, Dec 10, 2011 at 2:01 AM, Schnyder chris.schnyder@gmail.com wrote:

Thanks Shay, but I need to do an "or" operation on these two fields (one
field from the parent, and one field from the nested child). I don't think
your solution would allow that, if I understand you correctly.