How to normalize score when combining regular query and function_score?

First of all kudos on the awesome job everyone here is doing!

I was wondering if you guys can help me solve this puzzle:

Also available on stack
overflow: http://stackoverflow.com/questions/25361795/elasticsearch-how-to-normalize-score-when-combining-regular-query-and-function

Idealy what I am trying to achieve is to assign weights to queries such
that query1 constitutes 30% of the final score and query2 consitutes other
70%, so to achieve the maximum score a document has to have highest
possible score on query1 and query2. My study of the documentation did not
yield any hints as to how to achieve this so lets try to solve a simpler
problem.

Consider a query in following form:

{
"query": {
"bool": {
"should": [
{
"function_score": {
"query": {"match_all": {}},
"script_score": {
"script": "<some_script>",
}
}
},
{
"match": {
"message": "this is a test"
}
}
]
}
}
}

The script can return an arbitrary number (think-> it can return something
like 12392002).

How do I make sure that the result from the script will not dominate the
overall score? (my experiments using explain show that this indeed can
happen very often)

Is there any way to normalize it? For example instead of script score
return the ratio to max_script_score (achieved by document with highest
score)?

--
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/2179ed93-575c-47d5-a13a-42d1e2244baa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

2 Likes