Convert MySQL query to elasticsearch

You may need to do something more complicated, such as pass a script to the date aggregation in order to do some calculations across the returned buckets.

Notice in the example I linked to in the thread above, the script actually goes through values returned in the buckets and calculates an array of durations, returning that as a result:

start = doc['recordStart'].value; 
duration = doc['recordDuration'].value; 
l = []; 
for (long i = 0; i < duration; i += 60000) 
	{ l.add(start + i); }; 
return l;
1 Like