Skip to content

[data.search.aggs]: Expression functions for bucket agg types  #63762

@lukeelmers

Description

@lukeelmers

Part of #61768

As part of improving semantics in the esaggs expression function & making it available for more teams to use, we need to try to remove arguments that are blobs of stringified JSON.

Instead we will write functions for each of the agg types, as shown in the terms example here, which will only return data of type agg_type. Then as a follow-up step, we can update esaggs to only accept arguments of type agg_type for the agg configs. In this way we can enforce that anyone generating an agg config is doing so using each of these functions, which will make future maintainability much easier and prevent JSON blobs from being stored in expression strings everywhere.

Since there are so many agg types, we've broken the work into buckets and metrics. This issue exists to track work on expression functions for the bucket agg types:

Steps for each agg type:

  1. Create an interface for the params of the agg type you are writing a function for
    • note that all aggs will have id, enabled, schema, and json, in addition to the other params
    • params that are objects (such as ranges in the range agg) would ideally have expression functions created for them too so that they can be passed as subexpression arguments, but as a first step we can also simply stringify those objects in the expression function.
  2. Add the interface to AggParamsMapping in types.ts
  3. Write the function, using the interface you wrote in step 1
  4. Write tests for the function
  5. Import your function in agg_types.ts and add it to getAggTypesFunctions

Metadata

Metadata

Assignees

Labels

Feature:AggregationsAggregation infrastructure (AggConfig, esaggs, ...)Feature:ExpressionLanguageInterpreter expression language (aka canvas pipeline)v7.8.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions