Painless: Collection.contains() not working

Because Elasticsearch treats those numbers as Longs by default, you need to make sure that you pass a Long to the contains method. The following should work:

GET testdatatype_unit_tests/_search
{
  "size": 100,
  "query": {
    "script": {
      "script": {
        "source": "doc['IntCollection'].values.contains(1L)",
        "lang": "painless"
      }
    }
  }
}
1 Like