Query to get latest comment of each user in the month


(Aditya Raut) #1

I have a es index which is of the following structure
User: 1, timestamp: 13-5-2014, comment: "abcded"
User: 2, timestamp: 10-5-2014, comment: "abcded"
User: 1, timestamp: 12-5-2014, comment: "abcded"
User: 2, timestamp: 8-5-2014, comment: "abcded"
User: 3, timestamp: 5-5-2014, comment: "abcded"
User: 3, timestamp: 7-5-2014, comment: "abcded"

I have been trying to think of a query using facets or aggregations to get
the last comment of the month for each user.
For example the result would be from the above the bold only

User: 1, timestamp: 13-5-2014, comment: "abcded"
User: 2, timestamp: 10-5-2014, comment: "abcded"
User: 3, timestamp: 7-5-2014, comment: "abcded"

Is there any way to do this?

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/13605f9a-7506-401a-b918-6aaeadbf803e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(ElasticSearch Users mailing list) #2

Not at the moment. However you can do a terms agg on user, then nest a max
agg on the timestamp. Then from the results that come back, you will need
to run a second _search to retrieve the comment values (using the user +
timestamp combo for each bucket from the aggs).

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/7b7de0cc-ee76-4759-bb46-2db34c4162f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3