Plainless Query Cannot invoke \"Object.getClass()\" because \"callArgs[0]\" is null

Hello,
I am using a painless scripting language to query,but the hit of result is empty.
This is my query body

POST test_script-0/_search
{
        "_source":true,
        "aggs":{},
        "from":0,
        "highlight":{
            "fields":{
                "*":{
                    "fragment_size":10000
                }
            },
            "post_tags":[
                "@/kibana-highlighted-field@"
            ],
            "pre_tags":[
                "@kibana-highlighted-field@"
            ],
            "require_field_match":false
        },
        "query":{
            "bool":{
                "filter":[],
                "must":[
                    {
                        "range":{
                            "@timestamp":{
                                "format":"epoch_millis||yyyy-MM-dd HH:mm:ss",
                                "gte":1609403799250,
                                "lt":1610699799250
                            }
                        }
                    },
                    {
                        "script":{
                            "script":{
                                "inline":"\n            try{\n                Matcher m = /(?<ar1fbe9185f4feeb15eb9577e31c5f5394>\\d+)/.matcher(String.valueOf(params['_source']['freeSize']));\n                m.find();\n                String f = m.group(1);\n                f==\"487883268096\"\n            }catch(Exception e){}",
                                "lang":"painless"
                            }
                        }
                    }
                ],
                "must_not":[],
                "should":[]
            }
        },
        "size":10,
        "sort":[
            {
                "@timestamp":{
                    "missing":"_last",
                    "order":"desc",
                    "unmapped_type":"date"
                }
            }
        ]
    }

Then I take a testing, I create an index with a document first.

POST test_script-0/_doc
{
    "@timestamp":"2021-01-16T02:58:19.000Z",
    "freeSize":"487883268096"
}

I delete the operation of catching the exception,this is my query body,then I got an error.

{
  "_source": true,
  "aggs": {},
  "from": 0,
  "highlight": {
    "fields": {
      "*": {
        "fragment_size": 10000
      }
    },
    "post_tags": [
      "@/kibana-highlighted-field@"
    ],
    "pre_tags": [
      "@kibana-highlighted-field@"
    ],
    "require_field_match": false
  },
  "query": {
    "bool": {
      "filter": [],
      "must": [
        {
          "script": {
            "script": {
              "inline": "Matcher m = /(?<ar1fbe9185f4feeb15eb9577e31c5f5394>\\d+)/.matcher(String.valueOf(params['_source']['freeSize'])); m.find(); String f = m.group(1);               f==\"487883268096\";",
              "lang": "painless"
            }
          }
        }
      ],
      "must_not": [],
      "should": [
       
      ]
    }
  },
  "size": 10,
  "sort": [
    {
      "@timestamp": {
        "missing": "_last",
        "order": "desc",
        "unmapped_type": "date"
      }
    }
  ]
}

When executing, I have the following error.

Are there some idea for it ?

Looking forward to any help!

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