From 9ef4788c13349a055145996f6bbc3d8ef170e07f Mon Sep 17 00:00:00 2001 From: "Seong-hyun, Oh" Date: Thu, 1 Nov 2018 06:15:46 +0900 Subject: [PATCH] Make XContentBuilder in AliasActions build `is_write_index` field (#35071) Make XContentBuilder in AliasesActions build `is_write_index` field --- .../java/org/elasticsearch/client/IndicesClientIT.java | 5 +++++ .../admin/indices/alias/IndicesAliasesRequest.java | 9 +++++++-- .../index/alias/RandomAliasActionsGenerator.java | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java index 832aba51e2b..053f46f8496 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesClientIT.java @@ -522,6 +522,9 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase { IndicesAliasesRequest aliasesAddRequest = new IndicesAliasesRequest(); AliasActions addAction = new AliasActions(AliasActions.Type.ADD).index(index).aliases(alias); + if (randomBoolean()) { + addAction.writeIndex(randomBoolean()); + } addAction.routing("routing").searchRouting("search_routing").filter("{\"term\":{\"year\":2016}}"); aliasesAddRequest.addAliasAction(addAction); AcknowledgedResponse aliasesAddResponse = execute(aliasesAddRequest, highLevelClient().indices()::updateAliases, @@ -535,6 +538,8 @@ public class IndicesClientIT extends ESRestHighLevelClientTestCase { Map filter = (Map) getAlias.get("filter"); Map term = (Map) filter.get("term"); assertEquals(2016, term.get("year")); + Boolean isWriteIndex = (Boolean) getAlias.get("is_write_index"); + assertThat(isWriteIndex, equalTo(addAction.writeIndex())); String alias2 = "alias2"; IndicesAliasesRequest aliasesAddRemoveRequest = new IndicesAliasesRequest(); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java index 22e8554ed6a..dfe0a25c611 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java @@ -486,6 +486,9 @@ public class IndicesAliasesRequest extends AcknowledgedRequest