Partial Update a document in ElasticSearch using Java API

2.1k views Asked by At

I want to partially update a document in elastic search using java api. My ES mapping looks like :

"mappings": {

"DOC_TYPE": {
   "properties": {
        "FieldA": {
            "type": "long"
        },
        "FieldB": {
            "type": "long"
        },
        "FieldC": {
            "type": "long"
        }
  }

}

I want to update the value of FieldA. For the same I am using the following logic :

NOTE : map is containing the value to be updated. It is of type <String,Object>

UpdateRequest updateRequest = new UpdateRequest() .doc(map, XContentType.JSON);

Update.Builder builder = new Update.Builder(update).index("INDEX_NAME").type("DOC_TYPE").id("id");

client.execute(builder.build());

But I am getting error : {"error":{"root_cause":[{"type":"action_request_validation_exception","reason":"Validation Failed: 1: script or doc is missing;"}]

I am unable to figure out where I am going wrong as I have already added doc in my request.

NOTE : I am using JEST client here. Is it possible to partially update the document via Jest Client?

0

There are 0 answers