# Capping boost given by custom\_filters\_score

**URL:** https://discuss.elastic.co/t/capping-boost-given-by-custom-filters-score/7748
**Category:** Elasticsearch
**Created:** [May 17, 2012, 5:28pm UTC](https://discuss.elastic.co/t/capping-boost-given-by-custom-filters-score/7748 "2012-05-17T17:28:27Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Frederick\_Cheung](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frederick_cheung/32/1874_2.png) [@Frederick\_Cheung](https://discuss.elastic.co/u/Frederick_Cheung)
#### Post date: [May 17, 2012, 5:28pm UTC](https://discuss.elastic.co/t/capping-boost-given-by-custom-filters-score/7748/1 "2012-05-17T17:28:27Z")

</div>

I'm using custom\_filters\_score to boost documents that match one or  
more filters. Documents matching more of those filters should receive  
a larger boost, but only up to a point.

For example a document matching 1 filters might get a boost of 1.2,  
one matching 2 filters a boost of 1.44 but a document matching 3  
filters would be capped at 1.44 (rather than 1.2 \*1.44).  
I can't find anything that looks like it might do that but I'd love to  
be proved wrong. Failing that would a custom\_filters\_score option  
along the lines of max\_boost be of interest ? If so pointers to where  
to start digging in the source gratefully accepted!

Thanks,

Fred

---

<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: [May 20, 2012, 8:03pm UTC](https://discuss.elastic.co/t/capping-boost-given-by-custom-filters-score/7748/2 "2012-05-20T20:03:26Z")

</div>

Heya, it definitely make sense, and should not be too difficult to add. The  
custom\_filters\_score parse exists here:  
[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryParser.java](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/java/org/elasticsearch/index/query/CustomFiltersScoreQueryParser.java),  
you will need to add a parsing element for the max\_score. Then, you will  
need to change FiltersFunctionScore to allow to pass that max score and use  
it in the computation there. If you run into problems, just ping.

On Thu, May 17, 2012 at 7:28 PM, Frederick Cheung \<  
[frederick.cheung@gmail.com](mailto:frederick.cheung@gmail.com)\> wrote:

> I'm using custom\_filters\_score to boost documents that match one or  
> more filters. Documents matching more of those filters should receive  
> a larger boost, but only up to a point.
> 
> For example a document matching 1 filters might get a boost of 1.2,  
> one matching 2 filters a boost of 1.44 but a document matching 3  
> filters would be capped at 1.44 (rather than 1.2 \*1.44).  
> I can't find anything that looks like it might do that but I'd love to  
> be proved wrong. Failing that would a custom\_filters\_score option  
> along the lines of max\_boost be of interest ? If so pointers to where  
> to start digging in the source gratefully accepted!
> 
> Thanks,
> 
> Fred

---

<div class="post-metadata">

### Author: ![Frederick\_Cheung](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frederick_cheung/32/1874_2.png) [@Frederick\_Cheung](https://discuss.elastic.co/u/Frederick_Cheung)
#### Post date: [May 21, 2012, 9:36am UTC](https://discuss.elastic.co/t/capping-boost-given-by-custom-filters-score/7748/3 "2012-05-21T09:36:39Z")

</div>

On May 20, 9:03 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Heya, it definitely make sense, and should not be too difficult to add. The  
> custom\_filters\_score parse exists here:[https://github.com/elasticsearch/elasticsearch/blob/master/src/main/j](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/j)...,  
> you will need to add a parsing element for the max\_score. Then, you will  
> need to change FiltersFunctionScore to allow to pass that max score and use  
> it in the computation there. If you run into problems, just ping.

Cool. I'll have a root around in there. Thanks!

Fred.

> On Thu, May 17, 2012 at 7:28 PM, Frederick Cheung \<
> 
> [frederick.che...@gmail.com](mailto:frederick.che...@gmail.com)\> wrote:
> 
> > I'm using custom\_filters\_score to boost documents that match one or  
> > more filters. Documents matching more of those filters should receive  
> > a larger boost, but only up to a point.
> 
> > For example a document matching 1 filters might get a boost of 1.2,  
> > one matching 2 filters a boost of 1.44 but a document matching 3  
> > filters would be capped at 1.44 (rather than 1.2 \*1.44).  
> > I can't find anything that looks like it might do that but I'd love to  
> > be proved wrong. Failing that would a custom\_filters\_score option  
> > along the lines of max\_boost be of interest ? If so pointers to where  
> > to start digging in the source gratefully accepted!
> 
> > Thanks,
> 
> > Fred

---

<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: [May 23, 2012, 9:33pm UTC](https://discuss.elastic.co/t/capping-boost-given-by-custom-filters-score/7748/4 "2012-05-23T21:33:13Z")

</div>

Opened an issue: [Query DSL: Add max\_boost to custom\_filters\_score to cap boosting · Issue #1973 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1973),  
might hack it if I get some time...

On Mon, May 21, 2012 at 11:36 AM, Frederick Cheung \<  
[frederick.cheung@gmail.com](mailto:frederick.cheung@gmail.com)\> wrote:

> On May 20, 9:03 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > Heya, it definitely make sense, and should not be too difficult to add.  
> > The  
> > custom\_filters\_score parse exists here:  
> > [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/j](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/j)...,  
> > you will need to add a parsing element for the max\_score. Then, you will  
> > need to change FiltersFunctionScore to allow to pass that max score and  
> > use  
> > it in the computation there. If you run into problems, just ping.
> 
> Cool. I'll have a root around in there. Thanks!
> 
> Fred.
> 
> > On Thu, May 17, 2012 at 7:28 PM, Frederick Cheung \<
> > 
> > [frederick.che...@gmail.com](mailto:frederick.che...@gmail.com)\> wrote:
> > 
> > > I'm using custom\_filters\_score to boost documents that match one or  
> > > more filters. Documents matching more of those filters should receive  
> > > a larger boost, but only up to a point.
> > 
> > > For example a document matching 1 filters might get a boost of 1.2,  
> > > one matching 2 filters a boost of 1.44 but a document matching 3  
> > > filters would be capped at 1.44 (rather than 1.2 \*1.44).  
> > > I can't find anything that looks like it might do that but I'd love to  
> > > be proved wrong. Failing that would a custom\_filters\_score option  
> > > along the lines of max\_boost be of interest ? If so pointers to where  
> > > to start digging in the source gratefully accepted!
> > 
> > > Thanks,
> > 
> > > Fred

---

<div class="post-metadata">

### Author: ![Frederick\_Cheung](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/frederick_cheung/32/1874_2.png) [@Frederick\_Cheung](https://discuss.elastic.co/u/Frederick_Cheung)
#### Post date: [May 24, 2012, 9:36am UTC](https://discuss.elastic.co/t/capping-boost-given-by-custom-filters-score/7748/5 "2012-05-24T09:36:26Z")

</div>

On May 23, 10:33 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Opened an issue:[Query DSL: Add max\_boost to custom\_filters\_score to cap boosting · Issue #1973 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1973),  
> might hack it if I get some time...

You beat me to it ! Good to see that what you ended up was basically  
what I was doing!  
Thanks.

Fred

> On Mon, May 21, 2012 at 11:36 AM, Frederick Cheung \<
> 
> [frederick.che...@gmail.com](mailto:frederick.che...@gmail.com)\> wrote:
> 
> > On May 20, 9:03 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > Heya, it definitely make sense, and should not be too difficult to add.  
> > > The  
> > > custom\_filters\_score parse exists here:  
> > > [https://github.com/elasticsearch/elasticsearch/blob/master/src/main/j](https://github.com/elasticsearch/elasticsearch/blob/master/src/main/j)...,  
> > > you will need to add a parsing element for the max\_score. Then, you will  
> > > need to change FiltersFunctionScore to allow to pass that max score and  
> > > use  
> > > it in the computation there. If you run into problems, just ping.
> 
> > Cool. I'll have a root around in there. Thanks!
> 
> > Fred.
> > 
> > > On Thu, May 17, 2012 at 7:28 PM, Frederick Cheung \<
> 
> > > [frederick.che...@gmail.com](mailto:frederick.che...@gmail.com)\> wrote:
> > > 
> > > > I'm using custom\_filters\_score to boost documents that match one or  
> > > > more filters. Documents matching more of those filters should receive  
> > > > a larger boost, but only up to a point.
> 
> > > > For example a document matching 1 filters might get a boost of 1.2,  
> > > > one matching 2 filters a boost of 1.44 but a document matching 3  
> > > > filters would be capped at 1.44 (rather than 1.2 \*1.44).  
> > > > I can't find anything that looks like it might do that but I'd love to  
> > > > be proved wrong. Failing that would a custom\_filters\_score option  
> > > > along the lines of max\_boost be of interest ? If so pointers to where  
> > > > to start digging in the source gratefully accepted!
> 
> > > > Thanks,
> 
> > > > Fred

---

<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:27am UTC](https://discuss.elastic.co/t/capping-boost-given-by-custom-filters-score/7748/6 "2017-07-06T03:27:18Z")

</div>


