We have an index with Parent and Child Model, users and posts. Now we have a has_child query on posts, to be able to sort users based on desc order of post creation. in other words I need the user on top which has very latest post.
Here is my mapping
{
"properties":{
"id": {
"type": "keyword"
},
"content":{
"type": "text"
},
"created_at": {
"type": "date"
},
"join_type": {
"type": "join",
"relations": {
"user": [
"post",
],
}
}
}
}
The following query does not sort my users, based on the inner_hits:
{
"query": {
"has_child": {
"type": "post",
"inner_hits" : {},
"query": {
"match" : {"content" : "test"}
}
}
},
"sort": [{"post.created_at" : "desc"}]
}