# Normalizing Scores

**URL:** https://discuss.elastic.co/t/normalizing-scores/17749
**Category:** Elasticsearch
**Created:** [May 27, 2014, 11:34am UTC](https://discuss.elastic.co/t/normalizing-scores/17749 "2014-05-27T11:34:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![lypido](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@lypido](https://discuss.elastic.co/u/lypido)
#### Post date: [May 27, 2014, 11:34am UTC](https://discuss.elastic.co/t/normalizing-scores/17749/1 "2014-05-27T11:34:21Z")

</div>

Hello,

is it possible to normalize the scores of a query so that the highest  
scoring document gets a score of 1 and the others a scaled score \< 1?

Thanks

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 27, 2014, 11:37am UTC](https://discuss.elastic.co/t/normalizing-scores/17749/2 "2014-05-27T11:37:13Z")

</div>

May be using function\_score? [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#\_using\_function\_score](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_using_function_score)

The new score can be restricted to not exceed a certain limit by setting the max\_boostparameter. The default for max\_boost is FLT\_MAX.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 27 mai 2014 à 13:34:26, [lypido@gmail.com](mailto:lypido@gmail.com) ([lypido@gmail.com](mailto:lypido@gmail.com)) a écrit:

Hello,

is it possible to normalize the scores of a query so that the highest scoring document gets a score of 1 and the others a scaled score \< 1?

## Thanks

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.538478e9.235ba861.1e56%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.538478e9.235ba861.1e56%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![lypido](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@lypido](https://discuss.elastic.co/u/lypido)
#### Post date: [May 27, 2014, 11:56am UTC](https://discuss.elastic.co/t/normalizing-scores/17749/3 "2014-05-27T11:56:29Z")

</div>

Sadly, this doesn't work, as max\_boost only cuts the scores off at that  
point.

Am Dienstag, 27. Mai 2014 13:37:22 UTC+2 schrieb David Pilato:

> May be using function\_score?  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_using_function_score)
> 
> The new score can be restricted to not exceed a certain limit by setting  
> the max\_boostparameter. The default for max\_boost is FLT\_MAX.
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)
> 
> Le 27 mai 2014 à 13:34:26, [lyp...@gmail.com](mailto:lyp...@gmail.com) \<javascript:\> (  
> [lyp...@gmail.com](mailto:lyp...@gmail.com) \<javascript:\>) a écrit:
> 
> Hello,
> 
> is it possible to normalize the scores of a query so that the highest  
> scoring document gets a score of 1 and the others a scaled score \< 1?
> 
> ## Thanks
> 
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ce14b963-d7a6-4abb-9bad-ae23c135af04%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ce14b963-d7a6-4abb-9bad-ae23c135af04%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [May 27, 2014, 5:10pm UTC](https://discuss.elastic.co/t/normalizing-scores/17749/4 "2014-05-27T17:10:23Z")

</div>

I think but I might be wrong that you can use a function\_score with a script and run a script like :

"script\_score" : {  
"script" : "\_score \> 1.0 ? 1.0 : \_score"  
}

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 27 mai 2014 à 13:56:32, [lypido@gmail.com](mailto:lypido@gmail.com) ([lypido@gmail.com](mailto:lypido@gmail.com)) a écrit:

Sadly, this doesn't work, as max\_boost only cuts the scores off at that point.

Am Dienstag, 27. Mai 2014 13:37:22 UTC+2 schrieb David Pilato:  
May be using function\_score? [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#\_using\_function\_score](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#_using_function_score)

The new score can be restricted to not exceed a certain limit by setting the max\_boostparameter. The default for max\_boost is FLT\_MAX.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 27 mai 2014 à 13:34:26, [lyp...@gmail.com](mailto:lyp...@gmail.com) ([lyp...@gmail.com](mailto:lyp...@gmail.com)) a écrit:

Hello,

is it possible to normalize the scores of a query so that the highest scoring document gets a score of 1 and the others a scaled score \< 1?

## Thanks

## You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com). To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com). For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ce14b963-d7a6-4abb-9bad-ae23c135af04%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ce14b963-d7a6-4abb-9bad-ae23c135af04%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.5384c700.79e2a9e3.28b%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.5384c700.79e2a9e3.28b%40MacBook-Air-de-David.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![harto](https://avatars.discourse-cdn.com/v4/letter/h/bb73d2/32.png) [@harto](https://discuss.elastic.co/u/harto)
#### Post date: [August 2, 2016, 2:55am UTC](https://discuss.elastic.co/t/normalizing-scores/17749/5 "2016-08-02T02:55:33Z")

</div>

Hello, sorry for bumping this very old topic.

I'm also interested in knowing if it's possible to normalize `_score` values into the range `0,1.0` (where the top result has score `1.0`).

The proposed solution floors scores above `1.0`, but if I understood correctly the OP wanted to know if all scores could effectively be divided by `max_score`.

The reason this is interesting to me is: I don't know how to determine weights for functions in a `function_score` query. I.e. if a given query can produce `_score` values in an arbitrary range, how can I know if a weight of 1, 5, 100 or 50000 is effective?

---

<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 5, 2017, 10:31pm UTC](https://discuss.elastic.co/t/normalizing-scores/17749/6 "2017-07-05T22:31:01Z")

</div>


