1

Suppose that i have a doc mapping field like below

{
    "template": {
        "mappings":{
            "template":{
                "properties": {
                    "sth": {
                        "type": "long"
                    }
                }
            }
        }
    }
}

The field sth is the type of array.

I want to check whether the field sth contains a value or not, so i write painless script like doc['sth'].values.contains((long)1)

It works. However, if i write doc['sth'].contains((long)1), accessing the field not via .values, it also can works.

I've also tried some instance method like isEmpty(), size(), both can work whether via .values or not.

So, what's the difference between accessing a document field via .value/.values or not in painless script? What does painless do under the hood?

user8510613
  • 1,242
  • 9
  • 27

0 Answers0