Querylight TS Demo

Min Aggregation

Get the smallest indexed numeric or date value, optionally restricted to the current result set.

Back to docs search

Reference Entry

Min Aggregation

Discovery · advanced · order 22

Get the smallest indexed numeric or date value, optionally restricted to the current result set.

Min Aggregation

min() returns the smallest indexed value in a numeric or date field.

Basic usage

const publishedAtIndex = index.getFieldIndex("publishedAt") as DateFieldIndex;
const earliest = publishedAtIndex.min();

For date fields, the return value is an epoch timestamp in milliseconds.

How it works

min() scans the indexed numeric values and returns:

  • the smallest value when at least one value exists
  • null when the field or subset has no values

Subset example:

const earliestInSubset = publishedAtIndex.min(new Set(["a", "c"]));

When to use it

  • earliest publication time
  • smallest price in the current slice
  • lower bound for histogram or chart labels

Tradeoffs

  • Date results are numeric timestamps. Format them for display.