config
elasticsearch 8.4.3 (javaApi)
JDK 17
created index
PUT testdb
{
"mappings": {
"properties": {
"name":{
"type":"text"
},
"desc":{
"type":"text"
},
"score":{
"type": "integer"
}
}
}
}
PUT testdb/_doc/1
{
"name": "bookA",
"desc": "a desc",
"score":36305
}
PUT testdb/_doc/2
{
"name": "bookB",
"desc":"a desc",
"score": 1000
}
question
Now I want to add 125 points to bookB's score , the request statement should be like this
POST testdb/_update/2
{
"script":"ctx._source.score+=125"
}
here I use a script to make an add operation for bookB's score , and actually it works.
However, I want to create this request statement by javaApi ,how can I do this?(I haven't found a solution in elasticsearch's docs yet)