Normalizing Scores

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

2 Likes

May be 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
@dadoonet | @elasticsearchfr

Le 27 mai 2014 à 13:34:26, lypido@gmail.com (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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com.
For more options, visit 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.
To view this discussion on the web visit 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.

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

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
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr

Le 27 mai 2014 à 13:34:26, lyp...@gmail.com <javascript:> (
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 <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.comhttps://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.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ce14b963-d7a6-4abb-9bad-ae23c135af04%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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
@dadoonet | @elasticsearchfr

Le 27 mai 2014 à 13:56:32, lypido@gmail.com (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

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
@dadoonet | @elasticsearchfr

Le 27 mai 2014 à 13:34:26, lyp...@gmail.com (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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/281e7890-01f1-4bcf-bc0f-7a2c95e407be%40googlegroups.com.
For more options, visit 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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ce14b963-d7a6-4abb-9bad-ae23c135af04%40googlegroups.com.
For more options, visit 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.
To view this discussion on the web visit 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.

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?

6 Likes