use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions in project elasticsearch by elastic.
the class AliasActionsTests method testParseRemove.
public void testParseRemove() throws IOException {
String[] indices = generateRandomStringArray(10, 5, false, false);
String[] aliases = generateRandomStringArray(10, 5, false, false);
XContentBuilder b = XContentBuilder.builder(randomFrom(XContentType.values()).xContent());
b.startObject();
{
b.startObject("remove");
{
if (indices.length > 1 || randomBoolean()) {
b.array("indices", indices);
} else {
b.field("index", indices[0]);
}
if (aliases.length > 1 || randomBoolean()) {
b.array("aliases", aliases);
} else {
b.field("alias", aliases[0]);
}
}
b.endObject();
}
b.endObject();
b = shuffleXContent(b);
try (XContentParser parser = createParser(b)) {
AliasActions action = AliasActions.PARSER.apply(parser, null);
assertEquals(AliasActions.Type.REMOVE, action.actionType());
assertThat(action.indices(), equalTo(indices));
assertThat(action.aliases(), equalTo(aliases));
}
}
use of org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest.AliasActions in project graylog2-server by Graylog2.
the class ClientES7 method addAliasMapping.
@Override
public void addAliasMapping(String indexName, String alias) {
final IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
final AliasActions aliasAction = new AliasActions(AliasActions.Type.ADD).index(indexName).alias(alias);
indicesAliasesRequest.addAliasAction(aliasAction);
client.execute((c, requestOptions) -> c.indices().updateAliases(indicesAliasesRequest, requestOptions), "failed to add alias " + alias + " for index " + indexName);
}
Aggregations