I have the following mapping: http://pastebin.com/FgtC5aaw (includes sample data)
{
"columns": [
{
"name": "First column",
"position": 1
},
{
"name": "Second column",
"position": 2
},
{
"name": "Third column",
"position": 3
}
],
"name": "Database name"
}
What I would like to get is the "database" document(s), but each one with columns sorted in descending order by columns.position field, so:
{
"name": "Database name",
"columns": [
{
"name": "Third column",
"position": 3
},
{
"name": "Second column",
"position": 2
},
{
"name": "First column",
"position": 1
}
]
}
I tried using "sort" on "columns.position", but I think it would just sort all "database" documents on it's nested columns.
Is such a result possible in Elasticsearch?