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:
Clinton Gormley 2014-03-20 10:23:17 +01:00
parent a3f57c176e
commit 96655d2505
2 changed files with 136 additions and 1 deletions

View File

@ -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'}}

View File

@ -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)) {