# Why my bool query is not working?

**URL:** <https://discuss.elastic.co/t/why-my-bool-query-is-not-working/7291>\
**Category:** Elasticsearch\
**Created:** [April 11, 2012, 10:31am UTC](https://discuss.elastic.co/t/why-my-bool-query-is-not-working/7291 "2012-04-11T10:31:45Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sumit\_Guptaa](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Sumit\_Guptaa](https://discuss.elastic.co/u/Sumit_Guptaa)\
**Post date:** [April 11, 2012, 10:31am UTC](https://discuss.elastic.co/t/why-my-bool-query-is-not-working/7291/1 "2012-04-11T10:31:45Z")

</div>

Hi all,

curl -XGET '[http://localhost:9200/amazon/book/\_search](http://localhost:9200/amazon/book/_search)' -d '{  
"query":  
{  
"bool" :  
{  
"must" :[  
{"term":{"name":"call"}},  
{"range":{"pages":{"from":200,"to":300}}}  
],  
"must\_not": [  
{"term":{"book.author.first\_name":"jack"}}  
],  
"should": [  
{"term":{"book.author.last\_name":"london"}}  
]

```
                            }
                    }
}

```

}'

In this query i am getting SearchphaseExecutionException....

Regards,  
Sumit Gupta

---

<div class="post-metadata">

**Author:** ![Radu\_Gheorghe1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe1/32/2688_2.png) [@Radu\_Gheorghe1](https://discuss.elastic.co/u/Radu_Gheorghe1)\
**Post date:** [April 12, 2012, 6:38am UTC](https://discuss.elastic.co/t/why-my-bool-query-is-not-working/7291/2 "2012-04-12T06:38:52Z")

</div>

Hi Sumit,

I don't know if that's it, but you have an extra "}" in the end.

On Apr 11, 1:31 pm, Sumit Guptaa [sumit.gupta....@gmail.com](mailto:sumit.gupta....@gmail.com) wrote:

> Hi all,
> 
> curl -XGET '[http://localhost:9200/amazon/book/\_search'-d](http://localhost:9200/amazon/book/_search'-d) '{  
> "query":  
> {  
> "bool" :  
> {  
> "must" :[  
> {"term":{"name":"call"}},
> 
> {"range":{"pages":{"from":200,"to":300}}}  
> ],  
> "must\_not": [
> 
> {"term":{"book.author.first\_name":"jack"}}  
> ],  
> "should": [
> 
> {"term":{"book.author.last\_name":"london"}}  
> ]
> 
> ```
> }
> }
> }
> 
> ```
> 
> }'
> 
> In this query i am getting SearchphaseExecutionException....
> 
> Regards,  
> Sumit Gupta
> 
> --  
> View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/why-my-bool-query-is-](http://elasticsearch-users.115913.n3.nabble.com/why-my-bool-query-is-)...  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Sumit\_Guptaa](https://avatars.discourse-cdn.com/v4/letter/s/e8c25b/32.png) [@Sumit\_Guptaa](https://discuss.elastic.co/u/Sumit_Guptaa)\
**Post date:** [April 12, 2012, 8:38am UTC](https://discuss.elastic.co/t/why-my-bool-query-is-not-working/7291/3 "2012-04-12T08:38:17Z")

</div>

Hi Radhu,

auxuly this is not the adject reason because i check it many time...so please give me adject reason...

thanx..

Rgds,  
Sumit Gupta

---

<div class="post-metadata">

**Author:** ![Radu\_Gheorghe1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe1/32/2688_2.png) [@Radu\_Gheorghe1](https://discuss.elastic.co/u/Radu_Gheorghe1)\
**Post date:** [April 14, 2012, 4:24pm UTC](https://discuss.elastic.co/t/why-my-bool-query-is-not-working/7291/4 "2012-04-14T16:24:40Z")

</div>

Hi Sumit,

I don't know at this point, really. I've tried that query and I didn't  
get any exception.

Can you post here some more details on your setup? Mapping,  
configuration...

On Apr 12, 10:38 am, Sumit Guptaa [sumit.gupta....@gmail.com](mailto:sumit.gupta....@gmail.com) wrote:

> Hi Radhu,
> 
> auxuly this is not the adject reason because i check it many time...so  
> please give me adject reason...
> 
> thanx..
> 
> Rgds,  
> Sumit Gupta
> 
> --  
> View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/why-my-bool-query-is-](http://elasticsearch-users.115913.n3.nabble.com/why-my-bool-query-is-)...  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Gabriel\_Mirea](https://avatars.discourse-cdn.com/v4/letter/g/ee59a6/32.png) [@Gabriel\_Mirea](https://discuss.elastic.co/u/Gabriel_Mirea)\
**Post date:** [February 1, 2013, 11:15am UTC](https://discuss.elastic.co/t/why-my-bool-query-is-not-working/7291/5 "2013-02-01T11:15:17Z")

</div>

Salut Radu,  
Can you please help me?  
I have a jdbc river installed in my elasticsearch-0.20.3.

And the following mapping:

{  
"mappings":{  
"car" : {  
"properties" : {  
"engineType" : {"type" : "string", "index" : "not\_analyzed"},  
"price" : {"type" : "integer"},  
"mileage" : {"type" : "integer"},  
}  
}  
},  
"settings":{  
"analysis":{  
"filter":{  
"snowball": {  
"type": "snowball",  
"language": "French"  
}  
},  
"analyzer":{  
"my\_analyzer":{  
"filter":[  
"standard",  
"lowercase",  
"asciifolding"  
],  
"type":"custom",  
"tokenizer":"standard"  
}  
}  
}  
}  
}

I'm trying to fetch all the cars that has bellow 10000 Km as mileage with a  
bool query and a range fecet:

{  
"query": {  
"bool": {  
"must": {  
"range": {  
"mileAge": {  
"from": "1",  
"to": "10000"  
}  
}  
}  
}  
}  
}

But infortunatelly it does'nt find any documents the result is: {

- took: 5
- timed\_out: false
- \_shards: {
  - total: 6
  - successful: 6
  - failed: 0  
}

- hits: {
  - total: 0
  - max\_score: null
  - hits: []  
}

}  
Can you please provide a hint regarding what is wrong?

Multam fain,  
Gabriel

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [February 1, 2013, 2:22pm UTC](https://discuss.elastic.co/t/why-my-bool-query-is-not-working/7291/6 "2013-02-01T14:22:21Z")

</div>

Salut Gabriel! 🙂

The problem might come from writing "mileAge" instead of "mileage" in the  
query. It's case-sensitive.

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Fri, Feb 1, 2013 at 1:15 PM, Gabriel Mirea [gmirea@sqli.com](mailto:gmirea@sqli.com) wrote:

> Salut Radu,  
> Can you please help me?  
> I have a jdbc river installed in my elasticsearch-0.20.3.
> 
> And the following mapping:
> 
> {  
> "mappings":{  
> "car" : {  
> "properties" : {  
> "engineType" : {"type" : "string", "index" : "not\_analyzed"},  
> "price" : {"type" : "integer"},  
> "mileage" : {"type" : "integer"},  
> }  
> }  
> },  
> "settings":{  
> "analysis":{  
> "filter":{  
> "snowball": {  
> "type": "snowball",  
> "language": "French"  
> }  
> },  
> "analyzer":{  
> "my\_analyzer":{  
> "filter":[  
> "standard",  
> "lowercase",  
> "asciifolding"  
> ],  
> "type":"custom",  
> "tokenizer":"standard"  
> }  
> }  
> }  
> }  
> }
> 
> I'm trying to fetch all the cars that has bellow 10000 Km as mileage with  
> a bool query and a range fecet:
> 
> {  
> "query": {  
> "bool": {  
> "must": {  
> "range": {  
> "mileAge": {  
> "from": "1",  
> "to": "10000"  
> }  
> }  
> }  
> }  
> }  
> }
> 
> But infortunatelly it does'nt find any documents the result is: {
> 
> - took: 5
> - timed\_out: false
> - \_shards: {
> - total: 6
> - successful: 6
> - failed: 0  
> }
> 
> - hits: {
> - total: 0
> - max\_score: null
> - hits:   
> }
> 
> }  
> Can you please provide a hint regarding what is wrong?
> 
> Multam fain,  
> Gabriel
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
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:53am UTC](https://discuss.elastic.co/t/why-my-bool-query-is-not-working/7291/7 "2017-07-06T02:53:33Z")

</div>


