File tree Expand file tree Collapse file tree 3 files changed +103
-1
lines changed
docs/rest_apis/data_stream_apis Expand file tree Collapse file tree 3 files changed +103
-1
lines changed Original file line number Diff line number Diff line change @@ -921,6 +921,7 @@ npm run docs:dev
921921 - :heavy_check_mark : 数据流统计 [ :link : ] ( https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/data_stream_stats )
922922 - :heavy_check_mark : 推广数据流 [ :link : ] ( https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/promote_data_stream )
923923 - :heavy_check_mark : 修改数据流 [ :link : ] ( https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/modify_data_stream )
924+ - :heavy_check_mark : 设置数据流生命周期 [ :link : ] ( https://elasticsearch.bookhub.tech/rest_apis/data_stream_apis/put_data_stream_lifecycle )
924925 - :heavy_check_mark : 文档 API [ :link : ] ( https://elasticsearch.bookhub.tech/rest_apis/document_apis/ )
925926 - :heavy_check_mark : 读写 API [ :link : ] ( https://elasticsearch.bookhub.tech/rest_apis/document_apis/replication )
926927 - :heavy_check_mark : 索引 API [ :link : ] ( https://elasticsearch.bookhub.tech/rest_apis/document_apis/docs_index )
Original file line number Diff line number Diff line change 1+ # 设置数据流生命周期
2+
3+ 为目标[ 数据流] ( /data-streams ) 配置数据流[ 生命周期] ( /data-streams/data-stream-lifecycle ) 。
4+
5+ ## 前置条件
6+
7+ - 如果 Elasticsearch 安全特性启用,你使用此 API 必须有 ` manage_data_stream_lifecycle ` 或更高的[ 索引权限] ( /secure_the_elastic_statck/user_authorization/security_privileges#索引权限 ) 。更多信息,参阅[ 安全权限] ( /secure_the_elastic_statck/user_authorization/security_privileges ) 。
8+
9+ ## 请求
10+
11+ ` PUT _data_stream/<data-stream>/_lifecycle `
12+
13+ ## 描述
14+
15+ 为目标数据流配置数据流生命周期。如果提供了多个数据流,但其中有一个以上不存在,那么生命周期的更新将对所有数据流都失败,API 将响应 ` 404 ` 。
16+
17+ ## 路径参数
18+
19+ - ` <data-stream> `
20+
21+ (必需,字符串) 用于限制请求的数据流的逗号分隔列表。支持通配符 (` * ` )。要针对所有数据流,请使用 ` * ` 或 ` _all ` 。
22+
23+ ## 查询参数
24+
25+ - ` expand_wildcards `
26+
27+ (可选,字符串)通配符模式可以匹配的数据流类型。支持逗号分隔值,例如 ` open,hidden ` 。有效值为:
28+
29+ - ` all ` ,` hidden `
30+
31+ 匹配任何数据流或索引,包括[隐藏的](/rest_apis/api_conventions/multi_target_syntax#隐藏数据流和索引)。
32+
33+ - ` open ` ,` closed `
34+
35+ 匹配任何非隐藏的数据流。无法关闭 Data Streams。
36+
37+ - ` none `
38+
39+ 不接受通配符模式。
40+
41+ 默认为 ` open ` 。
42+
43+ ## 请求体
44+
45+ - ` lifecycle `
46+
47+ (必需,对象)
48+
49+ - ` lifecycle ` 的属性
50+
51+ - `data_retention`
52+
53+ (可选,字符串)如果定义,则添加到此数据流中的每个文档都将至少在此时间段内保存。在此期限之后的任何时间,文档都可能被删除。如果为空,则该数据流中的每份文档都将无限期存储。
54+
55+ - `enabled`
56+
57+ (可选,布尔值)如果定义,则打开/关闭(`true`/`false`)该数据流的数据流生命周期。禁用(`enabled: false`)的数据流生命周期对数据流没有任何影响。默认为 `true`。
58+
59+ - `downsampling`
60+
61+ (可选,数组)一个可选的下采样配置对象数组,每个对象都定义了一个后间隔(`after`)和一个固定间隔(`fixed_interval`),后间隔代表何时要对后备索引进行下采样(时间范围从索引滚动开始计算,即生成时间),`fixed_interval` 代表下采样间隔(`fixed_interval` 最小值为 `5m`)。最多可配置 10 轮向下采样。参阅下面的[配置](#示例)示例。
62+
63+ ## 示例
64+
65+ 下面的示例设置了 ` my-data-stream ` 的生命周期:
66+
67+ ``` bash
68+ PUT _data_stream/my-data-stream/_lifecycle
69+ {
70+ " data_retention" : " 7d"
71+ }
72+ ```
73+
74+ 当生命周期在所有数据流中更新成功后,你会收到以下结果:
75+
76+ ``` json
77+ {
78+ "acknowledged" : true
79+ }
80+ ```
81+
82+ 下面的示例配置了两轮下采样,第一轮在后备索引滚动一天后开始(或更晚,如果索引仍在其写入接受时间范围内),间隔为 ` 10m ` ,第二轮在滚动 7 天后开始,间隔为 ` 1d ` :
83+
84+ ``` bash
85+ PUT _data_stream/my-weather-sensor-data-stream/_lifecycle
86+ {
87+ " downsampling" : [
88+ {
89+ " after" : " 1d" ,
90+ " fixed_interval" : " 10m"
91+ },
92+ {
93+ " after" : " 7d" ,
94+ " fixed_interval" : " 1d"
95+ }
96+ ]
97+ }
98+ ```
99+
100+ > [ 原文链接] ( https://www.elastic.co/guide/en/elasticsearch/reference/current/data-streams-put-lifecycle.html )
Original file line number Diff line number Diff line change @@ -162,7 +162,8 @@ const sidebars = {
162162 'rest_apis/data_stream_apis/migrate_to_data_stream' ,
163163 'rest_apis/data_stream_apis/data_stream_stats' ,
164164 'rest_apis/data_stream_apis/promote_data_stream' ,
165- 'rest_apis/data_stream_apis/modify_data_stream'
165+ 'rest_apis/data_stream_apis/modify_data_stream' ,
166+ 'rest_apis/data_stream_apis/put_data_stream_lifecycle'
166167 ]
167168 } ,
168169 {
You can’t perform that action at this time.
0 commit comments