0

I am using Jest Java HTTP Rest client for Elasticsearch to do crud operations.

I have script update to update elastic search document. below is my script sample

    String script = "{\n" +
                    "    \"script\" : \"ctx._source.indicator = tag\",\n" +
                    "    \"params\" : {\n" +
                    "        \"tag\" : \"P\"\n" +
                    "    }\n" +
                    "}";

and using jest update api, I am able to update document. See below.

jestClient.execute(new Update.Builder(script).index(indexName).type("I").id(documentId).build());

I also added script.inline=true in my elastic search yml file without which script update mention above won't work.

This update operation works perfectly with Elastic Search 2.x version but recently we upgraded Elastic Search from 2.x to 5.x and now my Elastic Search documents are not getting updated.

Recently I have generated the mentioned script above with the help of Elastic Search helper class to create JSON. Below is my JSON that is going to Elastic Search server

{
          "script" : {
           "source": "ctx._source.requeue_parent_child_indicator = 
                   params.requeueIndicator",
           "lang": "painless",
                "params" : {
                "requeueIndicator" : "P"
                }
           }
        }

This script works when executed through latest kibana dev tool. My elastic search document is getting updated but it is not updating through JEST API (Update Builder)

Nkosi
  • 235,767
  • 35
  • 427
  • 472
ShaileshI
  • 137
  • 1
  • 1
  • 6
  • Maybe use fiddler to get the actual JSON going to the server. Then update your post with that. – Daryl Van Sittert Nov 15 '17 at 14:40
  • Daryl, this is the actual JSON that went to server {"script":{"source":"ctx._source.indicator = params.tag","lang":"painless","params":{"tag":"P"}}} – ShaileshI Nov 28 '17 at 11:35
  • please ignore that earlier one mentioned in the question section because I have used Elastic search helper class to generate JSON string. – ShaileshI Nov 28 '17 at 11:38
  • I have stopped using JEST as I could not able to solve it but I have used Java High Level Client API to update elastic search document and it is working fine. – ShaileshI Dec 15 '17 at 13:54
  • Did anyone find the solution for this? – user2689782 Sep 04 '20 at 19:51

0 Answers0