Here is the schema:
"mappings": {
"_doc": {
"properties": {
"createdAt": {
"type": "date"
},
"files": {
"type": "nested",
"properties": {
"name": {"type": "text"},
"contentType": {"type": "text"}
}
}
}
}
}
}
if i try to run a painless script to iterate through the document:
{
"script": {
"inline": """
int total = 0;
for (int i = 0; i < ctx._source.files.length; ++i) {
if (ctx._source.files[i].name== "1") {
ctx._source.files.add(params.object)
}
"""
}
}
}
It throws me null pointer exception on "ctx._source.files"
Any idea why does it happen? and how to access nested array of objects in ES 6.7