Facets/aggregations are a ParadeDB enterprise feature. Contact us for access.

Average

An average aggregation calculates the mean of the specified numeric field values across all documents.

SELECT search_idx.aggregate('{
  "avg_rating": {
    "avg": {"field": "rating"}
  }
}');
field
required

The field name to compute the average on.

missing

The value to use for documents missing the field. By default, missing values are ignored.

Sum

A sum aggregation computes the total sum of the specified numeric field values across all documents.

SELECT search_idx.aggregate('{
  "rating_total": {
    "sum": {"field": "rating"}
  }
}');
field
required

The field name to compute the sum on.

missing

The value to use for documents missing the field. By default, missing values are ignored.

Count

A count aggregation tallies the number of values for the specified field across all documents.

SELECT search_idx.aggregate('{
  "rating_count": {
    "value_count": {"field": "rating"}
  }
}');
field
required

The field name to compute the count on.

missing

The value to use for documents missing the field. By default, missing values are ignored.

Min

A min aggregation finds the smallest value for the specified numeric field across all documents.

SELECT search_idx.aggregate('{
  "min_rating": {
    "min": {"field": "rating"}
  }
}');
field
required

The field name to compute the minimum on.

missing

The value to use for documents missing the field. By default, missing values are ignored.

Max

A max aggregation finds the largest value for the specified numeric field across all documents.

SELECT search_idx.aggregate('{
  "max_rating": {
    "max": {"field": "rating"}
  }
}');
field
required

The field name to compute the maximum on.

missing

The value to use for documents missing the field. By default, missing values are ignored.

Stats

A stats aggregation provides a collection of statistical metrics for the specified numeric field, including count, sum, average, min, and max.

SELECT search_idx.aggregate('{
  "rating_stats": {
    "stats": {"field": "rating"}
  }
}');
field
required

The field name to compute the stats on.

missing

The value to use for documents missing the field. By default, missing values are ignored.

Percentiles

The percentiles aggregation calculates the values below which given percentages of the data fall, providing insights into the distribution of a dataset.

SELECT search_idx.aggregate('{
  "rating_percentiles": {
    "percentiles": {"field": "rating"}
  }
}');
field
required

The field name to compute the percentiles on.

percents
default: [1,5,25,50,75,95,99]

The percentiles to compute.

keyed
default: false

Whether to return the percentiles as a hash map.

missing

The value to use for documents missing the field. By default, missing values are ignored.