AggregationQueryDsl

Builds an aggregate query: its filter, the collections it expands into elements, its groups (terms, histogram, dateHistogram, datePart), its metrics, sort by group and metric aliases, limit and having. Inside an expanded element, a group or metric field is relative to the innermost element unless its scope is AggregationGroupScope.ROOT.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun any(field: String, alias: String)
fun any(field: QueryField<*>, alias: String)
fun any(field: String, alias: String, init: FilterDsl.() -> Unit)
fun any(field: QueryField<*>, alias: String, init: FilterDsl.() -> Unit)
Link copied to clipboard
fun avg(field: String, alias: String)
fun avg(expression: AggregationExpression, alias: String)
fun avg(field: String, alias: String, init: FilterDsl.() -> Unit)
fun avg(expression: AggregationExpression, alias: String, init: FilterDsl.() -> Unit)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun count(alias: String)

fun count(alias: String, init: FilterDsl.() -> Unit)

Counts the records (or elements) that match init.

Link copied to clipboard

The time from from to to in unit: dateDiff("state.paidAt", "state.shippedAt", DateDiffUnit.HOUR).

Link copied to clipboard
fun dateHistogram(field: String, unit: AggregationDateUnit, alias: String, timeZone: ZoneId = UTC, dense: Boolean = false, scope: AggregationGroupScope? = null)
fun dateHistogram(field: QueryField<*>, unit: AggregationDateUnit, alias: String, timeZone: ZoneId = UTC, dense: Boolean = false, scope: AggregationGroupScope? = null)
Link copied to clipboard
fun datePart(field: String, part: AggregationDatePart, alias: String, timeZone: ZoneId = UTC, dense: Boolean = false, scope: AggregationGroupScope? = null)
fun datePart(field: QueryField<*>, part: AggregationDatePart, alias: String, timeZone: ZoneId = UTC, dense: Boolean = false, scope: AggregationGroupScope? = null)
Link copied to clipboard

A metric computed from the other metrics of the group: derived("share") { ref("sum") / total("sum") }.

fun derived(alias: String, expression: DerivedExpression)
Link copied to clipboard
fun distinctCount(field: String, alias: String)
fun distinctCount(expression: AggregationExpression, alias: String)
fun distinctCount(field: String, alias: String, init: FilterDsl.() -> Unit)
fun distinctCount(expression: AggregationExpression, alias: String, init: FilterDsl.() -> Unit)
Link copied to clipboard
Link copied to clipboard
fun expand(path: String)
fun expand(path: QueryField<*>)
fun expand(path: QueryField<*>, block: FilterDsl.() -> Unit)

fun expand(path: String, block: FilterDsl.() -> Unit)

Expands path into its elements, keeping those that match block (fields relative to the element).

Link copied to clipboard
Link copied to clipboard
fun filter(block: FilterDsl.() -> Unit)
Link copied to clipboard
fun first(field: String, alias: String, orderBy: String? = null)

The value of field on the group's earliest record by orderBy (the model's event time by default).

fun first(field: QueryField<*>, alias: String, orderBy: QueryField<*>? = null)
fun first(field: String, alias: String, orderBy: String? = null, init: FilterDsl.() -> Unit)
fun first(field: QueryField<*>, alias: String, orderBy: QueryField<*>? = null, init: FilterDsl.() -> Unit)
Link copied to clipboard

Keeps the groups whose metrics match: having { ("count" gte 10.0) and ("sum".isNotNull()) }.

Link copied to clipboard
fun histogram(field: String, interval: Double, alias: String, scope: AggregationGroupScope? = null)
fun histogram(field: QueryField<*>, interval: Double, alias: String, scope: AggregationGroupScope? = null)

fun histogram(expression: AggregationExpression, interval: Double, alias: String, scope: AggregationGroupScope? = null)

Buckets the value of expression by interval.

Link copied to clipboard
fun last(field: String, alias: String, orderBy: String? = null)

The value of field on the group's latest record by orderBy (the model's event time by default).

fun last(field: QueryField<*>, alias: String, orderBy: QueryField<*>? = null)
fun last(field: String, alias: String, orderBy: String? = null, init: FilterDsl.() -> Unit)
fun last(field: QueryField<*>, alias: String, orderBy: QueryField<*>? = null, init: FilterDsl.() -> Unit)
Link copied to clipboard
fun limit(limit: Int)
Link copied to clipboard
fun max(field: String, alias: String)
fun max(expression: AggregationExpression, alias: String)
fun max(field: String, alias: String, init: FilterDsl.() -> Unit)
fun max(expression: AggregationExpression, alias: String, init: FilterDsl.() -> Unit)
Link copied to clipboard
fun median(field: String, alias: String)
fun median(expression: AggregationExpression, alias: String)
fun median(field: String, alias: String, init: FilterDsl.() -> Unit)
fun median(expression: AggregationExpression, alias: String, init: FilterDsl.() -> Unit)
Link copied to clipboard
fun min(field: String, alias: String)
fun min(expression: AggregationExpression, alias: String)
fun min(field: String, alias: String, init: FilterDsl.() -> Unit)
fun min(expression: AggregationExpression, alias: String, init: FilterDsl.() -> Unit)
Link copied to clipboard
Link copied to clipboard
fun percentile(field: String, p: Double, alias: String)
fun percentile(expression: AggregationExpression, p: Double, alias: String)
fun percentile(field: String, p: Double, alias: String, init: FilterDsl.() -> Unit)
fun percentile(expression: AggregationExpression, p: Double, alias: String, init: FilterDsl.() -> Unit)
Link copied to clipboard
Link copied to clipboard
fun sort(block: SortDsl.() -> Unit)

Sorts the groups by group and metric aliases: sort { "count".desc() }.

fun sort(sort: List<Sort>)
Link copied to clipboard
fun stddev(field: String, alias: String)
fun stddev(expression: AggregationExpression, alias: String)
fun stddev(field: String, alias: String, init: FilterDsl.() -> Unit)
fun stddev(expression: AggregationExpression, alias: String, init: FilterDsl.() -> Unit)
Link copied to clipboard
fun sum(field: String, alias: String)
fun sum(expression: AggregationExpression, alias: String)
fun sum(field: String, alias: String, init: FilterDsl.() -> Unit)
fun sum(expression: AggregationExpression, alias: String, init: FilterDsl.() -> Unit)
Link copied to clipboard
fun terms(expression: AggregationExpression, alias: String, scope: AggregationGroupScope? = null)

Groups by the value of expression.

fun terms(field: String, alias: String, missingKey: String? = null, scope: AggregationGroupScope? = null)

scope ROOT groups the expanded elements by a field of their root record (AggregationGroup.scope).

fun terms(field: QueryField<*>, alias: String, missingKey: String? = null, scope: AggregationGroupScope? = null)
Link copied to clipboard
Link copied to clipboard
fun variance(field: String, alias: String)
fun variance(expression: AggregationExpression, alias: String)
fun variance(field: String, alias: String, init: FilterDsl.() -> Unit)
fun variance(expression: AggregationExpression, alias: String, init: FilterDsl.() -> Unit)