# Getting different results while using bool query vs bool query with function score query

**URL:** <https://discuss.elastic.co/t/getting-different-results-while-using-bool-query-vs-bool-query-with-function-score-query/19476>\
**Category:** Elasticsearch\
**Created:** [August 26, 2014, 10:38pm UTC](https://discuss.elastic.co/t/getting-different-results-while-using-bool-query-vs-bool-query-with-function-score-query/19476 "2014-08-26T22:38:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![akshaysh](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@akshaysh](https://discuss.elastic.co/u/akshaysh)\
**Post date:** [August 26, 2014, 10:38pm UTC](https://discuss.elastic.co/t/getting-different-results-while-using-bool-query-vs-bool-query-with-function-score-query/19476/1 "2014-08-26T22:38:36Z")

</div>

I am trying to add a custom boost to the different should clauses in the bool query, but I am getting different number of results when I use the bool query with 2 should clauses containing 2 simple query string query vs a bool query with 2 should clauses with 2 function score query encapsulating the same simple query string queries.  
The following query returns me 2 results for my data set:  
{  
"query" : {  
"filtered" : {  
"query" : {  
"bool" : {  
"should" : [ {  
"simple\_query\_string" : {  
"query" : "128",  
"fields" : ["content.name\_enu.simple"]  
}  
}, {  
"simple\_query\_string" : {  
"query" : "128",  
"fields" : ["content.name\_enu.simple\_with\_numeric"]  
}  
} ]  
}  
},  
"filter" : {  
"bool" : {  
"must" : [ {  
"term" : {  
"securityInfo.securityType" : "open"  
}  
}, {  
"bool" : {  
"must" : [ {  
"term" : {  
"sourceId.sourceSystem" : "jmeter\_007971\_numeric"  
}  
}, {  
"term" : {  
"sourceId.type" : "file"  
}  
} ]  
}  
} ],  
"\_cache" : true  
}  
}  
}  
},  
"fields" : ["elementId", "sourceId.id", "sourceId.type", "sourceId.sourceSystem", "sourceVersion", "content.name\_enu"]  
}

Where as if I use the following query I get 5 results, same simple query strings but with function scores:  
{  
"query" : {  
"filtered" : {  
"query" : {  
"bool" : {  
"should" : [ {  
"function\_score" : {  
"query" : {  
"simple\_query\_string" : {  
"query" : "128",  
"fields" : ["content.name\_enu.simple"]  
}  
},  
"boost\_factor" : 1.5  
}  
}, {  
"function\_score" : {  
"query" : {  
"simple\_query\_string" : {  
"query" : "128",  
"fields" : ["content.name\_enu.simple\_with\_numeric"]  
}  
},  
"boost\_factor" : 2.5  
}  
} ]  
}  
},  
"filter" : {  
"bool" : {  
"must" : [ {  
"term" : {  
"securityInfo.securityType" : "open"  
}  
}, {  
"bool" : {  
"must" : [ {  
"term" : {  
"sourceId.sourceSystem" : "jmeter\_007971\_numeric"  
}  
}, {  
"term" : {  
"sourceId.type" : "file"  
}  
} ]  
}  
} ],  
"\_cache" : true  
}  
}  
}  
},  
"fields" : ["elementId", "sourceId.id", "sourceId.type", "sourceId.sourceSystem", "sourceVersion", "content.name\_enu"]  
}

From my understanding of how the should clause works I was expecting both the queries to return 5 results but I am not able to understand why the 1st query returns me 2 results for my data set. The "content.name\_enu.simple" uses a simple analyzer, whereas simple\_with\_numeric uses whitespace tokenizer and lowercase filter

---

<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:06am UTC](https://discuss.elastic.co/t/getting-different-results-while-using-bool-query-vs-bool-query-with-function-score-query/19476/2 "2017-07-06T01:06:13Z")

</div>


