🔍

Aggregate By Field

Verified

@elastic/aggregate-by-field

Aggregate documents by a specific field

Usage

RUN SKILL aggregate_by_field()

With parameters:

RUN SKILL aggregate_by_field WITH index_pattern = 'value', field = 'value', limit = 0

Parameters

NameTypeDefaultDescription
index_patternSTRINGIndex pattern to aggregate
fieldSTRINGField name to group by
limitINTMaximum number of buckets

Returns

ARRAY— An array of matching documents

Example

-- Using curl
curl -u elastic-admin:elastic-password http://localhost:9200/_escript \
  -H "Content-Type: application/json" \
  -d '{"query": "RUN SKILL aggregate_by_field()"}'

-- Response
{
  "result": [...],
  "_meta": {
    "execution_id": "abc123",
    "duration_ms": 45
  }
}