Skip to content

Commit 17f3318

Browse files
authored
[7.x] Resolve index API (#58037)
1 parent 076b32d commit 17f3318

File tree

15 files changed

+1682
-15
lines changed

15 files changed

+1682
-15
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,8 @@ public void testApiNamingConventions() throws Exception {
804804
"indices.create_data_stream",
805805
"indices.get_data_stream",
806806
"indices.delete_data_stream",
807-
"indices.simulate_template"
807+
"indices.simulate_template",
808+
"indices.resolve_index"
808809
};
809810
//These API are not required for high-level client feature completeness
810811
String[] notRequiredApi = new String[] {

qa/multi-cluster-search/src/test/java/org/elasticsearch/search/CCSDuelIT.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ protected boolean preserveIndicesUponCompletion() {
161161
return true;
162162
}
163163

164+
@Override
165+
protected boolean preserveDataStreamsUponCompletion() {
166+
return true;
167+
}
168+
164169
private static void indexDocuments(String idPrefix) throws IOException, InterruptedException {
165170
//this index with a single document is used to test partial failures
166171
IndexRequest indexRequest = new IndexRequest(INDEX_NAME + "_err");
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
"Resolve index with indices, aliases, and data streams":
3+
- skip:
4+
version: " - 7.99.99"
5+
reason: not backported yet
6+
7+
- do:
8+
indices.resolve_index:
9+
name: 'my_remote_cluster:*'
10+
expand_wildcards: [all]
11+
12+
- match: {indices.0.name: my_remote_cluster:.ds-simple-data-stream1-000001}
13+
- match: {indices.0.attributes.0: hidden}
14+
- match: {indices.0.attributes.1: open}
15+
- match: {indices.0.data_stream: simple-data-stream1}
16+
- match: {indices.1.name: my_remote_cluster:.ds-simple-data-stream2-000001}
17+
- match: {indices.1.attributes.0: hidden}
18+
- match: {indices.1.attributes.1: open}
19+
- match: {indices.1.data_stream: simple-data-stream2}
20+
- match: {indices.2.name: my_remote_cluster:.ds-simple-data-stream2-000002}
21+
- match: {indices.2.attributes.0: hidden}
22+
- match: {indices.2.attributes.1: open}
23+
- match: {indices.2.data_stream: simple-data-stream2}
24+
- match: {indices.3.name: my_remote_cluster:ccs_duel_index}
25+
- match: {indices.3.attributes.0: open}
26+
- match: {indices.4.name: my_remote_cluster:ccs_duel_index_empty}
27+
- match: {indices.4.attributes.0: open}
28+
- match: {indices.5.name: my_remote_cluster:ccs_duel_index_err}
29+
- match: {indices.5.attributes.0: open}
30+
- match: {indices.6.name: my_remote_cluster:closed_index}
31+
- match: {indices.6.aliases.0: aliased_closed_index}
32+
- match: {indices.6.attributes.0: closed}
33+
- match: {indices.7.name: my_remote_cluster:field_caps_index_1}
34+
- match: {indices.7.attributes.0: open}
35+
- match: {indices.8.name: my_remote_cluster:field_caps_index_3}
36+
- match: {indices.8.attributes.0: open}
37+
- match: {indices.9.name: my_remote_cluster:single_doc_index}
38+
- match: {indices.9.attributes.0: open}
39+
- match: {indices.10.name: my_remote_cluster:test_index}
40+
- match: {indices.10.aliases.0: aliased_test_index}
41+
- match: {indices.10.attributes.0: open}
42+
- match: {aliases.0.name: my_remote_cluster:aliased_closed_index}
43+
- match: {aliases.0.indices.0: closed_index}
44+
- match: {aliases.1.name: my_remote_cluster:aliased_test_index}
45+
- match: {aliases.1.indices.0: test_index}
46+
- match: {data_streams.0.name: my_remote_cluster:simple-data-stream1}
47+
- match: {data_streams.0.backing_indices.0: .ds-simple-data-stream1-000001}
48+
- match: {data_streams.0.timestamp_field: "@timestamp"}
49+
- match: {data_streams.1.name: my_remote_cluster:simple-data-stream2}
50+
- match: {data_streams.1.backing_indices.0: .ds-simple-data-stream2-000001}
51+
- match: {data_streams.1.backing_indices.1: .ds-simple-data-stream2-000002}
52+
- match: {data_streams.1.timestamp_field: "@timestamp2"}

qa/multi-cluster-search/src/test/resources/rest-api-spec/test/remote_cluster/10_basic.yml

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,48 @@
11
---
22
"Index data and search on the old cluster":
3+
- skip:
4+
features: allowed_warnings
5+
6+
- do:
7+
allowed_warnings:
8+
- "index template [my-template1] has index patterns [simple-data-stream1] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template1] will take precedence during new index creation"
9+
indices.put_index_template:
10+
name: my-template1
11+
body:
12+
index_patterns: [simple-data-stream1]
13+
template:
14+
mappings:
15+
properties:
16+
'@timestamp':
17+
type: date
18+
data_stream:
19+
timestamp_field: '@timestamp'
20+
- do:
21+
allowed_warnings:
22+
- "index template [my-template2] has index patterns [simple-data-stream2] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template2] will take precedence during new index creation"
23+
indices.put_index_template:
24+
name: my-template2
25+
body:
26+
index_patterns: [simple-data-stream2]
27+
template:
28+
mappings:
29+
properties:
30+
'@timestamp2':
31+
type: date
32+
data_stream:
33+
timestamp_field: '@timestamp2'
34+
35+
- do:
36+
indices.create_data_stream:
37+
name: simple-data-stream1
38+
39+
- do:
40+
indices.create_data_stream:
41+
name: simple-data-stream2
42+
43+
- do:
44+
indices.rollover:
45+
alias: "simple-data-stream2"
346

447
- do:
548
indices.create:
@@ -72,6 +115,18 @@
72115
nested2:
73116
type: keyword
74117
doc_values: false
118+
119+
- do:
120+
indices.create:
121+
index: closed_index
122+
body:
123+
aliases:
124+
aliased_closed_index: {}
125+
126+
- do:
127+
indices.close:
128+
index: closed_index
129+
75130
- do:
76131
indices.create:
77132
index: test_index
@@ -128,5 +183,3 @@
128183
- match: { hits.total: 2 }
129184
- match: { hits.hits.0._source.filter_field: 1 }
130185
- match: { hits.hits.0._index: "test_index" }
131-
132-
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"indices.resolve_index":{
3+
"documentation":{
4+
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index.html",
5+
"description":"Returns information about any matching indices, aliases, and data streams"
6+
},
7+
"stability":"experimental",
8+
"url":{
9+
"paths":[
10+
{
11+
"path":"/_resolve/index/{name}",
12+
"methods":[
13+
"GET"
14+
],
15+
"parts":{
16+
"name":{
17+
"type":"list",
18+
"description":"A comma-separated list of names or wildcard expressions"
19+
}
20+
}
21+
}
22+
]
23+
},
24+
"params":{
25+
"expand_wildcards":{
26+
"type":"enum",
27+
"options":[
28+
"open",
29+
"closed",
30+
"hidden",
31+
"none",
32+
"all"
33+
],
34+
"default":"open",
35+
"description":"Whether wildcard expressions should get expanded to open or closed indices (default: open)"
36+
}
37+
}
38+
}
39+
}
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
---
2+
setup:
3+
- skip:
4+
version: " - 7.99.99"
5+
reason: change after backporting
6+
features: allowed_warnings
7+
8+
- do:
9+
allowed_warnings:
10+
- "index template [my-template1] has index patterns [simple-data-stream1] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template1] will take precedence during new index creation"
11+
indices.put_index_template:
12+
name: my-template1
13+
body:
14+
index_patterns: [simple-data-stream1]
15+
template:
16+
mappings:
17+
properties:
18+
'@timestamp':
19+
type: date
20+
data_stream:
21+
timestamp_field: '@timestamp'
22+
- do:
23+
allowed_warnings:
24+
- "index template [my-template2] has index patterns [simple-data-stream2] matching patterns from existing older templates [global] with patterns (global => [*]); this template [my-template2] will take precedence during new index creation"
25+
indices.put_index_template:
26+
name: my-template2
27+
body:
28+
index_patterns: [simple-data-stream2]
29+
template:
30+
mappings:
31+
properties:
32+
'@timestamp2':
33+
type: date
34+
data_stream:
35+
timestamp_field: '@timestamp2'
36+
37+
- do:
38+
indices.create_data_stream:
39+
name: simple-data-stream1
40+
41+
- do:
42+
indices.create_data_stream:
43+
name: simple-data-stream2
44+
45+
- do:
46+
indices.rollover:
47+
alias: "simple-data-stream2"
48+
49+
- do:
50+
indices.create:
51+
index: test_index1
52+
body:
53+
aliases:
54+
test_alias: {}
55+
test_blias: {}
56+
test_clias: {}
57+
58+
- do:
59+
indices.create:
60+
index: test_index2
61+
body:
62+
aliases:
63+
test_alias: {}
64+
65+
- do:
66+
indices.close:
67+
index: test_index2
68+
69+
- do:
70+
indices.create:
71+
index: test_index3
72+
body:
73+
aliases:
74+
test_blias: {}
75+
76+
---
77+
"Resolve index with indices, aliases, and data streams":
78+
- skip:
79+
version: " - 7.99.99"
80+
reason: change after backporting
81+
82+
- do:
83+
indices.resolve_index:
84+
name: '*'
85+
86+
- match: {indices.0.name: test_index1}
87+
- match: {indices.0.aliases.0: test_alias}
88+
- match: {indices.0.aliases.1: test_blias}
89+
- match: {indices.0.aliases.2: test_clias}
90+
- match: {indices.0.attributes.0: open}
91+
- match: {indices.1.name: test_index3}
92+
- match: {indices.1.aliases.0: test_blias}
93+
- match: {indices.1.attributes.0: open}
94+
- match: {aliases.0.name: test_alias}
95+
- match: {aliases.0.indices.0: test_index1}
96+
- match: {aliases.0.indices.1: test_index2}
97+
- match: {aliases.1.name: test_blias}
98+
- match: {aliases.1.indices.0: test_index1}
99+
- match: {aliases.1.indices.1: test_index3}
100+
- match: {aliases.2.name: test_clias}
101+
- match: {aliases.2.indices.0: test_index1}
102+
- match: {data_streams.0.name: simple-data-stream1}
103+
- match: {data_streams.0.backing_indices.0: .ds-simple-data-stream1-000001}
104+
- match: {data_streams.0.timestamp_field: "@timestamp"}
105+
- match: {data_streams.1.name: simple-data-stream2}
106+
- match: {data_streams.1.backing_indices.0: .ds-simple-data-stream2-000001}
107+
- match: {data_streams.1.backing_indices.1: .ds-simple-data-stream2-000002}
108+
- match: {data_streams.1.timestamp_field: "@timestamp2"}
109+
110+
- do:
111+
indices.delete_data_stream:
112+
name: simple-data-stream1
113+
- is_true: acknowledged
114+
115+
- do:
116+
indices.delete_data_stream:
117+
name: simple-data-stream2
118+
- is_true: acknowledged
119+
120+
---
121+
"Resolve index with hidden and closed indices":
122+
- skip:
123+
version: " - 7.99.99"
124+
reason: change after backporting
125+
126+
- do:
127+
indices.resolve_index:
128+
name: '*'
129+
expand_wildcards: [all]
130+
131+
- match: {indices.0.name: .ds-simple-data-stream1-000001}
132+
- match: {indices.0.attributes.0: hidden}
133+
- match: {indices.0.attributes.1: open}
134+
- match: {indices.0.data_stream: simple-data-stream1}
135+
- match: {indices.1.name: .ds-simple-data-stream2-000001}
136+
- match: {indices.1.attributes.0: hidden}
137+
- match: {indices.1.attributes.1: open}
138+
- match: {indices.1.data_stream: simple-data-stream2}
139+
- match: {indices.2.name: .ds-simple-data-stream2-000002}
140+
- match: {indices.2.attributes.0: hidden}
141+
- match: {indices.2.attributes.1: open}
142+
- match: {indices.2.data_stream: simple-data-stream2}
143+
- match: {indices.3.name: test_index1}
144+
- match: {indices.3.aliases.0: test_alias}
145+
- match: {indices.3.aliases.1: test_blias}
146+
- match: {indices.3.aliases.2: test_clias}
147+
- match: {indices.3.attributes.0: open}
148+
- match: {indices.4.name: test_index2}
149+
- match: {indices.4.aliases.0: test_alias}
150+
- match: {indices.4.attributes.0: closed}
151+
- match: {indices.5.name: test_index3}
152+
- match: {indices.5.aliases.0: test_blias}
153+
- match: {indices.5.attributes.0: open}
154+
- match: {aliases.0.name: test_alias}
155+
- match: {aliases.0.indices.0: test_index1}
156+
- match: {aliases.0.indices.1: test_index2}
157+
- match: {aliases.1.name: test_blias}
158+
- match: {aliases.1.indices.0: test_index1}
159+
- match: {aliases.1.indices.1: test_index3}
160+
- match: {aliases.2.name: test_clias}
161+
- match: {aliases.2.indices.0: test_index1}
162+
- match: {data_streams.0.name: simple-data-stream1}
163+
- match: {data_streams.0.backing_indices.0: .ds-simple-data-stream1-000001}
164+
- match: {data_streams.0.timestamp_field: "@timestamp"}
165+
- match: {data_streams.1.name: simple-data-stream2}
166+
- match: {data_streams.1.backing_indices.0: .ds-simple-data-stream2-000001}
167+
- match: {data_streams.1.backing_indices.1: .ds-simple-data-stream2-000002}
168+
- match: {data_streams.1.timestamp_field: "@timestamp2"}
169+
170+
- do:
171+
indices.delete_data_stream:
172+
name: simple-data-stream1
173+
- is_true: acknowledged
174+
175+
- do:
176+
indices.delete_data_stream:
177+
name: simple-data-stream2
178+
- is_true: acknowledged

0 commit comments

Comments
 (0)