Question

I have two documents in parent - child relationship and I want to get the number and also the max value of a date field from the children documents grouped by the value of the parent id. In other words, for every parent document I want to count its children and get its latest child. In addition, it would be great if the date field would have the same format and not be returned as a timestamp value.

I already tried more facets, but nothing seems to return the desired answer. Could anyone provide some insights about how to achieve this? Is it possible? Thank you in advance.

Was it helpful?

Solution

Seems like you should look and play around with http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-stats-facet.html value field will be date key field will be _parent

I suppose, it should return max, min, count, etc. (read docs) for each _parent, but you must play with it

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top