-
Notifications
You must be signed in to change notification settings - Fork 558
Add bucket_script and bucket_selector pipeline aggregations. #9738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add bucket_script and bucket_selector pipeline aggregations. #9738
Conversation
…ve aggregations/pipeline-agg.md; Add aggregations/pipeline/index.md. Individual aggregation files added in other PRs. Signed-off-by: Dave Welsch <[email protected]>
Signed-off-by: Dave Welsch <[email protected]>
Thank you for submitting your PR. The PR states are In progress (or Draft) -> Tech review -> Doc review -> Editorial review -> Merged. Before you submit your PR for doc review, make sure the content is technically accurate. If you need help finding a tech reviewer, tag a maintainer. When you're ready for doc review, tag the assignee of this PR. The doc reviewer may push edits to the PR directly or leave comments and editorial suggestions for you to address (let us know in a comment if you have a preference). The doc reviewer will arrange for an editorial review. |
@jainankitk Could you please review this PR? Thanks! |
|
||
## Script variables | ||
|
||
The `buckets_path` parameter maps script variable names to metrics from parent aggregations. These variables can then be used in the script. For example, the following `buckets_path` maps the `sales_sum` metric to the `total_sales` script variable and the `item_count` metric to the `item_count` script variable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The `buckets_path` parameter maps script variable names to metrics from parent aggregations. These variables can then be used in the script. For example, the following `buckets_path` maps the `sales_sum` metric to the `total_sales` script variable and the `item_count` metric to the `item_count` script variable: | |
The `buckets_path` parameter maps script variable names to metrics from parent aggregations. These variables can then be used in the script. | |
For the `bucket_script` and `bucket_selector` aggregations, the `buckets_path` parameter is an object rather than a string because it must refer to multiple bucket metrics. See the [Pipeline aggregations]({{site.url}}{{site.baseurl}}/aggregations/pipeline/index#buckets-path-property) page for a description of the string version of `buckets_path`. | |
{: .note} | |
The following `buckets_path` maps the `sales_sum` metric to the `total_sales` script variable and the `item_count` metric to the `item_count` script variable: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I still need to explicitly specify even when the mapping is identical, like for item_count
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that you still need to explicitly specify the variable mapping in buckets_path
, even if the variable name is identical to the aggregation name (e.g., item_count
).
The bucket_script
aggregation does not implicitly inherit variable names from existing aggregations or field mappings. It only knows what you explicitly pass in through buckets_path
.
| `script` | Required | String or Object | The script to execute. Can be an in-line script, stored script, or script file. The script has access to the variable names defined in the `buckets_path` parameter. Must return a Boolean value. Buckets returning `false` are removed from the final output. | | ||
| `gap_policy` | Optional | String | The policy to apply to missing data. Valid values are `skip`, `insert_zeros`, and `keep_values`. Default is `skip`. | | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the section on Script parameters
and Enabling in-line scripting
?
Signed-off-by: Fanit Kolchina <[email protected]>
Description
Add bucket_script and bucket_selector pipeline aggregations.
Issues Resolved
Version
Frontend features
Checklist
For more information on following Developer Certificate of Origin and signing off your commits, please check here.