Trying to pass params to elasticsearch getting null_pointer_exception

I'm trying to send to Elasticsearch the following query. Here is the most minimal update by query which gives me the exception. Lets name it Query1:

{
  "id": "someID",
  "script": {
    "lang": "painless",
    "source": " if (ctx._source.containsKey('value')) { ctx._source.value = ctx._source.value + params.value; }"
  },
  "params": {
    "value": 1
  },
  "upsert": {
    "value": 1
  }
}

Been trying to hunt down this issue for a while now. In our case the parameter value is indexed as an integer. The query it's self is being sent as part of a bulk API. Which looks like as a following:

{update: {_id:"someID", _index:"someIndex", _type:"someType"}}
(Query1)

when trying to run the script it will have a run time exception:
null_point_exception

params.value 
      ^--- here

I've seen related issues to this one but non which contains solutions. In stack overflow and other sites.

The params should be inside the script block. Something like this should work:

  "script": {
    "lang": "painless",
    "source": " if (ctx._source.containsKey('value')) { ctx._source.value = ctx._source.value + params.value; }"
    "params": {
        "value": 1
    }
  }

I feel really silly. wow thanks.

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