Opensearch Aggregate
POST /opensearch/aggregate
Generic, allowlist-bounded GROUP BY over a whitelisted mashup index.
Translates group_by into nested OpenSearch terms aggregations with
metric sub-aggs, then applies having / sort / limit to the
flattened groups. This is the matrix-walk primitive for TAM design (e.g.
count companies by NAICS x state x employee band in one call).
Guardrails: group_by depth is capped at 3, per-level bucket size tapers by
depth (_AGG_TERMS_SIZE_BY_DEPTH), the agg list is capped at 10, and
returned groups at limit (<=1000). Counts from terms /
cardinality are APPROXIMATE on a sharded index. Since
mashup_companies/mashup_contacts share one contact-grained index,
use uniqExact on COMPANY_ID for true unique-company counts. Mashup
aggregations automatically apply the organization’s deliverability policy.
Authorizations
Parameters
Header Parameters
Request Body required
Generic, allowlist-bounded GROUP BY over a whitelisted mashup index.
Translates to nested OpenSearch terms aggregations (one level per
group_by field) with metric sub-aggregations. having / sort /
limit are applied to the flattened groups server-side. Counts from
terms buckets / cardinality are APPROXIMATE on a sharded index.
object
A single aggregate metric over the grouped rows.
count needs no field (it is the bucket doc count). All other functions
require field. alias keys the value in each group’s agg map;
it defaults to function when omitted (so two same-function metrics must
each carry a distinct alias).
Pre-aggregation equality filters, identical semantics to /opensearch/search. RAW UPPERCASE field names.
object
1-3 RAW UPPERCASE keyword fields to group on (e.g. [“COMPANY_NAICS”, “COMPANY_STATE”]). Must be keyword-type fields — the canonical COMPANY_* firmographics are. Capped at 3 dimensions to bound cluster cost. ORDER HIGHEST-CARDINALITY FIRST: deeper dimensions get smaller per-level bucket caps (1000 / 100 / 20), so a low-cardinality field placed last keeps full fidelity while a high-cardinality field placed last may be truncated.
Logical index to aggregate. Maps to a whitelisted physical alias.
Max number of groups returned (after having + sort). Hard-capped at 1000.
object
Responses
200
Successful Response
object
object
object
Metric values keyed by alias, e.g. {“count”: 1247, “unique_domains”: 1184}.
object
The group-by field values for this group, e.g. {“COMPANY_NAICS”: “3311”, “COMPANY_STATE”: “OH”}.
object
422
Validation Error