1

I'm trying to use JEST to implement CRUD actions to ElasticSearch, and I've surveryed some articles, the method I found to do "Update" is "Index" another document with the same "_id", but I'll replace the whole document in that way.

I want to know is JEST capable to do "Partial Update"?

Edit :

I found there's an Update class which is in io.searchbox.core package that might help, but after I try this :

Update update = new Update.Builder(updateCameraString).index(this._IndexName).type(this._TypeName).id(id).build();
JestResult updateResult = this._JestClient.execute(update);

The content of updateCameraString is

{"Name":"test Added into Es, update again.","CreatedAt":"","ModifiedAt":"","UniqueId":"","Note":""}

Seems everything is fine, but I'll get the response below :

{
  "error": {
    "root_cause": [
      {
        "type": "action_request_validation_exception",
        "reason": "Validation Failed: 1: script or doc is missing;"
      }
    ],
    "type": "action_request_validation_exception",
    "reason": "Validation Failed: 1: script or doc is missing;"
  },
  "status": 400
}

Any device could be really appreciate, Thanks!

Nkosi
  • 235,767
  • 35
  • 427
  • 472
Alanight
  • 353
  • 2
  • 8
  • 23

1 Answers1

5

You're almost there, the updateCameraString needs to either be a script or a partial document, so it needs to be changed to the following and it will work:

{"doc": { "Name":"test Added into Es, update again.","CreatedAt":"","ModifiedAt":"","UniqueId":"","Note":""}}
Val
  • 207,596
  • 13
  • 358
  • 360
  • You're right! It works perfectly after I change the original string to the form you mentioned. I was really almost there, thank you so much for pushing me far away!! – Alanight Jun 01 '17 at 04:13