# Not able to pass multiple term in bool query

**URL:** <https://discuss.elastic.co/t/not-able-to-pass-multiple-term-in-bool-query/16401>\
**Category:** Elasticsearch\
**Created:** [March 17, 2014, 9:21am UTC](https://discuss.elastic.co/t/not-able-to-pass-multiple-term-in-bool-query/16401 "2014-03-17T09:21:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [March 17, 2014, 9:21am UTC](https://discuss.elastic.co/t/not-able-to-pass-multiple-term-in-bool-query/16401/1 "2014-03-17T09:21:15Z")

</div>

Hi,

I'm trying to make a bool query where sending mutiple term under should  
block as given in link  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

But I'm getting SearchPhaseExecutionException while trying to execute below  
query. Please inform what is the correct way to send the query

POST /aricloud/\_search  
{  
"query": {  
"filtered": {  
"query": {  
"bool": {  
"must": [  
{  
"range": {  
"NODE\_CATEGORY\_ID": {  
"gte": 10,  
"lte": 20,  
"boost": 2.0  
}  
}  
}  
] ,  
"must\_not": [  
{  
"term": {  
"NODE\_ID": {  
"value": "12235"  
}  
}  
}  
],  
"should": [  
{  
"term": {  
"NODE\_PRIVATE\_IP\_ADDRESS": {  
"value": "10.123.124.40"  
}  
},  
"term": {  
"NODE\_PUBLIC\_IP\_ADDRESS": {  
"value": "125.31.108.72"  
}  
}  
}  
}  
]  
}  
},  
"filter": {  
"range": {  
"NODE\_CREATE\_TIME": {  
"from": "2014-03-14 16:22:35",  
"to": "2014-03-14 22:43:55"  
}  
}  
}  
}  
},  
"sort": [  
{  
"NODE\_ID": {  
"order": "asc"  
}  
}  
]  
}

--  
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/fb6b4846-7ceb-4046-a17b-c33de4d7bc79%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fb6b4846-7ceb-4046-a17b-c33de4d7bc79%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 17, 2014, 9:24am UTC](https://discuss.elastic.co/t/not-able-to-pass-multiple-term-in-bool-query/16401/2 "2014-03-17T09:24:10Z")

</div>

I just tried to copy and paste your JSON in: [http://jsonformatter.curiousconcept.com/](http://jsonformatter.curiousconcept.com/)  
I get

Error:Expecting comma or ], not }.[Code 6, Structure 86]  
Error:Expecting comma or }, not ].[Code 7, Structure 87]  
Error:Multiple JSON root elements[Code 22, Structure 115]  
Error:Extra closing }[Code 14, Structure 126]  
I think you should fix your JSON and check that it's correct before sending it to elasticsearch

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 17 mars 2014 à 10:21:20, Subhadip Bagui ([i.bagui@gmail.com](mailto:i.bagui@gmail.com)) a écrit:

Hi,

I'm trying to make a bool query where sending mutiple term under should block as given in link [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

But I'm getting SearchPhaseExecutionException while trying to execute below query. Please inform what is the correct way to send the query

POST /aricloud/\_search  
{  
"query": {  
"filtered": {  
"query": {  
"bool": {  
"must": [  
{  
"range": {  
"NODE\_CATEGORY\_ID": {  
"gte": 10,  
"lte": 20,  
"boost": 2.0  
}  
}  
}  
] ,  
"must\_not": [  
{  
"term": {  
"NODE\_ID": {  
"value": "12235"  
}  
}  
}  
],  
"should": [  
{  
"term": {  
"NODE\_PRIVATE\_IP\_ADDRESS": {  
"value": "10.123.124.40"  
}  
},  
"term": {  
"NODE\_PUBLIC\_IP\_ADDRESS": {  
"value": "125.31.108.72"  
}  
}  
}  
}  
]  
}  
},  
"filter": {  
"range": {  
"NODE\_CREATE\_TIME": {  
"from": "2014-03-14 16:22:35",  
"to": "2014-03-14 22:43:55"  
}  
}  
}  
}  
},  
"sort": [  
{  
"NODE\_ID": {  
"order": "asc"  
}  
}  
]  
}

--  
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/fb6b4846-7ceb-4046-a17b-c33de4d7bc79%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fb6b4846-7ceb-4046-a17b-c33de4d7bc79%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/etPan.5326bf3a.7724c67e.1ccf%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.5326bf3a.7724c67e.1ccf%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [March 17, 2014, 10:19am UTC](https://discuss.elastic.co/t/not-able-to-pass-multiple-term-in-bool-query/16401/3 "2014-03-17T10:19:28Z")

</div>

My mistake!! the json format was wrong. tried below and it's working fine.

Thanks David

> {  
> "query": {  
> "filtered": {  
> "query": {  
> "bool": {  
> "must": [  
> {  
> "range": {  
> "NODE\_CATEGORY\_ID": {  
> "gte": 10,  
> "lte": 20,  
> "boost": 2  
> }  
> }  
> }  
> ],  
> "must\_not": [  
> {  
> "term": {  
> "NODE\_ID": {  
> "value": "12235"  
> }  
> }  
> }  
> ],  
> "should": [  
> {  
> "term": {  
> "NODE\_PRIVATE\_IP\_ADDRESS": {  
> "value": "10.123.124.125"  
> }  
> }  
> },  
> {  
> "term": {  
> "NODE\_PUBLIC\_IP\_ADDRESS": {  
> "value": "125.31.108.82"  
> }  
> }  
> }  
> ]  
> }  
> },  
> "filter": {  
> "range": {  
> "NODE\_CREATE\_TIME": {  
> "from": "2014-03-14 16:22:35",  
> "to": "2014-03-14 22:43:55"  
> }  
> }  
> }  
> }  
> },  
> "sort": [  
> {  
> "NODE\_ID": {  
> "order": "asc"  
> }  
> }  
> ]  
> }

--  
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/571c5fe8-3219-46fa-82f4-6d3456e09d07%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/571c5fe8-3219-46fa-82f4-6d3456e09d07%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 17, 2014, 5:56pm UTC](https://discuss.elastic.co/t/not-able-to-pass-multiple-term-in-bool-query/16401/4 "2014-03-17T17:56:57Z")

</div>

Can you show the full error message details?

--  
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/6329cba2-2f9a-431d-ad6f-c41d7af127c8%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6329cba2-2f9a-431d-ad6f-c41d7af127c8%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bagui](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bagui/32/960_2.png) [@bagui](https://discuss.elastic.co/u/bagui)\
**Post date:** [March 18, 2014, 3:48am UTC](https://discuss.elastic.co/t/not-able-to-pass-multiple-term-in-bool-query/16401/5 "2014-03-18T03:48:16Z")

</div>

Hi Binh,

I was an issue with json format creation. Now I validated the json and  
getting result.  
Thanks..

--  
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/19af3f5d-b17d-4f9f-863c-b10adaffe27f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/19af3f5d-b17d-4f9f-863c-b10adaffe27f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:42am UTC](https://discuss.elastic.co/t/not-able-to-pass-multiple-term-in-bool-query/16401/6 "2017-07-06T01:42:38Z")

</div>


