Hello
I am having an issue with sorting documents based on aggregation result.
The scenario is the following:
I have an index called messages.
A message can have multiple messages. (one level a message can have only children, not grandsons)
I didn't make a relation child-parent, but I have a column called resourceId that represents the parent.
I want to filter all the parent messages return them based on the number of children.
I tried first to filter the results and then sort them by making a new request with a term aggregation based on resourceId, but what if the result that is most popular isn't in my filtered results? because I also have set a size?
I also tried first to make the aggregation, but again I can't actually filter the results because the filtering is made on parent messages.
Any other ideas that might help me?
PS: I am using elasticsearch 2.3