Env: python 3.11, OpenSearch 2.11, Json.
could you please share, if there is a possible approach to normalize the relevance scores., I see an approach for hybrid search,
Is there a similar approach for normal match case or match all case.
I tired the following approach but aggregator values not readily available during the script score of functions.
payload = {
"size": str(num_records),
"aggs": {
"max_score": {
"max": {
"script": {
"source": "_score"
}
}
},
"min_score": {
"min": {
"script": {
"source": "_score"
}
}
}
},
"query": {
"function_score": {
"query": {
"match": {
"title": query_text,
}
},
"functions": [
{
"script_score": {
"script": {
"source": "def minScore = params.min_score.value; def maxScore = params.max_score.value; if (maxScore == minScore) {return 0.0;} else {return (_score - minScore) / (maxScore - minScore);}",
"params": {
"min_score": {
"field": "min_score"
},
"max_score": {
"field": "max_score"
}
}
}
}
}
],
"boost_mode": "replace"
}
}
}
Please share me possible solutions, thank you for your time.