# Using a score threshold

**URL:** https://discuss.elastic.co/t/using-a-score-threshold/3963
**Category:** Elasticsearch
**Created:** [February 22, 2011, 9:52pm UTC](https://discuss.elastic.co/t/using-a-score-threshold/3963 "2011-02-22T21:52:06Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Rossini](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Rossini](https://discuss.elastic.co/u/Rossini)
#### Post date: [February 22, 2011, 9:52pm UTC](https://discuss.elastic.co/t/using-a-score-threshold/3963/1 "2011-02-22T21:52:06Z")

</div>

Hello Guys,

```
I have a legacy system based on Solr 1.2 and trying to port it to

```

ES. One of the features of the system is the possibility to create a  
"context" inside your index, a "context" is a search in the index with  
a big list of terms of some concept like Middle East Economy, Weather  
in Brazil, etc... As the list of terms in the search grows, the number  
of docs returned by that search also grows, but docs with a low score  
are outside the context (meaning that the document is not of that  
subject), so I Iet the user choose a threshold score that will define  
the docs inside the context.

```
In that version of Solr, (Lucene was 2.2) there was no way to

```

filter the documents of a search by a score, and I needed to know how  
many documents had a score higher than the threshold, so I created a  
SearchHandler that used a ScoreCollector wich extended HitCollector  
and just computed how many documents passed the threshold (a parameter  
passed to the handler) and returned that.

```
Do you guys have any clue how to achieve this with ES? I would

```

have to write a plugin or something? Is there a way of filtering  
results by a minimum score in ES? That would be great! I tried using  
the \_score in a filter script but I see that the scorer inside  
DocLookup is null. Is there some kind of after-score filter, filters  
that are applied after the score is computed?

Thanks for the help,  
Rossini

---

<div class="post-metadata">

### Author: ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)
#### Post date: [February 24, 2011, 2:29am UTC](https://discuss.elastic.co/t/using-a-score-threshold/3963/2 "2011-02-24T02:29:46Z")

</div>

That's a problem I'm facing too. Would like to know a workaround as well.

Cheers  
On Feb 22, 2011 6:52 PM, "Rafael Rossini" [rafael.rossini@gmail.com](mailto:rafael.rossini@gmail.com) wrote:

> Hello Guys,
> 
> I have a legacy system based on Solr 1.2 and trying to port it to  
> ES. One of the features of the system is the possibility to create a  
> "context" inside your index, a "context" is a search in the index with  
> a big list of terms of some concept like Middle East Economy, Weather  
> in Brazil, etc... As the list of terms in the search grows, the number  
> of docs returned by that search also grows, but docs with a low score  
> are outside the context (meaning that the document is not of that  
> subject), so I Iet the user choose a threshold score that will define  
> the docs inside the context.
> 
> In that version of Solr, (Lucene was 2.2) there was no way to  
> filter the documents of a search by a score, and I needed to know how  
> many documents had a score higher than the threshold, so I created a  
> SearchHandler that used a ScoreCollector wich extended HitCollector  
> and just computed how many documents passed the threshold (a parameter  
> passed to the handler) and returned that.
> 
> Do you guys have any clue how to achieve this with ES? I would  
> have to write a plugin or something? Is there a way of filtering  
> results by a minimum score in ES? That would be great! I tried using  
> the \_score in a filter script but I see that the scorer inside  
> DocLookup is null. Is there some kind of after-score filter, filters  
> that are applied after the score is computed?
> 
> Thanks for the help,  
> Rossini

---

<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: [February 24, 2011, 4:42am UTC](https://discuss.elastic.co/t/using-a-score-threshold/3963/3 "2011-02-24T04:42:37Z")

</div>

Its problematic to use the score in a filter that is part of the search process (compared to using it in facets). But, you can open an issue and we can add a minimum score parameter that will filter out results that are below it.  
On Thursday, February 24, 2011 at 4:29 AM, Thiago Souza wrote:

> That's a problem I'm facing too. Would like to know a workaround as well.  
> Cheers  
> On Feb 22, 2011 6:52 PM, "Rafael Rossini" [rafael.rossini@gmail.com](mailto:rafael.rossini@gmail.com) wrote:
> 
> > Hello Guys,
> > 
> > I have a legacy system based on Solr 1.2 and trying to port it to  
> > ES. One of the features of the system is the possibility to create a  
> > "context" inside your index, a "context" is a search in the index with  
> > a big list of terms of some concept like Middle East Economy, Weather  
> > in Brazil, etc... As the list of terms in the search grows, the number  
> > of docs returned by that search also grows, but docs with a low score  
> > are outside the context (meaning that the document is not of that  
> > subject), so I Iet the user choose a threshold score that will define  
> > the docs inside the context.
> > 
> > In that version of Solr, (Lucene was 2.2) there was no way to  
> > filter the documents of a search by a score, and I needed to know how  
> > many documents had a score higher than the threshold, so I created a  
> > SearchHandler that used a ScoreCollector wich extended HitCollector  
> > and just computed how many documents passed the threshold (a parameter  
> > passed to the handler) and returned that.
> > 
> > Do you guys have any clue how to achieve this with ES? I would  
> > have to write a plugin or something? Is there a way of filtering  
> > results by a minimum score in ES? That would be great! I tried using  
> > the \_score in a filter script but I see that the scorer inside  
> > DocLookup is null. Is there some kind of after-score filter, filters  
> > that are applied after the score is computed?
> > 
> > Thanks for the help,  
> > Rossini

---

<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: [February 24, 2011, 4:55am UTC](https://discuss.elastic.co/t/using-a-score-threshold/3963/4 "2011-02-24T04:55:39Z")

</div>

Nevermind, pushed support for this: [Search: Allow to filter out docs based on a minimum score · Issue #719 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/719) 🙂  
On Thursday, February 24, 2011 at 6:42 AM, Shay Banon wrote:

> Its problematic to use the score in a filter that is part of the search process (compared to using it in facets). But, you can open an issue and we can add a minimum score parameter that will filter out results that are below it.  
> On Thursday, February 24, 2011 at 4:29 AM, Thiago Souza wrote:
> 
> > That's a problem I'm facing too. Would like to know a workaround as well.  
> > Cheers  
> > On Feb 22, 2011 6:52 PM, "Rafael Rossini" [rafael.rossini@gmail.com](mailto:rafael.rossini@gmail.com) wrote:
> > 
> > > Hello Guys,
> > > 
> > > I have a legacy system based on Solr 1.2 and trying to port it to  
> > > ES. One of the features of the system is the possibility to create a  
> > > "context" inside your index, a "context" is a search in the index with  
> > > a big list of terms of some concept like Middle East Economy, Weather  
> > > in Brazil, etc... As the list of terms in the search grows, the number  
> > > of docs returned by that search also grows, but docs with a low score  
> > > are outside the context (meaning that the document is not of that  
> > > subject), so I Iet the user choose a threshold score that will define  
> > > the docs inside the context.
> > > 
> > > In that version of Solr, (Lucene was 2.2) there was no way to  
> > > filter the documents of a search by a score, and I needed to know how  
> > > many documents had a score higher than the threshold, so I created a  
> > > SearchHandler that used a ScoreCollector wich extended HitCollector  
> > > and just computed how many documents passed the threshold (a parameter  
> > > passed to the handler) and returned that.
> > > 
> > > Do you guys have any clue how to achieve this with ES? I would  
> > > have to write a plugin or something? Is there a way of filtering  
> > > results by a minimum score in ES? That would be great! I tried using  
> > > the \_score in a filter script but I see that the scorer inside  
> > > DocLookup is null. Is there some kind of after-score filter, filters  
> > > that are applied after the score is computed?
> > > 
> > > Thanks for the help,  
> > > Rossini

---

<div class="post-metadata">

### Author: ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)
#### Post date: [February 24, 2011, 12:44pm UTC](https://discuss.elastic.co/t/using-a-score-threshold/3963/5 "2011-02-24T12:44:18Z")

</div>

Thanks!!  
On Feb 24, 2011 1:56 AM, "Shay Banon" [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> Nevermind, pushed support for this:  
> [Search: Allow to filter out docs based on a minimum score · Issue #719 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/719) 🙂  
> On Thursday, February 24, 2011 at 6:42 AM, Shay Banon wrote:
> 
> > Its problematic to use the score in a filter that is part of the search  
> > process (compared to using it in facets). But, you can open an issue and we  
> > can add a minimum score parameter that will filter out results that are  
> > below it.  
> > On Thursday, February 24, 2011 at 4:29 AM, Thiago Souza wrote:
> > 
> > > That's a problem I'm facing too. Would like to know a workaround as  
> > > well.  
> > > Cheers  
> > > On Feb 22, 2011 6:52 PM, "Rafael Rossini" [rafael.rossini@gmail.com](mailto:rafael.rossini@gmail.com)  
> > > wrote:
> > > 
> > > > Hello Guys,
> > > > 
> > > > I have a legacy system based on Solr 1.2 and trying to port it to  
> > > > ES. One of the features of the system is the possibility to create a  
> > > > "context" inside your index, a "context" is a search in the index  
> > > > with  
> > > > a big list of terms of some concept like Middle East Economy, Weather  
> > > > in Brazil, etc... As the list of terms in the search grows, the  
> > > > number  
> > > > of docs returned by that search also grows, but docs with a low score  
> > > > are outside the context (meaning that the document is not of that  
> > > > subject), so I Iet the user choose a threshold score that will define  
> > > > the docs inside the context.
> > > > 
> > > > In that version of Solr, (Lucene was 2.2) there was no way to  
> > > > filter the documents of a search by a score, and I needed to know how  
> > > > many documents had a score higher than the threshold, so I created a  
> > > > SearchHandler that used a ScoreCollector wich extended HitCollector  
> > > > and just computed how many documents passed the threshold (a  
> > > > parameter  
> > > > passed to the handler) and returned that.
> > > > 
> > > > Do you guys have any clue how to achieve this with ES? I would  
> > > > have to write a plugin or something? Is there a way of filtering  
> > > > results by a minimum score in ES? That would be great! I tried using  
> > > > the \_score in a filter script but I see that the scorer inside  
> > > > DocLookup is null. Is there some kind of after-score filter, filters  
> > > > that are applied after the score is computed?
> > > > 
> > > > Thanks for the help,  
> > > > Rossini

---

<div class="post-metadata">

### Author: ![Rossini](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Rossini](https://discuss.elastic.co/u/Rossini)
#### Post date: [February 24, 2011, 1:54pm UTC](https://discuss.elastic.co/t/using-a-score-threshold/3963/6 "2011-02-24T13:54:00Z")

</div>

Thanks a lot! Keep going with the great work.

On Feb 24, 1:55 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Nevermind, pushed support for this:[Issues · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/719:))
> 
> On Thursday, February 24, 2011 at 6:42 AM, Shay Banon wrote:
> 
> > Its problematic to use the score in a filter that is part of the search process (compared to using it in facets). But, you can open an issue and we can add a minimum score parameter that will filter out results that are below it.  
> > On Thursday, February 24, 2011 at 4:29 AM, Thiago Souza wrote:
> > 
> > > That's a problem I'm facing too. Would like to know a workaround as well.  
> > > Cheers  
> > > On Feb 22, 2011 6:52 PM, "Rafael Rossini" [rafael.ross...@gmail.com](mailto:rafael.ross...@gmail.com) wrote:
> > > 
> > > > Hello Guys,
> 
> > > > I have a legacy system based on Solr 1.2 and trying to port it to  
> > > > ES. One of the features of the system is the possibility to create a  
> > > > "context" inside your index, a "context" is a search in the index with  
> > > > a big list of terms of some concept like Middle East Economy, Weather  
> > > > in Brazil, etc... As the list of terms in the search grows, the number  
> > > > of docs returned by that search also grows, but docs with a low score  
> > > > are outside the context (meaning that the document is not of that  
> > > > subject), so I Iet the user choose a threshold score that will define  
> > > > the docs inside the context.
> 
> > > > In that version of Solr, (Lucene was 2.2) there was no way to  
> > > > filter the documents of a search by a score, and I needed to know how  
> > > > many documents had a score higher than the threshold, so I created a  
> > > > SearchHandler that used a ScoreCollector wich extended HitCollector  
> > > > and just computed how many documents passed the threshold (a parameter  
> > > > passed to the handler) and returned that.
> 
> > > > Do you guys have any clue how to achieve this with ES? I would  
> > > > have to write a plugin or something? Is there a way of filtering  
> > > > results by a minimum score in ES? That would be great! I tried using  
> > > > the \_score in a filter script but I see that the scorer inside  
> > > > DocLookup is null. Is there some kind of after-score filter, filters  
> > > > that are applied after the score is computed?
> 
> > > > Thanks for the help,  
> > > > Rossini

---

<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, 4:11am UTC](https://discuss.elastic.co/t/using-a-score-threshold/3963/7 "2017-07-06T04:11:34Z")

</div>


