Elasticsearch nested query issue

Hey folks,

I am playing with Elasticsearch nested query and see some issue, can someone please help me explain it.

ES version: 0.20.5 (same behavior in 0.19.5 as well)

The steps to reproduce are here

The question in short is, let say I am indexing a nested field as in

"nested_field" : [ { "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 } ]

when I _search using nested query as

curl -XGET http://localhost:9200/newindex/foo/_search?pretty=true -d

'{ "query" : {"nested" : { "path" : "nested_field", "query": { "query_string": { "query": "name:blue AND count:4" }}}}}'

I am expecting to get back only matching child part for the nested field as in { "name" : "blue", "count" : 4 }

But I get back both as in

"nested_field" : [ { "name" : "blue", "count" : 4 }, { "name" : "green", "count" : 6 } ] (The part with "name": "green" should not show up in my mind)

Best