You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -118,17 +136,33 @@ When using the `ordered_dimesions` parameter, follow these best practices:
118
136
119
137
- The order of dimensions matters. You can define the dimensions ordered from the highest cardinality to the lowest cardinality for efficient storage and query pruning.
120
138
- Avoid using high-cardinality fields as dimensions. High-cardinality fields adversely affect storage space, indexing throughput, and query performance.
121
-
- Currently, fields supported by the `ordered_dimensions` parameter are all [numeric field types]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/numeric/), with the exception of `unsigned_long`. For more information, see [GitHub issue #15231](https://github.com/opensearch-project/OpenSearch/issues/15231).
122
-
- Support for other field types, such as `keyword` and `ip`, will be added in future versions. For more information, see [GitHub issue #16232](https://github.com/opensearch-project/OpenSearch/issues/16232).
123
139
- A minimum of `2` and a maximum of `10` dimensions are supported per star-tree index.
124
140
141
+
The `ordered_dimensions` parameter supports the following field types:
142
+
143
+
- All numeric field types, excluding `unsigned_long` and `scaled_float`
144
+
-`keyword`
145
+
-`object`
146
+
-`date`, which can use up to three of the following calendar intervals:
147
+
-`year` (of era)
148
+
-`quarter` (of year)
149
+
-`month` (of year)
150
+
-`week` (of week-based year)
151
+
-`day` (of month)
152
+
-`hour` (of day)
153
+
-`half-hour` (of day)
154
+
-`quater-hour` (of day)
155
+
-`minute` (of hour)
156
+
-`second` (of minute)
157
+
158
+
Support for other field types, such as `ip`, will be added in future versions. For more information, see [GitHub issue #13875](https://github.com/opensearch-project/OpenSearch/issues/13875).
159
+
125
160
The `ordered_dimensions` parameter supports the following property.
126
161
127
162
| Parameter | Required/Optional | Description |
128
163
| :--- | :--- | :--- |
129
164
|`name`| Required | The name of the field. The field name should be present in the `properties` section as part of the index `mapping`. Ensure that the `doc_values` setting is `enabled` for any associated fields. |
130
165
131
-
132
166
### Metrics
133
167
134
168
Configure any metric fields on which you need to perform aggregations. `Metrics` are required as part of a star-tree index configuration.
Copy file name to clipboardExpand all lines: _search-plugins/star-tree-index.md
+67-7Lines changed: 67 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ A star-tree index can be used to perform faster aggregations. Consider the follo
26
26
27
27
Star-tree indexes have the following limitations:
28
28
29
-
- A star-tree index should only be enabled on indexes whose data is not updated or deleted because updates and deletions are not accounted for in a star-tree index.
29
+
- A star-tree index should only be enabled on indexes whose data is not updated or deleted because updates and deletions are not accounted for in a star-tree index. To enforce this policy and use star-tree indexes, set the `index.append_only.enabled` setting to `true`.
30
30
- A star-tree index can be used for aggregation queries only if the queried fields are a subset of the star-tree's dimensions and the aggregated fields are a subset of the star-tree's metrics.
31
31
- After a star-tree index is enabled, it cannot be disabled. In order to disable a star-tree index, the data in the index must be reindexed without the star-tree mapping. Furthermore, changing a star-tree configuration will also require a reindex operation.
32
32
-[Multi-values/array values]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/index/#arrays) are not supported.
@@ -68,6 +68,7 @@ To use a star-tree index, modify the following settings:
68
68
- Set the feature flag `opensearch.experimental.feature.composite_index.star_tree.enabled` to `true`. For more information about enabling and disabling feature flags, see [Enabling experimental features]({{site.url}}{{site.baseurl}}/install-and-configure/configuring-opensearch/experimental/).
69
69
- Set the `indices.composite_index.star_tree.enabled` setting to `true`. For instructions on how to configure OpenSearch, see [Configuring settings]({{site.url}}{{site.baseurl}}/install-and-configure/configuring-opensearch/index/#static-settings).
70
70
- Set the `index.composite_index` index setting to `true` during index creation.
71
+
- Set the `index.append_only.enabled` index setting to `true` during index creation.
71
72
- Ensure that the `doc_values` parameter is enabled for the `dimensions` and `metrics` fields used in your star-tree mapping.
72
73
73
74
@@ -81,7 +82,8 @@ PUT logs
81
82
"settings": {
82
83
"index.number_of_shards": 1,
83
84
"index.number_of_replicas": 0,
84
-
"index.composite_index": true
85
+
"index.composite_index": true,
86
+
"index.append_only.enabled": true
85
87
},
86
88
"mappings": {
87
89
"composite": {
@@ -94,6 +96,9 @@ PUT logs
94
96
},
95
97
{
96
98
"name": "port"
99
+
},
100
+
{
101
+
"name": "method"
97
102
}
98
103
],
99
104
"metrics": [
@@ -123,6 +128,9 @@ PUT logs
123
128
"size": {
124
129
"type": "integer"
125
130
},
131
+
"method" : {
132
+
"type": "keyword"
133
+
},
126
134
"latency": {
127
135
"type": "scaled_float",
128
136
"scaling_factor": 10
@@ -131,6 +139,7 @@ PUT logs
131
139
}
132
140
}
133
141
```
142
+
{% include copy.html %}
134
143
135
144
For detailed information about star-tree index mappings and parameters, see [Star-tree field type]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/star-tree/).
136
145
@@ -140,14 +149,20 @@ Star-tree indexes can be used to optimize queries and aggregations.
140
149
141
150
### Supported queries
142
151
143
-
The following queries are supported as of OpenSearch 2.18:
152
+
The following queries are supported as of OpenSearch 2.19:
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.
159
+
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. Queries without aggregations cannot be used with a star-tree index. Currently, queries on `date` fields are not supported and will be added in later versions.
149
160
150
161
### Supported aggregations
162
+
163
+
The following aggregations are supported by star-tree indexes.
164
+
165
+
#### Metric aggregations
151
166
152
167
The following metric aggregations are supported as of OpenSearch 2.18:
To use searchable aggregations with a star-tree index, make sure you fulfill the following prerequisites:
160
175
161
176
- The fields must be present in the `metrics` section of the star-tree configuration.
162
177
- The metric aggregation type must be part of the `stats` parameter.
163
178
164
-
### Aggregation example
165
-
166
179
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):
167
180
168
181
```json
@@ -182,9 +195,56 @@ POST /logs/_search
182
195
}
183
196
}
184
197
```
198
+
{% include copy.html %}
185
199
186
200
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.
187
201
202
+
#### Date histograms with metric aggregations
203
+
204
+
You can use [date histograms]({{site.url}}{{site.baseurl}}/aggregations/bucket/date-histogram/) on calendar intervals with metric sub-aggregations.
205
+
206
+
To use date histogram aggregations and make them searchable in a star-tree index, remember the following requirements:
207
+
208
+
- The calendar intervals in a star-tree mapping configuration can use either the request's calendar field or a field of lower granularity than the request field. For example, if an aggregation uses the `month` field, the star-tree search can still use lower-granularity fields such as `day`.
209
+
- A metric sub-aggregation must be part of the aggregation request.
210
+
211
+
The following example gets the sum of all the values in the `size` field with a range query, aggregated for each calendar month, for all error logs containing `method:get`:
212
+
213
+
```json
214
+
POST /logs/_search
215
+
{
216
+
{
217
+
"query": {
218
+
"range": {
219
+
"created": {
220
+
"gte": "2019/01/01",
221
+
"lte": "2019/12/31"
222
+
},
223
+
"method": {
224
+
"status": "get"
225
+
}
226
+
},
227
+
"size": 0,
228
+
"aggs": {
229
+
"by_hour": {
230
+
"date_histogram": {
231
+
"field": "@timestamp",
232
+
"calendar_interval": "month"
233
+
},
234
+
"aggs": {
235
+
"sum_size": {
236
+
"sum": {
237
+
"field": "size"
238
+
}
239
+
}
240
+
}
241
+
}
242
+
}
243
+
}
244
+
```
245
+
{% include copy-curl.html %}
246
+
247
+
188
248
## Using queries without a star-tree index
189
249
190
250
Set the `indices.composite_index.star_tree.enabled` setting to `false` to run queries without using a star-tree index.
0 commit comments