-
Notifications
You must be signed in to change notification settings - Fork 578
Star Tree Search changes related to new Aggregations supported #9163
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
Changes from 3 commits
318915e
1a02f55
5280adb
4fbe03c
4a9d099
1cf92e2
01ba392
95fea9b
7a6a90c
ac157a1
f97a7d1
d393211
274c8a4
365aed0
1c359fd
3323395
f6eae46
6777e85
1be0ba4
531e498
a12edfc
655fce5
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 |
---|---|---|
|
@@ -140,14 +140,18 @@ | |
|
||
### Supported queries | ||
|
||
The following queries are supported as of OpenSearch 2.18: | ||
The following queries are supported as of OpenSearch 2.19: | ||
|
||
- [Term query]({{site.url}}{{site.baseurl}}/query-dsl/term/term/) | ||
- [Terms query]({{site.url}}{{site.baseurl}}/query-dsl/term/terms/) | ||
- [Match all docs query]({{site.url}}{{site.baseurl}}/query-dsl/match-all/) | ||
- [Range query]({{site.url}}{{site.baseurl}}/query-dsl/term/range/) | ||
sandeshkr419 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
To use a query with a star-tree index, the query's fields must be present in the `ordered_dimensions` section of the star-tree configuration. Queries must also be paired with a supported aggregation. | ||
To use a query in supported aggregations with a star-tree index, the query's fields must be present in the `ordered_dimensions` section of the star-tree configuration. Queries without aggregaions are not supported, they must be paired with a supported aggregation. | ||
Check failure on line 150 in _search-plugins/star-tree-index.md
|
||
|
||
### Supported aggregations | ||
|
||
Naarcha-AWS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#### Metric Aggregations | ||
Check failure on line 154 in _search-plugins/star-tree-index.md
|
||
|
||
The following metric aggregations are supported as of OpenSearch 2.18: | ||
- [Sum]({{site.url}}{{site.baseurl}}/aggregations/metric/sum/) | ||
|
@@ -156,12 +160,12 @@ | |
- [Value count]({{site.url}}{{site.baseurl}}/aggregations/metric/value-count/) | ||
- [Average]({{site.url}}{{site.baseurl}}/aggregations/metric/average/) | ||
|
||
To use aggregations: | ||
To use aggregations searchable via star-tree: | ||
Check warning on line 163 in _search-plugins/star-tree-index.md
|
||
Naarcha-AWS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- The fields must be present in the `metrics` section of the star-tree configuration. | ||
- The metric aggregation type must be part of the `stats` parameter. | ||
|
||
### Aggregation example | ||
##### Example | ||
Naarcha-AWS marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The following example gets the sum of all the values in the `size` field for all error logs with `status=500`, using the [example mapping](#example-mapping): | ||
|
||
|
@@ -185,6 +189,48 @@ | |
|
||
Using a star-tree index, the result will be retrieved from a single aggregated document as it traverses the `status=500` node, as opposed to scanning through all of the matching documents. This results in lower query latency. | ||
|
||
#### Date Histogram Aggregation with Metric Aggregations | ||
Check failure on line 192 in _search-plugins/star-tree-index.md
|
||
|
||
[Date Histogram]({{site.url}}{{site.baseurl}}/aggregations/bucket/date-histogram/) on calendar intervals with above metric sub-aggregations is supported as of OpenSearch 2.19. | ||
Check warning on line 194 in _search-plugins/star-tree-index.md
|
||
|
||
To use date histogram aggregations searchable via star-tree: | ||
Check warning on line 196 in _search-plugins/star-tree-index.md
|
||
|
||
natebower marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- The calendar intervals in star-tree mapping configuration should have either the request calendar field or a lower granularity calendar field. For example, `month` can be resolved by star-tree from `day` field as well if present in star-tree mapping. | ||
- Metric sub-aggregation must be part of the aggregation request. | ||
|
||
##### Example | ||
|
||
The following example gets the sum of all the values in the `size` field aggregated for each calendar month, for all error logs with `status=500`. | ||
|
||
```json | ||
POST /logs/_search | ||
{ | ||
"query": { | ||
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. Is this a valid query ? @sandeshkr419 just double checking. I don't see term/terms etc 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. @bharath-techie: I updated the query to add terms while keeping the method. 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. This is still not a valid query , we don't support range on timestamp. Lets reword this @Naarcha-AWS 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. @bharath-techie: Can you suggest a valid query? 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.
This is a valid query which we can use @Naarcha-AWS |
||
"term": { | ||
"status": "500" | ||
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. Can we use range query or keyword term query since term is already used in the above example ? Maybe keyword term query will be a good example. 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. @bharath-techie: I'll update the example to use a range query. |
||
} | ||
}, | ||
"size": 0, | ||
"aggs": { | ||
"by_hour": { | ||
"date_histogram": { | ||
"field": "@timestamp", | ||
"calendar_interval": "month" | ||
}, | ||
"aggs": { | ||
"sum_size": { | ||
"sum": { | ||
"field": "size" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
natebower marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Using queries without a star-tree index | ||
|
||
Set the `indices.composite_index.star_tree.enabled` setting to `false` to run queries without using a star-tree index. |
Uh oh!
There was an error while loading. Please reload this page.