# Boost not working as expected in bool query

**URL:** <https://discuss.elastic.co/t/boost-not-working-as-expected-in-bool-query/5042>\
**Category:** Elasticsearch\
**Created:** [August 3, 2011, 10:46am UTC](https://discuss.elastic.co/t/boost-not-working-as-expected-in-bool-query/5042 "2011-08-03T10:46:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mattcollins84](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@mattcollins84](https://discuss.elastic.co/u/mattcollins84)\
**Post date:** [August 3, 2011, 10:46am UTC](https://discuss.elastic.co/t/boost-not-working-as-expected-in-bool-query/5042/1 "2011-08-03T10:46:41Z")

</div>

Hi,

I am trying to run a bool query with a single "must" query and several "should" queries.

Each of the "should" queries are "term" queries and have a different boost applied to them, however I am not getting the output I would expect.

Here is my query:  
{  
"query" : {  
"bool" : {  
"must" : {  
"term" : { "locations" : 1 }  
},  
"should" : [  
{  
"term" : { "tags" : { "value":1, "boost":10 } }  
},  
{  
"term" : { "categories" : { "value":"c1", "boost":5 } }  
}  
],  
"minimum\_number\_should\_match" : 1  
}  
}  
}

I would expect that this query would return in the following order:

- all documents where locations contains 1, tags contains 1, categories contains "c1"
- all documents where locations contains 1, tags contains 1
- all documents where locations contains 1, categories contains "c1"

But what I am getting is:

- all documents where locations contains 1, tags contains 1, categories contains "c1" (score of ~10)
- all documents where locations contains 1, categories contains "c1" (score of ~7)
- all documents where locations contains 1, tags contains 1 (score of ~0.5) \<--- this seems really weird

I feel like I am missing something obvious, but am a bit of an ES novice - please help!

Here is my mapping:

curl -XPUT [http://localhost:9200/goat/simple/\_mapping](http://localhost:9200/goat/simple/_mapping) -d'  
{  
"simple" : {  
"properties" : {  
"name" : {"type" : "string"},  
"locations" : {"type" : "integer"},  
"categories" : {"type" : "string"},  
"tags" : {"type" : "integer"},  
"sortcode" : {"type" : "integer"},  
"isCustomer" : {"type" : "boolean"}  
}  
}  
}'

Here is my sample data:

curl -XPUT [http://localhost:9200/goat/simple/1](http://localhost:9200/goat/simple/1) -d'{"name":"First Business","locations":[1],"categories":["c1"],"tags":[1],"sortcode":100,"isCustomer" :true}'  
curl -XPUT [http://localhost:9200/goat/simple/2](http://localhost:9200/goat/simple/2) -d'{"name":"Second Business","locations":[1],"categories":["c1"],"tags":[],"sortcode":100,"isCustomer" :true}'  
curl -XPUT [http://localhost:9200/goat/simple/3](http://localhost:9200/goat/simple/3) -d'{"name":"Third Business","locations":[1],"categories":[],"tags":[1],"sortcode":100,"isCustomer" :true}'  
curl -XPUT [http://localhost:9200/goat/simple/4](http://localhost:9200/goat/simple/4) -d'{"name":"Fourth Business","locations":[1,2],"categories":["c1"],"tags":[1],"sortcode":200,"isCustomer" :true}'  
curl -XPUT [http://localhost:9200/goat/simple/5](http://localhost:9200/goat/simple/5) -d'{"name":"Fifth Business","locations":[1,2],"categories":["c1"],"tags":[],"sortcode":200,"isCustomer" :true}'  
curl -XPUT [http://localhost:9200/goat/simple/6](http://localhost:9200/goat/simple/6) -d'{"name":"Sixth Business","locations":[1,2],"categories":[],"tags":[1],"sortcode":200,"isCustomer" :true}'  
curl -XPUT [http://localhost:9200/goat/simple/7](http://localhost:9200/goat/simple/7) -d'{"name":"Seventh Business","locations":[1,2,3],"categories":["c1"],"tags":[1],"sortcode":400,"isCustomer" :false}'  
curl -XPUT [http://localhost:9200/goat/simple/8](http://localhost:9200/goat/simple/8) -d'{"name":"Eighth Business","locations":[1,2,3],"categories":["c1"],"tags":[],"sortcode":400,"isCustomer" :false}'  
curl -XPUT [http://localhost:9200/goat/simple/9](http://localhost:9200/goat/simple/9) -d'{"name":"Ninth Business","locations":[1,2,3],"categories":[],"tags":[1],"sortcode":400,"isCustomer" :false}'

Thanks in advance!  
Matt

---

<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, 3:58am UTC](https://discuss.elastic.co/t/boost-not-working-as-expected-in-bool-query/5042/2 "2017-07-06T03:58:23Z")

</div>


