Hello,
I have some problems with sorting by element of array.
If I have for example 2 documents like:
{
"_id" : "1",
"_source" : {
"users" : [{"name" : "John"},{"name" : "Paul"}]
}
}
{
"_id" : "2",
"_source" : {
"users" : [{"name" : "Alice"},{"name" : "John"}]
}
}
Can you please tell me if I have the ability to sort and group by each element of the array using pagination and find one document several times?
The result that is to be expected after sort:
{
"hits" : {
"hits" : [
{
"_id" : "2",
"sort" : ["Alice"]
},
{
"_id" : "1",
"sort" : ["John"]
},
{
"_id" : "2",
"sort" : ["John"]
},
{
"_id" : "1",
"sort" : ["Paul"]
}
]
}
}
I've tried doing this via sorting or aggregation.
For aggregation, you can group elements, but end-to-end sorting and pagination do not work for me.