How to write Kibana update query in java

Hi team,

My requirement is to update a document for a particular index.
I have constructed the query in Kibana using KQL, but I am unable to convert the same into java API client, so that I can call from my java code.

Following is my query using KQL:

POST my_doc/_update/new1
{

  "script": {
    "source": """
            for(elm in params.domTraces){
              if(!ctx._source.domTraces.contains(elm)){
                ctx._source.domTraces.add(elm);
              }
            }
            
            ctx._source.stopTime = params.stopTime
            """,
    "params": {
      "domTraces": [
        {
          "element": "app-root",
          "attributes": {
            "ng-version": "12.9"
          }
        }
      ],
      "stopTime":12
    }
  },
    "upsert": {
      "domTraces": [
        {
          "element": "app-root",
          "attributes": {
            "ng-version": "12"
          }
        }
      ]
  }
}

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