i need to access document values stored in arrays from script. The order of the items in the array is important.
using doc['...'] to retrieve the array will mix up the order :-(
suppose a simple document like this
{
"ar":[5,4,3,2,1]
}
retrieved using this Query:
{
"query":{
"match_all":{}
},
"script_fields": {
"values": {
"script": {
"inline":"return doc['ar']"
}
}
}
}
will return the array in reversed(sorted) order: [1,2,3,4,5] is there a way to prevent this behavior?
i can not resort to using _source because i need this in a "has_child" query, which does not support _source.
any ideas?