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

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

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

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
To view this discussion on the web visit
For more options, visit