Skip to content

Commit 6e82ade

Browse files
authored
Add mode filter to _resolve/index (#133616)
* Add mode filter to _resolve/index
1 parent 937f80c commit 6e82ade

File tree

8 files changed

+377
-17
lines changed

8 files changed

+377
-17
lines changed

docs/changelog/133616.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 133616
2+
summary: Add mode filter to _resolve/index
3+
area: Indices APIs
4+
type: enhancement
5+
issues: []

rest-api-spec/src/main/resources/rest-api-spec/api/indices.resolve_index.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
"type":"boolean",
4848
"description":"Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)",
4949
"default":true
50+
},
51+
"mode": {
52+
"type": "string",
53+
"description": "Filter indices by index mode"
5054
}
5155
}
5256
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
setup:
3+
- do:
4+
indices.create:
5+
index: my-std-index
6+
body:
7+
settings:
8+
number_of_shards: 1
9+
number_of_replicas: 0
10+
aliases:
11+
my-std-alias: { }
12+
13+
# Create a time-series index
14+
- do:
15+
indices.create:
16+
index: my-ts-index
17+
body:
18+
settings:
19+
index.mode: time_series
20+
number_of_shards: 1
21+
number_of_replicas: 0
22+
index.routing_path: [ "host" ]
23+
mappings:
24+
properties:
25+
"@timestamp":
26+
type: date
27+
host:
28+
type: keyword
29+
time_series_dimension: true
30+
metric:
31+
type: keyword
32+
value:
33+
type: double
34+
aliases:
35+
my-ts-alias: { }
36+
# Create a lookup index
37+
- do:
38+
indices.create:
39+
index: my-lookup-index
40+
body:
41+
settings:
42+
index.mode: lookup
43+
aliases:
44+
my-lookup-alias: { }
45+
46+
---
47+
"resolve index filters by mode":
48+
- requires:
49+
test_runner_features: [ capabilities ]
50+
capabilities:
51+
- method: GET
52+
path: /_resolve/index/*
53+
capabilities: [ mode_filter ]
54+
reason: "Need support for mode filtering in indices.resolve_index"
55+
56+
- do:
57+
indices.resolve_index:
58+
name: 'my-*'
59+
mode: lookup
60+
- length: { indices: 1 }
61+
- match: { indices.0.name: "my-lookup-index" }
62+
- match: { indices.0.mode: "lookup" }
63+
- match: { indices.0.aliases: [ "my-lookup-alias" ] }
64+
- length: { aliases: 1 }
65+
- match: { aliases.0.name: "my-lookup-alias" }
66+
- match: { aliases.0.indices: [ "my-lookup-index" ] }
67+
68+
---
69+
"resolve index filters by mode, multiple modes":
70+
- requires:
71+
test_runner_features: [ capabilities ]
72+
capabilities:
73+
- method: GET
74+
path: /_resolve/index/*
75+
capabilities: [ mode_filter ]
76+
reason: "Need support for mode filtering in indices.resolve_index"
77+
78+
- do:
79+
indices.resolve_index:
80+
name: 'my-*'
81+
mode: time_series,standard
82+
- length: { indices: 2 }
83+
- match: { indices.0.name: "my-std-index" }
84+
- match: { indices.0.mode: "standard" }
85+
- match: { indices.0.aliases: [ "my-std-alias" ] }
86+
- match: { indices.1.name: "my-ts-index" }
87+
- match: { indices.1.mode: "time_series" }
88+
- match: { indices.1.aliases: [ "my-ts-alias" ] }
89+
- length: { aliases: 2 }
90+
- match: { aliases.0.name: "my-std-alias" }
91+
- match: { aliases.0.indices: [ "my-std-index" ] }
92+
- match: { aliases.1.name: "my-ts-alias" }
93+
- match: { aliases.1.indices: [ "my-ts-index" ] }
94+
95+
---
96+
teardown:
97+
- do:
98+
indices.delete:
99+
index: my-std-index
100+
ignore_unavailable: true
101+
- do:
102+
indices.delete:
103+
index: my-ts-index
104+
ignore_unavailable: true
105+
- do:
106+
indices.delete:
107+
index: my-lookup-index
108+
ignore_unavailable: true

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ static TransportVersion def(int id) {
355355
public static final TransportVersion ESQL_SAMPLE_OPERATOR_STATUS = def(9_127_0_00);
356356
public static final TransportVersion PROJECT_RESERVED_STATE_MOVE_TO_REGISTRY = def(9_147_0_00);
357357
public static final TransportVersion STREAMS_ENDPOINT_PARAM_RESTRICTIONS = def(9_148_0_00);
358+
public static final TransportVersion RESOLVE_INDEX_MODE_FILTER = def(9_149_0_00);
358359

359360
/*
360361
* STOP! READ THIS FIRST! No, really,

0 commit comments

Comments
 (0)