Using constant_score to boost document scores

Hi there!

New to elastic search.

Have a question regarding "constant_score". When I use the "constant_score"
query and supply a "boost" param, the query returns docs with score still
as 1, not multiplied with the boost.

Is it supposed to do that?

--
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/6894681f-1682-4053-ba71-78ed6090db5b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hi,

This happens because of query normalization: the query normalization factor
is 1/boost so in the end the score is multiplied by the boost and then
divided by the boost again in the end, so the score remains 0.

However, this doesn't mean that the boost is always ignored! For example,
if you wrap two constant-score queries into a boolean query:

{
"query": {
"bool": {
"should": [
{
"constant_score": {
"filter": {
"term": {
"fifled": "value1"
}
},
"boost": 2
}
},
{
"constant_score": {
"filter": {
"term": {
"field": "value2"
}
},
"boost": 5
}
}
]
}
}
}

Documents that match "value2" will get a higher score than documents that
match "value1".

--
Adrien Grand

--
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/CAL6Z4j7me_CRCvSan5zwh-MNOxUx1fgEqi6c9G-4zoxB_W6%3DLA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.