本文整理汇总了Java中org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest类的典型用法代码示例。如果您正苦于以下问题:Java IndicesAliasesRequest类的具体用法?Java IndicesAliasesRequest怎么用?Java IndicesAliasesRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IndicesAliasesRequest类属于org.elasticsearch.action.admin.indices.alias包,在下文中一共展示了IndicesAliasesRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: aliasActionToJson
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
private void aliasActionToJson(IndicesAliasesRequest.AliasActions actions, String alias, String index, XContentBuilder builder) throws IOException {
String filter = actions.aliasAction().filter();
String indexRouting = actions.aliasAction().indexRouting();
String searchRouting = actions.aliasAction().searchRouting();
AliasAction.Type type = actions.aliasAction().actionType();
builder.startObject();
builder.startObject(type.name().toLowerCase());
if (alias != null) {
builder.field("alias", alias);
}
if (index != null) {
builder.field("index", index);
}
if (filter != null) {
builder.rawField("filter", filter.getBytes());
}
if (searchRouting != null) {
builder.field("search_routing", searchRouting);
}
if (indexRouting != null) {
builder.field("index_routing", indexRouting);
}
builder.endObject();
builder.endObject();
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:27,代码来源:IndicesAliasesActionHandler.java
示例2: should_create_alias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Test
public void should_create_alias() throws Exception {
String index = "index_without_alias";
createIndex(index);
ensureGreen(index);
IndicesAliasesRequest request = new IndicesAliasesRequest();
request.addAlias("the_alias", index);
IndicesAliasesResponse response = httpClient.admin().indices().aliases(request).get();
Assertions.assertThat(response.isAcknowledged()).isTrue();
GetAliasesResponse finalState = transportClient.admin().indices().getAliases(new GetAliasesRequest()).actionGet();
Assertions.assertThat(finalState.getAliases().get(index)).hasSize(1);
Assertions.assertThat(finalState.getAliases().get(index).get(0).alias()).isEqualTo("the_alias");
Assertions.assertThat(finalState.getAliases().get(index).get(0).filter()).isNull();
Assertions.assertThat(finalState.getAliases().get(index).get(0).getIndexRouting()).isNull();
Assertions.assertThat(finalState.getAliases().get(index).get(0).getSearchRouting()).isNull();
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:20,代码来源:IndicesAliasesActionHandlerTest.java
示例3: should_delete_alias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Test
public void should_delete_alias() throws Exception {
String index = "index_without_alias";
createIndex(index);
ensureGreen(index);
transportClient.admin().indices().aliases(new IndicesAliasesRequest().addAlias("the_alias", index)).actionGet();
GetAliasesResponse actualAlias = transportClient.admin().indices().getAliases(new GetAliasesRequest().indices(index)).actionGet();
Assertions.assertThat(actualAlias.getAliases().containsKey(index)).isTrue();
Assertions.assertThat(actualAlias.getAliases().get(index)).hasSize(1);
Assertions.assertThat(actualAlias.getAliases().get(index).get(0).alias()).isEqualTo("the_alias");
IndicesAliasesRequest request = new IndicesAliasesRequest();
request.removeAlias(index, "the_alias");
IndicesAliasesResponse response = httpClient.admin().indices().aliases(request).get();
Assertions.assertThat(response.isAcknowledged()).isTrue();
GetAliasesResponse finalState = transportClient.admin().indices().getAliases(new GetAliasesRequest()).actionGet();
Assertions.assertThat(finalState.getAliases()).hasSize(0);
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:22,代码来源:IndicesAliasesActionHandlerTest.java
示例4: should_create_alias_with_filter
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Test
public void should_create_alias_with_filter() throws Exception {
String index = "index_without_alias";
createIndex(index);
ensureGreen(index);
// add a mapping so I can add a filter, else it will fail due to strict resolution of fields
createSimpleDoc(index, THE_TYPE, THE_ID);
ensureSearchable(index);
IndicesAliasesRequest request = new IndicesAliasesRequest();
TermFilterBuilder filter = termFilter("the_string_field", "some_value");
request.addAlias("the_alias", filter, index);
IndicesAliasesResponse response = httpClient.admin().indices().aliases(request).get();
Assertions.assertThat(response.isAcknowledged()).isTrue();
GetAliasesResponse finalState = transportClient.admin().indices().getAliases(new GetAliasesRequest()).actionGet();
Assertions.assertThat(finalState.getAliases().get(index)).hasSize(1);
Assertions.assertThat(finalState.getAliases().get(index).get(0).alias()).isEqualTo("the_alias");
String requestFilter = request.getAliasActions().get(0).aliasAction().filter();
CompressedString actualFilter = finalState.getAliases().get(index).get(0).filter();
Assertions.assertThat(actualFilter.string()).isEqualTo(requestFilter);
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:27,代码来源:IndicesAliasesActionHandlerTest.java
示例5: should_create_alias_with_routing
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Test
public void should_create_alias_with_routing() throws Exception {
String index = "index_without_alias";
createIndex(index);
ensureGreen(index);
IndicesAliasesRequest request = new IndicesAliasesRequest();
request.addAliasAction(new AliasAction(AliasAction.Type.ADD).alias("the_alias").index(index).searchRouting("the_search_routing").indexRouting("the_index_routing"));
IndicesAliasesResponse response = httpClient.admin().indices().aliases(request).get();
Assertions.assertThat(response.isAcknowledged()).isTrue();
GetAliasesResponse finalState = transportClient.admin().indices().getAliases(new GetAliasesRequest()).actionGet();
Assertions.assertThat(finalState.getAliases().get(index)).hasSize(1);
Assertions.assertThat(finalState.getAliases().get(index).get(0).alias()).isEqualTo("the_alias");
Assertions.assertThat(finalState.getAliases().get(index).get(0).searchRouting()).isEqualTo("the_search_routing");
Assertions.assertThat(finalState.getAliases().get(index).get(0).indexRouting()).isEqualTo("the_index_routing");
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:20,代码来源:IndicesAliasesActionHandlerTest.java
示例6: prepareRequest
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final String[] aliases = Strings.splitStringByCommaToArray(request.param("name"));
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout()));
indicesAliasesRequest.addAliasAction(AliasActions.remove().indices(indices).aliases(aliases));
indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout()));
return channel -> client.admin().indices().aliases(indicesAliasesRequest, new AcknowledgedRestListener<>(channel));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:RestIndexDeleteAliasesAction.java
示例7: prepareRequest
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout()));
indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout()));
try (XContentParser parser = request.contentParser()) {
PARSER.parse(parser, indicesAliasesRequest, null);
}
if (indicesAliasesRequest.getAliasActions().isEmpty()) {
throw new IllegalArgumentException("No action specified");
}
return channel -> client.admin().indices().aliases(indicesAliasesRequest, new AcknowledgedRestListener<>(channel));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:RestIndicesAliasesAction.java
示例8: handleRequest
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final String[] aliases = Strings.splitStringByCommaToArray(request.param("name"));
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout()));
indicesAliasesRequest.removeAlias(indices, aliases);
indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout()));
client.admin().indices().aliases(indicesAliasesRequest, new AcknowledgedRestListener<IndicesAliasesResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:RestIndexDeleteAliasesAction.java
示例9: addAlias
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
public boolean addAlias(String indexName,String indexAlias) {
try {
esClient.admin().indices().aliases(new IndicesAliasesRequest().addAlias(indexAlias,indexName)).actionGet();
return true;
} catch(Exception e) {
return false;
}
}
开发者ID:tootedom,项目名称:related,代码行数:9,代码来源:ElasticSearchServer.java
示例10: toXContent
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Override
protected XContentBuilder toXContent(IndicesAliasesRequest request, IndicesAliasesResponse response, XContentBuilder builder) throws IOException {
builder.startObject()
.field(Fields.OK, true)
.field(Fields.ACKNOWLEDGED, response.isAcknowledged())
.endObject();
return builder;
}
开发者ID:javanna,项目名称:elasticshell,代码行数:9,代码来源:UpdateIndicesAliasesRequestBuilder.java
示例11: aliases
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Override
public ActionFuture<IndicesAliasesResponse> aliases(final IndicesAliasesRequest request) {
return execute(IndicesAliasesAction.INSTANCE, request);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java
示例12: prepareRequest
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
String alias = request.param("name");
Map<String, Object> filter = null;
String routing = null;
String indexRouting = null;
String searchRouting = null;
if (request.hasContent()) {
try (XContentParser parser = request.contentParser()) {
XContentParser.Token token = parser.nextToken();
if (token == null) {
throw new IllegalArgumentException("No index alias is specified");
}
String currentFieldName = null;
while ((token = parser.nextToken()) != null) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if ("index".equals(currentFieldName)) {
indices = Strings.splitStringByCommaToArray(parser.text());
} else if ("alias".equals(currentFieldName)) {
alias = parser.text();
} else if ("routing".equals(currentFieldName)) {
routing = parser.textOrNull();
} else if ("indexRouting".equals(currentFieldName)
|| "index-routing".equals(currentFieldName) || "index_routing".equals(currentFieldName)) {
indexRouting = parser.textOrNull();
} else if ("searchRouting".equals(currentFieldName)
|| "search-routing".equals(currentFieldName) || "search_routing".equals(currentFieldName)) {
searchRouting = parser.textOrNull();
}
} else if (token == XContentParser.Token.START_OBJECT) {
if ("filter".equals(currentFieldName)) {
filter = parser.mapOrdered();
}
}
}
}
}
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout()));
indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout()));
IndicesAliasesRequest.AliasActions aliasAction = AliasActions.add().indices(indices).alias(alias);
if (routing != null) {
aliasAction.routing(routing);
}
if (searchRouting != null) {
aliasAction.searchRouting(searchRouting);
}
if (indexRouting != null) {
aliasAction.indexRouting(indexRouting);
}
if (filter != null) {
aliasAction.filter(filter);
}
indicesAliasesRequest.addAliasAction(aliasAction);
return channel -> client.admin().indices().aliases(indicesAliasesRequest, new AcknowledgedRestListener<>(channel));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:63,代码来源:RestIndexPutAliasAction.java
示例13: handleRequest
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) throws Exception {
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
String alias = request.param("name");
Map<String, Object> filter = null;
String routing = null;
String indexRouting = null;
String searchRouting = null;
if (request.hasContent()) {
try (XContentParser parser = XContentFactory.xContent(request.content()).createParser(request.content())) {
XContentParser.Token token = parser.nextToken();
if (token == null) {
throw new IllegalArgumentException("No index alias is specified");
}
String currentFieldName = null;
while ((token = parser.nextToken()) != null) {
if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName();
} else if (token.isValue()) {
if ("index".equals(currentFieldName)) {
indices = Strings.splitStringByCommaToArray(parser.text());
} else if ("alias".equals(currentFieldName)) {
alias = parser.text();
} else if ("routing".equals(currentFieldName)) {
routing = parser.textOrNull();
} else if ("indexRouting".equals(currentFieldName) || "index-routing".equals(currentFieldName) || "index_routing".equals(currentFieldName)) {
indexRouting = parser.textOrNull();
} else if ("searchRouting".equals(currentFieldName) || "search-routing".equals(currentFieldName) || "search_routing".equals(currentFieldName)) {
searchRouting = parser.textOrNull();
}
} else if (token == XContentParser.Token.START_OBJECT) {
if ("filter".equals(currentFieldName)) {
filter = parser.mapOrdered();
}
}
}
}
}
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
indicesAliasesRequest.timeout(request.paramAsTime("timeout", indicesAliasesRequest.timeout()));
String[] aliases = new String[]{alias};
IndicesAliasesRequest.AliasActions aliasAction = new AliasActions(AliasAction.Type.ADD, indices, aliases);
indicesAliasesRequest.addAliasAction(aliasAction);
indicesAliasesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", indicesAliasesRequest.masterNodeTimeout()));
if (routing != null) {
aliasAction.routing(routing);
}
if (searchRouting != null) {
aliasAction.searchRouting(searchRouting);
}
if (indexRouting != null) {
aliasAction.indexRouting(indexRouting);
}
if (filter != null) {
aliasAction.filter(filter);
}
client.admin().indices().aliases(indicesAliasesRequest, new AcknowledgedRestListener<IndicesAliasesResponse>(channel));
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:63,代码来源:RestIndexPutAliasAction.java
示例14: testBasicAggregations
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Test
public void testBasicAggregations() throws Exception {
final Settings settings = Settings.builder()
.build();
setup(settings);
final RestHelper rh = nonSslRestHelper();
try (TransportClient tc = getInternalTransportClient()) {
tc.admin().indices().create(new CreateIndexRequest("copysf")).actionGet();
tc.index(new IndexRequest("vulcangov").type("kolinahr").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("starfleet").type("ships").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("starfleet_academy").type("students").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("starfleet_library").type("public").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("klingonempire").type("ships").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("public").type("legends").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("spock").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("kirk").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("role01_role02").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().indices("starfleet","starfleet_academy","starfleet_library").alias("sf"))).actionGet();
tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().indices("klingonempire","vulcangov").alias("nonsf"))).actionGet();
tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().indices("public").alias("unrestricted"))).actionGet();
}
HttpResponse res;
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_search?pretty", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":40}}}}",encodeBasicHeader("nagilum", "nagilum"))).getStatusCode());
System.out.println(res.getBody());
assertNotContains(res, "*xception*");
assertNotContains(res, "*erial*");
assertNotContains(res, "*mpty*");
assertNotContains(res, "*earchguard*");
assertContains(res, "*vulcangov*");
assertContains(res, "*\"failed\" : 0*");
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("*/_search?pretty", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":40}}}}",encodeBasicHeader("nagilum", "nagilum"))).getStatusCode());
System.out.println(res.getBody());
assertNotContains(res, "*xception*");
assertNotContains(res, "*erial*");
assertNotContains(res, "*mpty*");
assertNotContains(res, "*earchguard*");
assertContains(res, "*vulcangov*");
assertContains(res, "*\"failed\" : 0*");
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePostRequest("_search?pretty", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":40}}}}",encodeBasicHeader("worf", "worf"))).getStatusCode());
System.out.println(res.getBody());
assertNotContains(res, "*xception*");
assertNotContains(res, "*erial*");
assertNotContains(res, "*mpty*");
assertNotContains(res, "*earchguard*");
assertContains(res, "*vulcangov*");
assertContains(res, "*\"failed\" : 0*");
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePostRequest("_search?pretty", "{\"size\":0,\"aggs\":{\"myindices\":{\"terms\":{\"field\":\"_index\",\"size\":40}}}}",encodeBasicHeader("worf", "worf"))).getStatusCode());
}
开发者ID:floragunncom,项目名称:search-guard,代码行数:59,代码来源:AggregationTests.java
示例15: testAliases
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Test
public void testAliases() throws Exception {
final Settings settings = Settings.builder()
.put(ConfigConstants.SEARCHGUARD_ROLES_MAPPING_RESOLUTION, "BOTH")
.build();
setup(settings);
try (TransportClient tc = getInternalTransportClient()) {
tc.index(new IndexRequest("nopermindex").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("logstash-1").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("logstash-2").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("logstash-3").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("logstash-4").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("logstash-5").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("logstash-del").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("logstash-del-ok").type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
String date = new SimpleDateFormat("YYYY.MM.dd").format(new Date());
tc.index(new IndexRequest("logstash-"+date).type("logs").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().indices("nopermindex").alias("nopermalias"))).actionGet();
}
RestHelper rh = nonSslRestHelper();
HttpResponse res = null;
System.out.println("#### add alias to allowed index");
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executePutRequest("/logstash-1/_alias/alog1", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode());
System.out.println("#### add alias to not existing (no perm)");
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePutRequest("/nonexitent/_alias/alnp", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode());
System.out.println("#### add alias to not existing (with perm)");
Assert.assertEquals(HttpStatus.SC_NOT_FOUND, (res = rh.executePutRequest("/logstash-nonex/_alias/alnp", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode());
System.out.println("#### add alias to not allowed index");
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePutRequest("/nopermindex/_alias/alnp", "",encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode());
String aliasRemoveIndex = "{"+
"\"actions\" : ["+
"{ \"add\": { \"index\": \"logstash-del-ok\", \"alias\": \"logstash-del\" } },"+
"{ \"remove_index\": { \"index\": \"logstash-del\" } } "+
"]"+
"}";
System.out.println("#### remove_index");
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executePostRequest("/_aliases", aliasRemoveIndex,encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode());
System.out.println("#### get alias for permitted index");
Assert.assertEquals(HttpStatus.SC_OK, (res = rh.executeGetRequest("/logstash-1/_alias/alog1", encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode());
System.out.println("#### get alias for all indices");
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executeGetRequest("/_alias/alog1", encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode());
System.out.println("#### get alias no perm");
Assert.assertEquals(HttpStatus.SC_FORBIDDEN, (res = rh.executeGetRequest("/_alias/nopermalias", encodeBasicHeader("aliasmngt", "nagilum"))).getStatusCode());
}
开发者ID:floragunncom,项目名称:search-guard,代码行数:65,代码来源:IntegrationTests.java
示例16: testHTTPSingle
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Test
public void testHTTPSingle() throws Exception {
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
}
});
final Settings settings = Settings.builder()
.putList(ConfigConstants.SEARCHGUARD_AUTHCZ_REST_IMPERSONATION_USERS+".worf", "knuddel","nonexists")
.build();
setup(settings);
final RestHelper rh = nonSslRestHelper();
try (TransportClient tc = getInternalTransportClient()) {
tc.admin().indices().create(new CreateIndexRequest("copysf")).actionGet();
tc.index(new IndexRequest("vulcangov").type("kolinahr").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("starfleet").type("ships").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("starfleet_academy").type("students").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("starfleet_library").type("public").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("klingonempire").type("ships").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("public").type("legends").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("spock").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("kirk").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.index(new IndexRequest("role01_role02").type("type01").setRefreshPolicy(RefreshPolicy.IMMEDIATE).source("{\"content\":1}", XContentType.JSON)).actionGet();
tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().indices("starfleet","starfleet_academy","starfleet_library").alias("sf"))).actionGet();
tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().indices("klingonempire","vulcangov").alias("nonsf"))).actionGet();
tc.admin().indices().aliases(new IndicesAliasesRequest().addAliasAction(AliasActions.add().indices("public").alias("unrestricted"))).actionGet();
}
System.out.println("########pause1");
Thread.sleep(5000);
System.out.println("########end pause1");
System.out.println("########search");
Assert.assertEquals(HttpStatus.SC_OK, rh.executeGetRequest("_search", encodeBasicHeader("nagilum", "nagilum")).getStatusCode());
System.out.println("########search done");
System.out.println("########pause2");
Thread.sleep(5000);
System.out.println("########end pause2");
System.out.println("############ _bulk");
String bulkBody =
"{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"1\" } }"+System.lineSeparator()+
"{ \"field1\" : \"value1\" }" +System.lineSeparator()+
"{ \"index\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+
"{ \"field2\" : \"value2\" }"+System.lineSeparator()+
"{ \"delete\" : { \"_index\" : \"test\", \"_type\" : \"type1\", \"_id\" : \"2\" } }"+System.lineSeparator()+
"{ \"index\" : { \"_index\" : \"myindex\", \"_type\" : \"myindex\", \"_id\" : \"1\" } }"+System.lineSeparator()+
"{ \"field1\" : \"value1\" }" +System.lineSeparator()+
"{ \"index\" : { \"_index\" : \"myindex\", \"_type\" : \"myindex\", \"_id\" : \"1\" } }"+System.lineSeparator()+
"{ \"field1\" : \"value1\" }" +System.lineSeparator();
System.out.println(rh.executePostRequest("_bulk?refresh=true", bulkBody, encodeBasicHeader("nagilum", "nagilum")).getBody());
System.out.println("############ _end");
Thread.sleep(5000);
}
开发者ID:floragunncom,项目名称:search-guard,代码行数:66,代码来源:TracingTests.java
示例17: execute
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
public void execute(IndicesAliasesRequest request, final ActionListener<IndicesAliasesResponse> listener) {
logger.debug("indices aliases request {}", request);
try {
RequestUriBuilder uriBuilder = new RequestUriBuilder().addEndpoint("_aliases");
XContentBuilder jsonBuilder = XContentFactory.jsonBuilder().startObject();
jsonBuilder.startArray("actions");
List<IndicesAliasesRequest.AliasActions> actions = request.getAliasActions();
for (IndicesAliasesRequest.AliasActions action : actions) {
for (String alias : action.aliases()) {
for (String index : action.indices()) {
aliasActionToJson(action, alias, index, jsonBuilder);
}
}
}
jsonBuilder.endArray();
jsonBuilder.endObject();
uriBuilder.addQueryParameter("timeout", request.timeout().toString());
uriBuilder.addQueryParameter("master_timeout", request.masterNodeTimeout().toString());
uriBuilder.addIndicesOptions(request.indicesOptions());
byte[] body = jsonBuilder.bytes().toBytes();
indicesAdminClient.getHttpClient().submit(HttpClientRequest.createPost(uriBuilder.toString())
.withContent(body))
.flatMap(ErrorHandler.AS_FUNC)
.flatMap(new Func1<HttpClientResponse<ByteBuf>, Observable<IndicesAliasesResponse>>() {
@Override
public Observable<IndicesAliasesResponse> call(final HttpClientResponse<ByteBuf> response) {
return response.getContent().flatMap(new Func1<ByteBuf, Observable<IndicesAliasesResponse>>() {
@Override
public Observable<IndicesAliasesResponse> call(ByteBuf byteBuf) {
return IndicesAliasesResponse.parse(byteBuf, response.getStatus().code());
}
});
}
})
.single()
.subscribe(new ListenerCompleterObserver<>(listener));
} catch (Exception e) {
listener.onFailure(e);
}
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:48,代码来源:IndicesAliasesActionHandler.java
示例18: aliases
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
public void aliases(IndicesAliasesRequest request, ActionListener<IndicesAliasesResponse> listener) {
indicesAliasesActionHandler.execute(request, listener);
}
开发者ID:obourgain,项目名称:elasticsearch-http,代码行数:4,代码来源:HttpIndicesAdminClient.java
示例19: UpdateIndicesAliasesRequestBuilder
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
public UpdateIndicesAliasesRequestBuilder(Client client, JsonToString<JsonInput> jsonToString, StringToJson<JsonOutput> stringToJson) {
super(client, new IndicesAliasesRequest(), jsonToString, stringToJson);
}
开发者ID:javanna,项目名称:elasticshell,代码行数:4,代码来源:UpdateIndicesAliasesRequestBuilder.java
示例20: doExecute
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; //导入依赖的package包/类
@Override
protected ActionFuture<IndicesAliasesResponse> doExecute(IndicesAliasesRequest request) {
return client.admin().indices().aliases(r
|
请发表评论