Find most frequent users on basis of captureTime

I want to fire a query, which should return most frequent users data on the basis of attribute - "CaptureTime", which is an array of variable sizes[of timestamp field].
I can't perform "update by query" because of some restrictions, so, I tried to perform max using aggregation API but remained unsuccessful, also thought if I can sort in decreasing order on the "CaptureTime" array length which will help me in finding - most frequent users.
Below is the glimpse of that dataset :-

"_source" : {
id : "23",
captureTime :
"_source" : {

Kindly provide me some insights.Thanks a real bunch!

I think a date_histogram aggregation on captureTime, followed by a terms aggregation on ID would work.

That will give you a bucket per time interval (every five minutes, or whatever makes sense). Then for each bucket of time, the terms agg will give you the list of IDs that fell into that bucket.

1 Like

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