Methods
# aggregate(params) → {Promise.<ServiceResponse>}
Runs an aggregation query against the source's data.
Supports filtering, sorting, field selection, pagination via cursor (pageKey),
and Elasticsearch-style aggregations. Pass raw: true to query the raw index
(unprocessed field values as ingested).
filter and sort are arrays of real Elasticsearch clause objects, not a flat
{field: value} shorthand — they're passed straight through to the query body.
sort entries use ES's shorthand form ({field: 'asc'|'desc'}); filter entries
are full query-DSL clauses (term, range, bool, ...), ANDed together. A
text/string-formatted field needs its .keyword sub-field for an exact-match
term filter (e.g. { term: { 'status.keyword': 'active' } }), not the bare field.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
Object
|
Aggregation parameters. |
|
size |
number
|
<optional> |
Number of rows to return. |
fields |
Array.<string>
|
<optional> |
Fields to include in each row. |
sort |
Array.<Object>
|
<optional> |
Sort clauses, e.g. |
filter |
Array.<Object>
|
<optional> |
ES filter clauses, e.g. |
aggs |
Object
|
<optional> |
Elasticsearch aggregation definitions. |
pageKey |
string
|
<optional> |
Cursor for the next page (from a previous response's |
raw |
boolean
|
<optional> |
When |
sdk/aggregate-filter-must-be-array – filter was given but isn't an array.
Error
sdk/aggregate-sort-must-be-array – sort was given but isn't an array.
Error
Promise.<ServiceResponse>
Example
const { result } = await insights.Source('Orders').aggregate({
size: 100,
filter: [{ term: { 'status.keyword': 'active' } }],
sort: [{ createdAt: 'desc' }]
})
# get(schemaopt) → {Promise.<ServiceResponse>}
Fetches metadata for the source, optionally including its formulator validation schema.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
schema |
boolean
|
<optional> |
false | When |
Promise.<ServiceResponse>
Example
const { result } = await insights.Source('Orders').get(true)
// result.schema.validation, result.schema.render, result.schema.translations
Type Definitions
Object
# FieldMappingObject
Properties:
| Name | Type | Attributes | Description |
|---|---|---|---|
include |
Array.<string>
|
<optional> |
|
exclude |
Array.<string>
|
<optional> |
Object
# ServiceResponse
Properties:
| Name | Type | Description |
|---|---|---|
status |
number
|
HTTP status code returned by the service. |
result |
*
|
Parsed JSON body of the response, or |