date_format
function. Aggregations that group by a date_format
are translated to a Solr range facet query. This allows for fast, interactive time series reporting over large data sets.
An example of a time series aggregation is shown below:
date_format
function is used to specify both the output format and the time interval in one compact pattern as specified by the Java
SimpleDateFormat class.
The example above is performing a monthly time series aggregation over the rec_time
field which is a datetime
field.
To switch to a daily time series aggregation all that is needed is to change the date pattern:
gap
parameter. If the gap parameter is not
defined it is inferred from the date format string. For example the date format string ‘yyyy-MM’
will have an inferred gap of 1MONTH.
To specify a custom gap you can add the gap parameter to the date format string as follows:
date_add
, date_sub
, and current_date
functions.
Below is an example of the use of date math predicates.
ORDER BY
clause can be used to sort time series aggregation results in
a different order.
HAVING
clause can also be applied to a time series query to limit the results to rows that meet specific criteria.