-
Notifications
You must be signed in to change notification settings - Fork 508
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
Add composite aggregation documentation #7666
base: main
Are you sure you want to change the base?
Changes from 2 commits
978dcdd
bcf8016
c4144e0
6850148
13d7217
621d0c0
1fdb04d
e8adaf2
5b7b264
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
layout: default | ||
title: Composite | ||
parent: Bucket aggregations | ||
grand_parent: Aggregations | ||
nav_order: 20 | ||
has_children: true | ||
--- | ||
|
||
# Composite | ||
|
||
The `composite` aggregation is a multi-bucket aggregation that creates composite buckets from different sources. It is useful for efficiently paginating multi-level aggregations and retrieving all buckets. Composite buckets are built from combinations of values extracted from documents for each specified source field. | ||
|
||
## Syntax | ||
|
||
```json | ||
{ | ||
"composite": { | ||
"sources": [ | ||
{ | ||
"source_field_1": { | ||
"terms": { | ||
"field": "field_name" | ||
} | ||
} | ||
}, | ||
{ | ||
"source_field_2": { | ||
"terms": { | ||
"field": "another_field_name" | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
Property | Description | | ||
---------|------------| | ||
`composite` | The aggregation type. | ||
`sources ` | An array of source objects, where each object defines a source field for the composite buckets. | ||
`terms` | The subaggregation type used to extract the values from the specified field for each source. | ||
`field` | The field name in your documents from which the values will be extracted for the corresponding source. | ||
|
||
For example, consider the following document: | ||
|
||
```json | ||
{ | ||
"product": "T-Shirt", | ||
"category": "Clothing", | ||
"brand": "Acme", | ||
"price": 19.99, | ||
"sizes": ["S", "M", "L"], | ||
"colors": ["red", "blue"] | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
Using `sizes` and `colors` as source fields for the aggregation results in the following composite buckets: | ||
|
||
```json | ||
{ "sizes": "S", "colors": "red" } | ||
{ "sizes": "S", "colors": "blue" } | ||
{ "sizes": "M", "colors": "red" } | ||
{ "sizes": "M", "colors": "blue" } | ||
{ "sizes": "L", "colors": "red" } | ||
{ "sizes": "L", "colors": "blue" } | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Compatibility and limitations | ||
|
||
<SME: What version of OpenSearch is this compatible with? What are the limitations?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technical reviewer: Please provide information about compatibility and limitations. |
||
|
||
## Performance considerations | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technical reviewer: Please provide information about performance considerations, if any. |
||
|
||
<What are the performance implications or best practices for using this aggregation?> |
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.
Technical reviewer: Please review this content and confirm the syntax and examples are accurate and relevant to an OpenSearch user. I tested the examples using Dev Tools. If another example is more appropriate, please replace the draft example with your example. Thank you.