I have a simple test object indexed. It has a collection "IntCollection" and the indexed object has this property set to the array {1, 2, 3, 4, 5}. Here is the (simplified) indexed object:
"_source":
{
// ...
"IntCollection": [
1,
2,
3,
4,
5
]
}
The goal is to filter the indexed objects by containing a specific value in "IntCollection" using Painless.
Here is my query (in Kibana):
GET /testdatatype_unit_tests/_search
{ "size": 100,
"query": {
"script": {
"script": {
"source": "doc['IntCollection'].values.contains(1)",
"lang": "painless"
}
}
}
}
No results are returned, although the indexed document has the searched value inside. Here is the query result:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
When I do the same request with a TermQuery, it works:
GET /testdatatype_unit_tests/_search
{ "size": 100,
"query": {
"term": {
"IntCollection": {
"value": 1
}
}
}
}
Any idea, what is wrong with the Painless script?
Edit: ES version 6.4.2 is used.