How to query top 1 Child document for each unique parent document?

I am trying to query elasticsearch in such a way the return the latest child document or any one child document for each unique parent document. I am indexing UserId as Parent document and User metadata information to child document. Each UserId will have multiple metadata info indexed as Child document. So I need to query to return top 1 child document for each UserId in Parent document. Can anyone help me on how to achieve this in Elasticsearch. I am using ES 5.1.


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.