# Struggling with understand how to add boost if a field is true

**URL:** https://discuss.elastic.co/t/struggling-with-understand-how-to-add-boost-if-a-field-is-true/7101
**Category:** Elasticsearch
**Created:** [March 22, 2012, 8:55pm UTC](https://discuss.elastic.co/t/struggling-with-understand-how-to-add-boost-if-a-field-is-true/7101 "2012-03-22T20:55:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Scott\_Reynolds](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/scott_reynolds/32/2945_2.png) [@Scott\_Reynolds](https://discuss.elastic.co/u/Scott_Reynolds)
#### Post date: [March 22, 2012, 8:55pm UTC](https://discuss.elastic.co/t/struggling-with-understand-how-to-add-boost-if-a-field-is-true/7101/1 "2012-03-22T20:55:19Z")

</div>

I have a set of documents that have a field user\_verified that is either  
true or false. When executing a disjunction max query I want documents  
where the user\_verified is true to be given a boost.

I thought the answer was constant\_score, but I have really failed to figure  
out how to make this work. I am missing something fundmental. Here is the  
php code that creates a QueryDSL

> <https://gist.github.com/SupermanScott/2164332>

I have tried a bunch of combinations and have really failed to figure it  
out. Any help would be greatly appreciated.

Thanks,  
Scott

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [March 25, 2012, 11:39am UTC](https://discuss.elastic.co/t/struggling-with-understand-how-to-add-boost-if-a-field-is-true/7101/2 "2012-03-25T11:39:44Z")

</div>

Maybe custom\_filters\_score will do the trick?  
[http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/custom-filters-score-query.html).  
Wrap your query with it, and add a filter on the boolean field, if its  
true, you can adjust the score in this case.

On Thu, Mar 22, 2012 at 10:55 PM, Scott Reynolds [sdrreynolds@gmail.com](mailto:sdrreynolds@gmail.com)wrote:

> I have a set of documents that have a field user\_verified that is either  
> true or false. When executing a disjunction max query I want documents  
> where the user\_verified is true to be given a boost.
> 
> I thought the answer was constant\_score, but I have really failed to  
> figure out how to make this work. I am missing something fundmental. Here  
> is the php code that creates a QueryDSL
> 
> [gist:2164332 · GitHub](https://gist.github.com/2164332)
> 
> I have tried a bunch of combinations and have really failed to figure it  
> out. Any help would be greatly appreciated.
> 
> Thanks,  
> Scott

---

<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:34am UTC](https://discuss.elastic.co/t/struggling-with-understand-how-to-add-boost-if-a-field-is-true/7101/3 "2017-07-06T03:34:55Z")

</div>


