How to convert painless script to java api

Below is the ElasticSearch painless script query , please suggest me the JAVA API or how to write the java code for below query
I wanted to prepare the same query using Java 1.8 and RestHighLevelClient

Request:-

GET /xyz_indx_name/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"PRD_ID": {
"value": 01,
"boost": 1.0
}
}
},
{
"term": {
"DTST_ID": {
"value": 1,
"boost": 1.0
}
}
},
{
"term": {
"CNF_ID": {
"value": 0000,
"boost": 1.0
}
}
}
],
"adjust_pure_negative": true,
"boost": 1.0
}
},
"script_fields": {
"script1": {
"script": {
"lang": "painless",
"source": """return (1+ (params.get('A') - params.get('B')) * params.get('C'));""",
"params": {
"A": 20,
"B": 2,
"C": 30
}
}
},
"Script2": {
"script": {
"lang": "painless",
"source": """return (1+(params.get('D')-params.get('E')));""",
"params": {
"D": 20,
"E": 2
}
}
},
"Script3": {
"script": {
"lang": "painless",
"source": """return (params.get('F') * params.get('G'));""",
"params": {
"F": 20,
"G": 2
}
}
},
"Script4": {
"script": {
"lang": "painless",
"source": """return (params.get('A') * (1+(params.get('B') - params.get('C')))) * params.get('D');""",
"params": {
"A": 20,
"B": 2,
"C": 4,
"D": 6
}
}
}
}
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.