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

Make XContentBuilder in AliasActions build is_write_index field #35071

Merged
merged 3 commits into from
Oct 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -522,6 +522,9 @@ public void testUpdateAliases() throws IOException {

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,
Expand All @@ -535,6 +538,8 @@ public void testUpdateAliases() throws IOException {
Map<String, Object> filter = (Map<String, Object>) getAlias.get("filter");
Map<String, Object> term = (Map<String, Object>) 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (false == Strings.isEmpty(searchRouting)) {
builder.field(SEARCH_ROUTING.getPreferredName(), searchRouting);
}
if (null != writeIndex) {
builder.field(IS_WRITE_INDEX.getPreferredName(), writeIndex);
}
builder.endObject();
builder.endObject();
return builder;
Expand All @@ -505,6 +508,7 @@ public String toString() {
+ ",routing=" + routing
+ ",indexRouting=" + indexRouting
+ ",searchRouting=" + searchRouting
+ ",writeIndex=" + writeIndex
+ "]";
}

Expand All @@ -521,12 +525,13 @@ public boolean equals(Object obj) {
&& Objects.equals(filter, other.filter)
&& Objects.equals(routing, other.routing)
&& Objects.equals(indexRouting, other.indexRouting)
&& Objects.equals(searchRouting, other.searchRouting);
&& Objects.equals(searchRouting, other.searchRouting)
&& Objects.equals(writeIndex, other.writeIndex);
}

@Override
public int hashCode() {
return Objects.hash(type, indices, aliases, filter, routing, indexRouting, searchRouting);
return Objects.hash(type, indices, aliases, filter, routing, indexRouting, searchRouting, writeIndex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public static AliasActions randomAliasAction(boolean useStringAsFilter) {
action.indexRouting(randomRouting().toString());
}
}
if (randomBoolean()) {
action.writeIndex(randomBoolean());
}
}
return action;
}
Expand Down