Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for is_write_index in put-alias body parsing #31674

Merged
merged 4 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,27 @@
indices.put_alias:
index: test_index
name: foo

---
"Can set is_write_index":

- skip:
version: " - 6.3.99"
reason: "is_write_index is only available from 6.4.0 on"

- do:
indices.create:
index: test_index

- do:
indices.put_alias:
index: test_index
name: test_alias
body:
is_write_index: true

- do:
indices.exists_alias:
name: test_alias

- is_true: ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to add a test that gets the alias and sees the flag?

Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
String routing = null;
String indexRouting = null;
String searchRouting = null;
Boolean writeIndex = null;

if (request.hasContent()) {
try (XContentParser parser = request.contentParser()) {
Expand All @@ -90,6 +91,8 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
} else if ("searchRouting".equals(currentFieldName)
|| "search-routing".equals(currentFieldName) || "search_routing".equals(currentFieldName)) {
searchRouting = parser.textOrNull();
} else if ("is_write_index".equals(currentFieldName)) {
writeIndex = parser.booleanValue();
}
} else if (token == XContentParser.Token.START_OBJECT) {
if ("filter".equals(currentFieldName)) {
Expand Down Expand Up @@ -117,6 +120,9 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC
if (filter != null) {
aliasAction.filter(filter);
}
if (writeIndex != null) {
aliasAction.writeIndex(writeIndex);
}
indicesAliasesRequest.addAliasAction(aliasAction);
return channel -> client.admin().indices().aliases(indicesAliasesRequest, new RestToXContentListener<>(channel));
}
Expand Down