Search code examples
javascriptelasticsearchelasticsearch-painless

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.


Solution

  • Asked in the elastic forum. params wasn't inside script.