I'm using ES version 6.0.1 and have integrated the Java High level rest client having version 6.0.1 in my application.
I am currently trying to build this script based sorting query using the Java High Level Rest client API of elastic search:
{
"sort": {
"_script": {
"type": "number",
"script": {
"lang": "painless",
"params": {
"ids": [3, 2, 1570]
},
"source": """
int idsCount = params.ids.size();
int id = (int)doc['id'].value;
int foundIdx = params.ids.indexOf(id);
return foundIdx > -1 ? foundIdx: idsCount + 1;
"""
}
}
}
}
But I couldn't find any documentation regarding the script based sorting queries for the java client. I would appreciate if someone will help me out in implementing the above query using java API.
I am not sure about ES version 6.0.1. I am using ES version 7.9.0
This works for me.