Hello everyone,
In elastic script params[_source ] or doc contexts returns only a single document and it allows us to iterate on fields but I need to get variables from all other documents to do my calculation. How can I do that?
I would be happy if anyone can explain on this example;
Thanks a lot !
GET hockey/_search
{
"query": {
"function_score": {
"script_score": {
"script": {
"lang": "painless",
"source": """
int total = 0;
for (int i = 0; i < doc['goals'].length; ++i) {
total += doc['goals'][i];
}
return total;
"""
}
}
}
}
}