# Tricky Query nested json array

**URL:** https://discuss.elastic.co/t/tricky-query-nested-json-array/14610
**Category:** Elasticsearch
**Created:** [November 27, 2013, 9:07am UTC](https://discuss.elastic.co/t/tricky-query-nested-json-array/14610 "2013-11-27T09:07:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)
#### Post date: [November 27, 2013, 9:07am UTC](https://discuss.elastic.co/t/tricky-query-nested-json-array/14610/1 "2013-11-27T09:07:29Z")

</div>

My data:

```
    name: Abc College
    rankingList: [
        {
            value: 8
            key: Academic 
        }
        {
            value: 8
            key: career
        }
    ]

```

I Need all the college with Academic \> 8  
My query

"query": {  
"bool": {  
"must": [  
{  
"match": {  
"rankingList.key": "Academic"  
}  
},  
{  
"match": {  
"rankingList.value": 9  
}  
}  
]  
}  
}

But this query give all the data has Academic and 9 in rankingList but not  
that has Academic whose value is 8.

response

rankingList: [  
{  
value: 5  
key: Academic  
}  
{  
value: 8  
key: career  
}  
],  
rankingList: [  
{  
value: 8  
key: sports  
}  
{  
value: 5  
key: career  
}  
]

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/781c3fbf-3518-4443-90e4-c0cf8077c02d%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/781c3fbf-3518-4443-90e4-c0cf8077c02d%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)
#### Post date: [November 27, 2013, 9:47am UTC](https://discuss.elastic.co/t/tricky-query-nested-json-array/14610/2 "2013-11-27T09:47:37Z")

</div>

On Wednesday, 27 November 2013 14:37:29 UTC+5:30, paul wrote:

> My data:
> 
> ```
> name: Abc College
> rankingList: [
> {
> value: 8
> key: Academic 
> }
> {
> value: 8
> key: career
> }
> ]
> 
> ```
> 
> I Need all the college with Academic \> 8  
> My query
> 
> "query": {  
> "bool": {  
> "must": [  
> {  
> "match": {  
> "rankingList.key": "Academic"  
> }  
> },  
> {  
> "match": {  
> "rankingList.value": 9  
> }  
> }  
> ]  
> }  
> }
> 
> But this query give all the data has Academic and 9 in rankingList but not  
> that has Academic whose value is 8.
> 
> response
> 
> rankingList: [  
> {  
> value: 5  
> key: Academic  
> }  
> {  
> value: 8  
> key: career  
> }  
> ],  
> rankingList: [  
> {  
> value: 8  
> key: sports  
> }  
> {  
> value: 5  
> key: career  
> }  
> ]

Got the answer at

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6cf0760f-baf4-478a-81e3-37510fe15ce0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6cf0760f-baf4-478a-81e3-37510fe15ce0%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:04am UTC](https://discuss.elastic.co/t/tricky-query-nested-json-array/14610/3 "2017-07-06T02:04:38Z")

</div>


