This is a simplified version of the problem.
"should": [
{
"script_score": {
"query": {
"match_all": {}
},
"script": {
"source": """
def score = 0;
if(params.ct1 < 3) {
score = 20;
params.ct1++;
}
return score;
""",
"params": {
"ct1": 0
}
}
}
}
],
Ideally I'd only get a 20 score 3 times but it's not working consistently - sometimes I get more than 3.
Is this possible? Has anyone done anything similar?