Skip to content

Commit 349a8be

Browse files
committed
Consistent REST API changes for GETting data
* Made GET mappings consistent, supporting * /{index}/_mappings/{type} * /{index}/_mapping/{type} * /_mapping/{type} * Added "mappings" in the JSON response to align it with other responses * Made GET warmers consistent, support /{index}/_warmers/{type} and /_warmer, /_warner/{name} as well as wildcards and _all notation * Made GET aliases consistent, support /{index}/_aliases/{name} and /_alias, /_aliases/{name} as well as wildcards and _all notation * Made GET settings consistent, added /{index}/_setting/{name}, /_settings/{name} as well as supportings wildcards in settings name * Returning empty JSON instead of a 404, if a specific warmer/ setting/alias/type is missing * Added a ton of spec tests for all of the above * Added a couple of more integration tests for several features Relates elastic#4071
1 parent b35ca1a commit 349a8be

File tree

33 files changed

+1345
-152
lines changed

33 files changed

+1345
-152
lines changed

docs/reference/indices/get-settings.asciidoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ curl -XGET 'http://localhost:9200/my-index/_settings?prefix=index.'
3939
4040
curl -XGET 'http://localhost:9200/_all/_settings?prefix=index.routing.allocation.'
4141
42-
curl -XGET 'http://localhost:9200/2013-*/_settings?prefix=index.merge.'
42+
curl -XGET 'http://localhost:9200/2013-*/_settings?name=index.merge.*'
4343
44-
curl -XGET 'http://localhost:9200/2013-*/index.merge./_settings'
44+
curl -XGET 'http://localhost:9200/2013-*/_settings/index.merge.*'
4545
--------------------------------------------------
4646

4747
The first example returns all index settings the start with `index.` in the index `my-index`,
4848
the second example gets all index settings that start with `index.routing.allocation.` for
4949
all indices, lastly the third example returns all index settings that start with `index.merge.`
50-
in indices that start with `2013-`.
50+
in indices that start with `2013-`.

rest-api-spec/api/indices.get_alias.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html",
44
"methods": ["GET"],
55
"url": {
6-
"path": "/_alias/{name}",
7-
"paths": ["/_alias/{name}", "/{index}/_alias/{name}", "/{index}/_alias"],
6+
"path": "/_alias/",
7+
"paths": [ "/_alias", "/_alias/{name}", "/{index}/_alias/{name}", "/{index}/_alias"],
88
"parts": {
99
"index": {
1010
"type" : "list",

rest-api-spec/api/indices.get_aliases.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
"methods": ["GET"],
55
"url": {
66
"path": "/_aliases",
7-
"paths": ["/_aliases", "/{index}/_aliases"],
7+
"paths": ["/_aliases", "/{index}/_aliases", "/{index}/_aliases/{name}", "/_aliases/{name}" ],
88
"parts": {
99
"index": {
1010
"type" : "list",
1111
"description" : "A comma-separated list of index names to filter aliases"
12+
},
13+
"name": {
14+
"type" : "list",
15+
"description" : "A comma-separated list of alias names to filter"
1216
}
1317
},
1418
"params": {

rest-api-spec/api/indices.get_mapping.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"methods": ["GET"],
55
"url": {
66
"path": "/_mapping",
7-
"paths": ["/_mapping", "/{index}/_mapping", "/{index}/{type}/_mapping"],
7+
"paths": ["/_mapping", "/{index}/_mapping", "/_mapping/{type}", "/{index}/_mapping/{type}"],
88
"parts": {
99
"index": {
1010
"type" : "list",

rest-api-spec/api/indices.get_settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"methods": ["GET"],
55
"url": {
66
"path": "/_settings",
7-
"paths": ["/_settings", "/{index}/_settings", "/{index}/{prefix}/_settings"],
7+
"paths": ["/_settings", "/{index}/_settings", "/{index}/_settings/{name}", "/_settings/{name}"],
88
"parts": {
99
"index": {
1010
"type" : "list",
1111
"description" : "A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices"
1212
},
13-
"prefix": {
13+
"name": {
1414
"type" : "string",
15-
"description" : "The prefix all settings must have in order to be included"
15+
"description" : "The name of the settings that should be included"
1616
}
1717
},
1818
"params": {

rest-api-spec/api/indices.get_warmer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html",
44
"methods": ["GET"],
55
"url": {
6-
"path": "/{index}/_warmer",
7-
"paths": ["/{index}/_warmer", "/{index}/_warmer/{name}", "/{index}/{type}/_warmer/{name}"],
6+
"path": "/_warmer",
7+
"paths": [ "/_warmer", "/{index}/_warmer", "/{index}/_warmer/{name}", "/_warmer/{name}", "/{index}/{type}/_warmer/{name}"],
88
"parts": {
99
"index": {
1010
"type" : "list",

rest-api-spec/test/indices.delete_alias/10_basic.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
name: testali
2626

2727
- do:
28-
catch: missing
2928
indices.get_alias:
3029
index: testind
3130
name: testali
31+
32+
- match: { '': {}}

rest-api-spec/test/indices.delete_warmer/all_path_options.yaml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,7 @@ setup:
4949
name: test_warmer1
5050

5151
- do:
52-
catch: missing
53-
indices.get_warmer: { index: _all, name: 'test_warmer1' }
54-
55-
- do:
56-
indices.get_warmer: { index: _all, name: 'test_warmer2' }
57-
52+
indices.get_warmer: {}
5853

5954
- match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
6055
- match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
@@ -68,12 +63,7 @@ setup:
6863
name: test_warmer1
6964

7065
- do:
71-
catch: missing
72-
indices.get_warmer: { index: _all, name: 'test_warmer1' }
73-
74-
- do:
75-
indices.get_warmer: { index: _all, name: 'test_warmer2' }
76-
66+
indices.get_warmer: {}
7767

7868
- match: {test_index1.warmers.test_warmer2.source.query.match_all: {}}
7969
- match: {test_index2.warmers.test_warmer2.source.query.match_all: {}}
@@ -146,7 +136,7 @@ setup:
146136
---
147137
"check delete with index list and _all warmers":
148138
- do:
149-
indices.delete_warmer:
139+
indices.delete_warmer:
150140
index: "test_index1,test_index2"
151141
name: _all
152142

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
---
2+
setup:
3+
4+
- do:
5+
indices.create:
6+
index: test_index
7+
8+
- do:
9+
indices.create:
10+
index: test_index_2
11+
12+
- do:
13+
indices.put_alias:
14+
index: test_index
15+
name: test_alias
16+
17+
- do:
18+
indices.put_alias:
19+
index: test_index
20+
name: test_blias
21+
22+
- do:
23+
indices.put_alias:
24+
index: test_index_2
25+
name: test_alias
26+
27+
- do:
28+
indices.put_alias:
29+
index: test_index_2
30+
name: test_blias
31+
32+
---
33+
"Get all aliases via /_alias":
34+
35+
- do:
36+
indices.get_alias: {}
37+
38+
- match: {test_index.aliases.test_alias: {}}
39+
- match: {test_index.aliases.test_blias: {}}
40+
- match: {test_index_2.aliases.test_alias: {}}
41+
- match: {test_index_2.aliases.test_blias: {}}
42+
43+
44+
---
45+
"Get all aliases via /{index}/_alias/":
46+
47+
- do:
48+
indices.get_alias:
49+
index: test_index
50+
51+
- match: {test_index.aliases.test_alias: {}}
52+
- match: {test_index.aliases.test_blias: {}}
53+
- is_false: test_index_2
54+
55+
---
56+
"Get specific alias via /{index}/_alias/{name}":
57+
58+
- do:
59+
indices.get_alias:
60+
index: test_index
61+
name: test_alias
62+
63+
- match: {test_index.aliases.test_alias: {}}
64+
- is_false: test_index.aliases.test_blias
65+
- is_false: test_index_2
66+
67+
---
68+
"Get aliases via /{index}/_alias/_all":
69+
70+
- do:
71+
indices.get_alias:
72+
index: test_index
73+
name: _all
74+
75+
- match: {test_index.aliases.test_alias: {}}
76+
- match: {test_index.aliases.test_blias: {}}
77+
- is_false: test_index_2
78+
79+
---
80+
"Get aliases via /{index}/_alias/*":
81+
82+
- do:
83+
indices.get_alias:
84+
index: test_index
85+
name: '*'
86+
87+
- match: {test_index.aliases.test_alias: {}}
88+
- match: {test_index.aliases.test_blias: {}}
89+
- is_false: test_index_2
90+
91+
---
92+
"Get aliases via /{index}/_alias/prefix*":
93+
94+
- do:
95+
indices.get_alias:
96+
index: test_index
97+
name: 'test_a*'
98+
99+
- match: {test_index.aliases.test_alias: {}}
100+
- is_false: test_index.aliases.test_blias
101+
- is_false: test_index_2
102+
103+
---
104+
"Get aliases via /{index}/_alias/name,name":
105+
106+
- do:
107+
indices.get_alias:
108+
index: test_index
109+
name: 'test_alias,test_blias'
110+
111+
- match: {test_index.aliases.test_alias: {}}
112+
- match: {test_index.aliases.test_blias: {}}
113+
- is_false: test_index_2
114+
115+
---
116+
"Get aliases via /_alias/{name}":
117+
118+
- do:
119+
indices.get_alias:
120+
name: test_alias
121+
122+
- match: {test_index.aliases.test_alias: {}}
123+
- match: {test_index_2.aliases.test_alias: {}}
124+
- is_false: test_index.aliases.test_blias
125+
- is_false: test_index_2.aliases.test_blias
126+
127+
---
128+
"Get aliases via /_all/_alias/{name}":
129+
130+
- do:
131+
indices.get_alias:
132+
index: _all
133+
name: test_alias
134+
135+
- match: {test_index.aliases.test_alias: {}}
136+
- match: {test_index_2.aliases.test_alias: {}}
137+
- is_false: test_index.aliases.test_blias
138+
- is_false: test_index_2.aliases.test_blias
139+
140+
---
141+
"Get aliases via /*/_alias/{name}":
142+
143+
- do:
144+
indices.get_alias:
145+
index: '*'
146+
name: test_alias
147+
148+
- match: {test_index.aliases.test_alias: {}}
149+
- match: {test_index_2.aliases.test_alias: {}}
150+
- is_false: test_index.aliases.test_blias
151+
- is_false: test_index_2.aliases.test_blias
152+
153+
---
154+
"Get aliases via /pref*/_alias/{name}":
155+
156+
- do:
157+
indices.get_alias:
158+
index: '*2'
159+
name: test_alias
160+
161+
- match: {test_index_2.aliases.test_alias: {}}
162+
- is_false: test_index.aliases.test_alias
163+
- is_false: test_index.aliases.test_blias
164+
- is_false: test_index_2.aliases.test_blias
165+
166+
---
167+
"Get aliases via /name,name/_alias/{name}":
168+
169+
- do:
170+
indices.get_alias:
171+
index: test_index,test_index_2
172+
name: test_alias
173+
174+
- match: {test_index.aliases.test_alias: {}}
175+
- match: {test_index_2.aliases.test_alias: {}}
176+
- is_false: test_index.aliases.test_blias
177+
- is_false: test_index_2.aliases.test_blias
178+
179+
180+
---
181+
"Non-existent alias on an existing index returns an empty body":
182+
183+
- do:
184+
indices.get_alias:
185+
index: test_index
186+
name: non-existent
187+
188+
- match: { '': {}}
189+
190+
---
191+
"Existent and non-existent alias returns just the existing":
192+
193+
- do:
194+
indices.get_alias:
195+
index: test_index
196+
name: test_alias,non-existent
197+
198+
- match: {test_index.aliases.test_alias: {}}
199+
- is_false: test_index.aliases.non-existent
200+
201+
---
202+
"Getting alias on an non-existent index should return 404":
203+
204+
- do:
205+
catch: missing
206+
indices.get_alias:
207+
index: non-existent
208+
name: foo
209+
210+
211+

0 commit comments

Comments
 (0)