# Elasticsearch nested query issue

**URL:** <https://discuss.elastic.co/t/elasticsearch-nested-query-issue/10852>\
**Category:** Elasticsearch\
**Created:** [February 22, 2013, 2:48am UTC](https://discuss.elastic.co/t/elasticsearch-nested-query-issue/10852 "2013-02-22T02:48:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhupesh](https://avatars.discourse-cdn.com/v4/letter/b/e274bd/32.png) [@bhupesh](https://discuss.elastic.co/u/bhupesh)\
**Post date:** [February 22, 2013, 2:48am UTC](https://discuss.elastic.co/t/elasticsearch-nested-query-issue/10852/1 "2013-02-22T02:48:52Z")

</div>

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

> <https://gist.github.com/bbansal/5010329>

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

---

<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, 2:50am UTC](https://discuss.elastic.co/t/elasticsearch-nested-query-issue/10852/2 "2017-07-06T02:50:08Z")

</div>


