How to Update Value inside Native Script Plugin

Hello guys,

I saw this snippet where update_by_query can update source directly

POST twitter/_update_by_query
{
  "script": {
    "inline": "ctx._source.likes++",
    "lang": "painless"
  },
  "query": {
    "term": {
      "user": "kimchy"
    }
  }
}

instead of using painless, I wrote a native script plugin in Java because of my complex business logic. Then I need to update multiple fields value including the ones in nested object.

public Object run() {
     // change field value of "subtotal"
     // change field value of "total"   

   return true;
}

I was trying with source().put("subtotal", 3000) but I kept getting NullPointerException

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