0

in ES version 5.x, I used this query and works well.

"bool": {
    "must": [
      {
        "script": {
          "script": {
            "inline": "params['_source']['my_field'] != null",
            "lang": "painless"
          },

BUT in ES version 6.2, It's error with below error message.

"error": {
    "root_cause": [
    {
        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
            "params['_source']['my_field'] != null"
            ,
            " ^---- HERE"
        ],
        "script": "params['_source']['my_field'] != null",
        "lang": "painless"
    }
],

There is no '_source' data in params. because there is no return data with below query.

"inline": "params['_source'] != null",

How should I do with this error?

1 Answer 1

0

Please, try something like this:

{ 
  "query" : {
    "bool": {
      "must": [
        {
          "script": {
            "script": {
              "source": "(doc.containsKey('my_field') ? doc['my_field'].value : null) != null",
             "lang": "painless"
            }
          }
        }
      ]
    }
  }
}

It works on my 6.2.2 version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.