The functions score query gives a good facility to implement various aspects of the score , but then its not exactly giving control over the influence of each function.
For eg: , for the function below -
{
"query": {
"function_score": {
"functions": [
{
"decay": {
"gauss": {
"date": {
"origin": "2013-09-17",
"scale": "10d",
"offset": "5d",
"decay": 0.5
}
}
}
},
{
"field_value_factor": {
"field": "popularity",
"factor": 1.2,
"modifier": "sqrt",
"missing": 1
}
},
{
"random_score": {}
},
{
"script_score": {
"script": {
"lang": "lang",
"params": {
"param1": 2,
"param2": 3
},
"inline": "_score * doc['rating'].value / pow(param1, param2)"
}
}
}
]
}
}
}
There are 4 functions and they dictate the end score. Here , either of the function like the script_score function can eat up all the influence of the score. That is the value of the script_score might be in range of 1000 to 2000 and value of the decay would be between 0 and 1. Hence the influence of the decay function is not exactly passed on to the final score , rather its the script_score that eats up all the influence , rest of the functions might have little or no influence on the final score.
To fix this , it might be useful to have a influenceScore factor per function which tells what percentage of the end score , this function should influence.
For eg: , the above query can be rewriten as
{
"query": {
"function_score": {
"functions": [
{
"influenceScore": "40%",
"decay": {
"gauss": {
"date": {
"origin": "2013-09-17",
"scale": "10d",
"offset": "5d",
"decay": 0.5
}
}
}
},
{
"influenceScore": "30%",
"field_value_factor": {
"field": "popularity",
"factor": 1.2,
"modifier": "sqrt",
"missing": 1
}
},
{
"influenceScore": "10%",
"random_score": {}
},
{
"influenceScore": "20%",
"script_score": {
"script": {
"lang": "lang",
"params": {
"param1": 2,
"param2": 3
},
"inline": "_score * doc['rating'].value / pow(param1, param2)"
}
}
}
]
}
}
}
Here , we will have a influenceScore per function which dictates the influence of each function. This will help us in further fine tuning the score.
The functions score query gives a good facility to implement various aspects of the score , but then its not exactly giving control over the influence of each function.
For eg: , for the function below -
There are 4 functions and they dictate the end score. Here , either of the function like the script_score function can eat up all the influence of the score. That is the value of the script_score might be in range of 1000 to 2000 and value of the decay would be between 0 and 1. Hence the influence of the decay function is not exactly passed on to the final score , rather its the script_score that eats up all the influence , rest of the functions might have little or no influence on the final score.
To fix this , it might be useful to have a influenceScore factor per function which tells what percentage of the end score , this function should influence.
For eg: , the above query can be rewriten as
Here , we will have a influenceScore per function which dictates the influence of each function. This will help us in further fine tuning the score.