Aggregation API upgrade guide
Introduction
In Jira 10.4, we introduced a new search API and deprecated the Lucene-specific org.apache.lucene.search.Collector
, recommending its replacement with com.atlassian.jira.search.index.IndexSearcher#scan(SearchRequest request, Function<Document, Boolean> callback)
. However, we've recognized that using the scan
method for aggregations is inefficient due to high data transfer volumes for local processing.
To address this, we're introducing a new aggregation API designed specifically for aggregation operations.
This page details the new aggregation methods and provides migration examples from Lucene-specific collectors to the aggregation API.
Aggregation methods
In Jira 10.5, we’re introducing two aggregation types: metric and bucket aggregations.
Metric aggregations
Metric aggregations calculate values over a set of documents. In Jira 10.5, the following metric aggregations are available:
- AvgAggregation: Computes the average of numeric values for a field across all matching documents.
- MaxAggregation: Determines the maximum numeric value for a field across all matching documents.
- SumAggregation: Calculates the sum of numeric values for a field across all matching documents.
Bucket aggregations
Bucket aggregations group documents based on specified criteria and can include sub-aggregations, unlike metric aggregations. In Jira 10.5, the following bucket aggregations are available:
- DateHistogramAggregation: Groups documents into buckets based on date intervals.
- TermsAggregation: Groups documents into buckets based on unique terms within a specified field.
We plan to introduce more aggregations in the future. You can suggest new aggregations by filing a suggestion ticket on JAC with the Search - Search API
component.
Good to know
To perform aggregation on a field, ensure that the field is indexed with doc values enabled.
Migrating collectors to Aggregation API
Example 1 - Compute average value of a number custom field
Legacy Lucene | Aggregation API |
---|---|
|
|
Example 2 - Count issues by project
Legacy Lucene | Aggregation API |
---|---|
|
|