diff --git a/docs/reference/api-reference.md b/docs/reference/api-reference.md index 7034ba1c8..38b3a89fd 100644 --- a/docs/reference/api-reference.md +++ b/docs/reference/api-reference.md @@ -474,6 +474,7 @@ client.deleteByQuery({ index }) - **`max_docs` (Optional, number)**: The maximum number of documents to delete. - **`query` (Optional, { bool, boosting, common, combined_fields, constant_score, dis_max, distance_feature, exists, function_score, fuzzy, geo_bounding_box, geo_distance, geo_grid, geo_polygon, geo_shape, has_child, has_parent, ids, intervals, knn, match, match_all, match_bool_prefix, match_none, match_phrase, match_phrase_prefix, more_like_this, multi_match, nested, parent_id, percolate, pinned, prefix, query_string, range, rank_feature, regexp, rule, script, script_score, semantic, shape, simple_query_string, span_containing, span_field_masking, span_first, span_multi, span_near, span_not, span_or, span_term, span_within, sparse_vector, term, terms, terms_set, text_expansion, weighted_tokens, wildcard, wrapper, type })**: The documents to delete specified with Query DSL. - **`slice` (Optional, { field, id, max })**: Slice the request manually using the provided slice ID and total number of slices. +- **`sort` (Optional, string \| { _score, _doc, _geo_distance, _script } \| string \| { _score, _doc, _geo_distance, _script }[])**: A sort object that specifies the order of deleted documents. - **`allow_no_indices` (Optional, boolean)**: If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`. - **`analyzer` (Optional, string)**: Analyzer to use for the query string. This parameter can be used only when the `q` query string parameter is specified. - **`analyze_wildcard` (Optional, boolean)**: If `true`, wildcard and prefix queries are analyzed. This parameter can be used only when the `q` query string parameter is specified. @@ -495,7 +496,6 @@ client.deleteByQuery({ index }) - **`search_timeout` (Optional, string \| -1 \| 0)**: The explicit timeout for each search request. It defaults to no timeout. - **`search_type` (Optional, Enum("query_then_fetch" \| "dfs_query_then_fetch"))**: The type of the search operation. Available options include `query_then_fetch` and `dfs_query_then_fetch`. - **`slices` (Optional, number \| Enum("auto"))**: The number of slices this task should be divided into. -- **`sort` (Optional, string[])**: A list of `:` pairs. - **`stats` (Optional, string[])**: The specific `tag` of the request for logging and statistical purposes. - **`terminate_after` (Optional, number)**: The maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting. Use with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers. - **`timeout` (Optional, string \| -1 \| 0)**: The period each deletion request waits for active shards. @@ -1343,7 +1343,7 @@ Additionally, if you opt to count version conflicts, the operation could attempt It's recommended to reindex on indices with a green status. Reindexing can fail when a node shuts down or crashes. * When requested with `wait_for_completion=true` (default), the request fails if the node shuts down. -* When requested with `wait_for_completion=false`, a task id is returned, which can be used via the task management API to monitor, debug, or cancel the task. The task may disappear or fail if the node shuts down. +* When requested with `wait_for_completion=false`, a task id is returned, for use with the task management APIs. The task may disappear or fail if the node shuts down. When retrying a failed reindex operation, it might be necessary to set `conflicts=proceed` or to first delete the partial destination index. Additionally, dry runs, checking disk space, and fetching index recovery information can help address the root cause. @@ -6935,7 +6935,7 @@ For example, a request targeting `foo*,bar*` returns an error if an index starts ## client.indices.rollover [_indices.rollover] Roll over to a new index. -TIP: It is recommended to use the index lifecycle rollover action to automate rollovers. +TIP: We recommend using the index lifecycle rollover action to automate rollovers. However, Serverless does not support Index Lifecycle Management (ILM), so don't use this approach in the Serverless context. The rollover API creates a new index for a data stream or index alias. The API behavior depends on the rollover target. @@ -14841,14 +14841,33 @@ client.transform.scheduleNowTransform({ transform_id }) - **`timeout` (Optional, string \| -1 \| 0)**: Controls the time to wait for the scheduling to take place ## client.transform.setUpgradeMode [_transform.set_upgrade_mode] -Sets a cluster wide upgrade_mode setting that prepares transform indices for an upgrade. +Set upgrade_mode for transform indices. +Sets a cluster wide upgrade_mode setting that prepares transform +indices for an upgrade. +When upgrading your cluster, in some circumstances you must restart your +nodes and reindex your transform indices. In those circumstances, +there must be no transforms running. You can close the transforms, +do the upgrade, then open all the transforms again. Alternatively, +you can use this API to temporarily halt tasks associated with the transforms +and prevent new transforms from opening. You can also use this API +during upgrades that do not require you to reindex your transform +indices, though stopping transforms is not a requirement in that case. +You can see the current value for the upgrade_mode setting by using the get +transform info API. -[Endpoint documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/transform-set-upgrade-mode.html) +[Endpoint documentation](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-set-upgrade-mode) ```ts -client.transform.setUpgradeMode() +client.transform.setUpgradeMode({ ... }) ``` +### Arguments [_arguments_transform.set_upgrade_mode] + +#### Request (object) [_request_transform.set_upgrade_mode] +- **`enabled` (Optional, boolean)**: When `true`, it enables `upgrade_mode` which temporarily halts all +transform tasks and prohibits new transform tasks from +starting. +- **`timeout` (Optional, string \| -1 \| 0)**: The time to wait for the request to be completed. ## client.transform.startTransform [_transform.start_transform] Start a transform. diff --git a/src/api/api/delete_by_query.ts b/src/api/api/delete_by_query.ts index 4604c0ac1..16a66ef3b 100644 --- a/src/api/api/delete_by_query.ts +++ b/src/api/api/delete_by_query.ts @@ -36,7 +36,8 @@ const acceptedParams: Record`. If you create the index on May 6, 2099, the index's name is `my-index-2099.05.06-000001`. If you roll over the alias on May 7, 2099, the new index's name is `my-index-2099.05.07-000002`. + * Roll over to a new index. TIP: We recommend using the index lifecycle rollover action to automate rollovers. However, Serverless does not support Index Lifecycle Management (ILM), so don't use this approach in the Serverless context. The rollover API creates a new index for a data stream or index alias. The API behavior depends on the rollover target. **Roll over a data stream** If you roll over a data stream, the API creates a new write index for the stream. The stream's previous write index becomes a regular backing index. A rollover also increments the data stream's generation. **Roll over an index alias with a write index** TIP: Prior to Elasticsearch 7.9, you'd typically use an index alias with a write index to manage time series data. Data streams replace this functionality, require less maintenance, and automatically integrate with data tiers. If an index alias points to multiple indices, one of the indices must be a write index. The rollover API creates a new write index for the alias with `is_write_index` set to `true`. The API also `sets is_write_index` to `false` for the previous write index. **Roll over an index alias with one index** If you roll over an index alias that points to only one index, the API creates a new index for the alias and removes the original index from the alias. NOTE: A rollover creates a new index and is subject to the `wait_for_active_shards` setting. **Increment index names for an alias** When you roll over an index alias, you can specify a name for the new index. If you don't specify a name and the current index ends with `-` and a number, such as `my-index-000001` or `my-index-3`, the new index name increments that number. For example, if you roll over an alias with a current index of `my-index-000001`, the rollover creates a new index named `my-index-000002`. This number is always six characters and zero-padded, regardless of the previous index's name. If you use an index alias for time series data, you can use date math in the index name to track the rollover date. For example, you can create an alias that points to an index named ``. If you create the index on May 6, 2099, the index's name is `my-index-2099.05.06-000001`. If you roll over the alias on May 7, 2099, the new index's name is `my-index-2099.05.07-000002`. * @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-indices-rollover | Elasticsearch API documentation} */ async rollover (this: That, params: T.IndicesRolloverRequest, options?: TransportRequestOptionsWithOutMeta): Promise diff --git a/src/api/api/reindex.ts b/src/api/api/reindex.ts index 1522c8fe6..c280e26e8 100644 --- a/src/api/api/reindex.ts +++ b/src/api/api/reindex.ts @@ -54,7 +54,7 @@ const acceptedParams: Record diff --git a/src/api/api/transform.ts b/src/api/api/transform.ts index 238fa065f..f98f60512 100644 --- a/src/api/api/transform.ts +++ b/src/api/api/transform.ts @@ -137,7 +137,10 @@ export default class Transform { 'transform.set_upgrade_mode': { path: [], body: [], - query: [] + query: [ + 'enabled', + 'timeout' + ] }, 'transform.start_transform': { path: [ @@ -590,13 +593,13 @@ export default class Transform { } /** - * Sets a cluster wide upgrade_mode setting that prepares transform indices for an upgrade. - * @see {@link https://www.elastic.co/guide/en/elasticsearch/reference/9.0/transform-set-upgrade-mode.html | Elasticsearch API documentation} + * Set upgrade_mode for transform indices. Sets a cluster wide upgrade_mode setting that prepares transform indices for an upgrade. When upgrading your cluster, in some circumstances you must restart your nodes and reindex your transform indices. In those circumstances, there must be no transforms running. You can close the transforms, do the upgrade, then open all the transforms again. Alternatively, you can use this API to temporarily halt tasks associated with the transforms and prevent new transforms from opening. You can also use this API during upgrades that do not require you to reindex your transform indices, though stopping transforms is not a requirement in that case. You can see the current value for the upgrade_mode setting by using the get transform info API. + * @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-transform-set-upgrade-mode | Elasticsearch API documentation} */ - async setUpgradeMode (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise - async setUpgradeMode (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise> - async setUpgradeMode (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise - async setUpgradeMode (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise { + async setUpgradeMode (this: That, params?: T.TransformSetUpgradeModeRequest, options?: TransportRequestOptionsWithOutMeta): Promise + async setUpgradeMode (this: That, params?: T.TransformSetUpgradeModeRequest, options?: TransportRequestOptionsWithMeta): Promise> + async setUpgradeMode (this: That, params?: T.TransformSetUpgradeModeRequest, options?: TransportRequestOptions): Promise + async setUpgradeMode (this: That, params?: T.TransformSetUpgradeModeRequest, options?: TransportRequestOptions): Promise { const { path: acceptedPath } = this.acceptedParams['transform.set_upgrade_mode'] @@ -619,6 +622,7 @@ export default class Transform { if (acceptedPath.includes(key)) { continue } else if (key !== 'body' && key !== 'querystring') { + // @ts-expect-error querystring[key] = params[key] } } diff --git a/src/api/types.ts b/src/api/types.ts index e6852721c..9df77b139 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -434,8 +434,6 @@ export interface DeleteByQueryRequest extends RequestBase { search_type?: SearchType /** The number of slices this task should be divided into. */ slices?: Slices - /** A comma-separated list of `:` pairs. */ - sort?: string[] /** The specific `tag` of the request for logging and statistical purposes. */ stats?: string[] /** The maximum number of documents to collect for each shard. @@ -464,10 +462,12 @@ export interface DeleteByQueryRequest extends RequestBase { query?: QueryDslQueryContainer /** Slice the request manually using the provided slice ID and total number of slices. */ slice?: SlicedScroll + /** A sort object that specifies the order of deleted documents. */ + sort?: Sort /** All values in `body` will be added to the request body. */ - body?: string | { [key: string]: any } & { index?: never, allow_no_indices?: never, analyzer?: never, analyze_wildcard?: never, conflicts?: never, default_operator?: never, df?: never, expand_wildcards?: never, from?: never, ignore_unavailable?: never, lenient?: never, preference?: never, refresh?: never, request_cache?: never, requests_per_second?: never, routing?: never, q?: never, scroll?: never, scroll_size?: never, search_timeout?: never, search_type?: never, slices?: never, sort?: never, stats?: never, terminate_after?: never, timeout?: never, version?: never, wait_for_active_shards?: never, wait_for_completion?: never, max_docs?: never, query?: never, slice?: never } + body?: string | { [key: string]: any } & { index?: never, allow_no_indices?: never, analyzer?: never, analyze_wildcard?: never, conflicts?: never, default_operator?: never, df?: never, expand_wildcards?: never, from?: never, ignore_unavailable?: never, lenient?: never, preference?: never, refresh?: never, request_cache?: never, requests_per_second?: never, routing?: never, q?: never, scroll?: never, scroll_size?: never, search_timeout?: never, search_type?: never, slices?: never, stats?: never, terminate_after?: never, timeout?: never, version?: never, wait_for_active_shards?: never, wait_for_completion?: never, max_docs?: never, query?: never, slice?: never, sort?: never } /** All values in `querystring` will be added to the request querystring. */ - querystring?: { [key: string]: any } & { index?: never, allow_no_indices?: never, analyzer?: never, analyze_wildcard?: never, conflicts?: never, default_operator?: never, df?: never, expand_wildcards?: never, from?: never, ignore_unavailable?: never, lenient?: never, preference?: never, refresh?: never, request_cache?: never, requests_per_second?: never, routing?: never, q?: never, scroll?: never, scroll_size?: never, search_timeout?: never, search_type?: never, slices?: never, sort?: never, stats?: never, terminate_after?: never, timeout?: never, version?: never, wait_for_active_shards?: never, wait_for_completion?: never, max_docs?: never, query?: never, slice?: never } + querystring?: { [key: string]: any } & { index?: never, allow_no_indices?: never, analyzer?: never, analyze_wildcard?: never, conflicts?: never, default_operator?: never, df?: never, expand_wildcards?: never, from?: never, ignore_unavailable?: never, lenient?: never, preference?: never, refresh?: never, request_cache?: never, requests_per_second?: never, routing?: never, q?: never, scroll?: never, scroll_size?: never, search_timeout?: never, search_type?: never, slices?: never, stats?: never, terminate_after?: never, timeout?: never, version?: never, wait_for_active_shards?: never, wait_for_completion?: never, max_docs?: never, query?: never, slice?: never, sort?: never } } export interface DeleteByQueryResponse { @@ -4557,10 +4557,17 @@ export type Service = string export interface ShardFailure { index?: IndexName + /** @alias index */ + _index?: IndexName node?: string + /** @alias node */ + _node?: string reason: ErrorCause - shard: integer + shard?: integer + /** @alias shard */ + _shard?: integer status?: string + primary?: boolean } export interface ShardStatistics { @@ -36832,6 +36839,21 @@ export interface TransformScheduleNowTransformRequest extends RequestBase { export type TransformScheduleNowTransformResponse = AcknowledgedResponseBase +export interface TransformSetUpgradeModeRequest extends RequestBase { + /** When `true`, it enables `upgrade_mode` which temporarily halts all + * transform tasks and prohibits new transform tasks from + * starting. */ + enabled?: boolean + /** The time to wait for the request to be completed. */ + timeout?: Duration + /** All values in `body` will be added to the request body. */ + body?: string | { [key: string]: any } & { enabled?: never, timeout?: never } + /** All values in `querystring` will be added to the request querystring. */ + querystring?: { [key: string]: any } & { enabled?: never, timeout?: never } +} + +export type TransformSetUpgradeModeResponse = AcknowledgedResponseBase + export interface TransformStartTransformRequest extends RequestBase { /** Identifier for the transform. */ transform_id: Id