PUT /_aliases should accept a numeric routing value
Also added REST tests for setting index/search/routing via the PUT /_aliases endpoint Fixes #5465
This commit is contained in:
parent
a3f57c176e
commit
96655d2505
|
@ -0,0 +1,135 @@
|
|||
setup:
|
||||
- do:
|
||||
indices.create:
|
||||
index: test_index
|
||||
|
||||
---
|
||||
"Routing":
|
||||
|
||||
- do:
|
||||
indices.update_aliases:
|
||||
body:
|
||||
actions:
|
||||
- add:
|
||||
index: test_index
|
||||
alias: test_alias
|
||||
routing: routing
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.aliases.test_alias: {'index_routing': 'routing', 'search_routing': 'routing'}}
|
||||
|
||||
---
|
||||
"Index Routing":
|
||||
|
||||
- do:
|
||||
indices.update_aliases:
|
||||
body:
|
||||
actions:
|
||||
- add:
|
||||
index: test_index
|
||||
alias: test_alias
|
||||
index_routing: index_routing
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.aliases.test_alias: {'index_routing': 'index_routing'}}
|
||||
|
||||
---
|
||||
"Search Routing":
|
||||
|
||||
- do:
|
||||
indices.update_aliases:
|
||||
body:
|
||||
actions:
|
||||
- add:
|
||||
index: test_index
|
||||
alias: test_alias
|
||||
search_routing: search_routing
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.aliases.test_alias: {'search_routing': 'search_routing'}}
|
||||
|
||||
---
|
||||
"Index, Default Routing":
|
||||
|
||||
- do:
|
||||
indices.update_aliases:
|
||||
body:
|
||||
actions:
|
||||
- add:
|
||||
index: test_index
|
||||
alias: test_alias
|
||||
index_routing: index_routing
|
||||
routing: routing
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.aliases.test_alias: {'index_routing': 'index_routing', 'search_routing': 'routing'}}
|
||||
|
||||
---
|
||||
"Search, Default Routing":
|
||||
|
||||
- do:
|
||||
indices.update_aliases:
|
||||
body:
|
||||
actions:
|
||||
- add:
|
||||
index: test_index
|
||||
alias: test_alias
|
||||
search_routing: search_routing
|
||||
routing: routing
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.aliases.test_alias: {'index_routing': 'routing', 'search_routing': 'search_routing'}}
|
||||
|
||||
---
|
||||
"Index, Search, Default Routing":
|
||||
|
||||
- do:
|
||||
indices.update_aliases:
|
||||
body:
|
||||
actions:
|
||||
- add:
|
||||
index: test_index
|
||||
alias: test_alias
|
||||
index_routing: index_routing
|
||||
search_routing: search_routing
|
||||
routing: routing
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.aliases.test_alias: {'index_routing': 'index_routing', 'search_routing': 'search_routing'}}
|
||||
|
||||
---
|
||||
"Numeric Routing":
|
||||
|
||||
- do:
|
||||
indices.update_aliases:
|
||||
body:
|
||||
actions:
|
||||
- add:
|
||||
index: test_index
|
||||
alias: test_alias
|
||||
routing: 5
|
||||
|
||||
- do:
|
||||
indices.get_aliases:
|
||||
index: test_index
|
||||
|
||||
- match: {test_index.aliases.test_alias: {'index_routing': '5', 'search_routing': '5'}}
|
||||
|
|
@ -92,7 +92,7 @@ public class RestIndicesAliasesAction extends BaseRestHandler {
|
|||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (token == XContentParser.Token.VALUE_STRING) {
|
||||
} else if (token.isValue()) {
|
||||
if ("index".equals(currentFieldName)) {
|
||||
index = parser.text();
|
||||
} else if ("alias".equals(currentFieldName)) {
|
||||
|
|
Loading…
Reference in New Issue