Question about week granularity elasticsearch uses

(Thomas) #1


I stepped into a situation where I need to truncate a timestamp field
truncated to the week, and i want to do it the exact way elasticsearch does
it in the datehistogram aggregation in order to be able to perform
comparisons. Does anyone knows how I should perform the truncate to the
week? I notice that datehistogram returns the beginning of the week
(MONDAY), is it safe to use the Calendar way as follows?

Calendar cal = Calendar.getInstance();

// cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
Date time = cal.getTime();
System.out.println("time = " + time);

Is the first day of week depends on the Locale in elasticsearch or not?

Thank you

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
To view this discussion on the web visit
For more options, visit

(system) #2