本文整理了Java中org.elasticsearch.client.IndicesAdminClient.create()
方法的一些代码示例,展示了IndicesAdminClient.create()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IndicesAdminClient.create()
方法的具体详情如下:
包路径:org.elasticsearch.client.IndicesAdminClient
类名称:IndicesAdminClient
方法名:create
[英]Creates an index using an explicit request allowing to specify the settings of the index.
[中]使用允许指定索引设置的显式请求创建索引。
代码示例来源:origin: brianfrankcooper/YCSB
client.admin().indices().create(
new CreateIndexRequest(indexKey)
.settings(
代码示例来源:origin: floragunncom/search-guard
final boolean indexCreated = tc.admin().indices().create(new CreateIndexRequest(index)
.settings(indexSettings))
.actionGet().isAcknowledged();
代码示例来源:origin: brianfrankcooper/YCSB
client.admin().indices().create(
new CreateIndexRequest(indexKey)
.settings(
代码示例来源:origin: floragunncom/search-guard
@Test
public void testAdvancedMapping() throws Exception {
setup(Settings.EMPTY, new DynamicSgConfig(), Settings.EMPTY, true, ClusterConfiguration.DEFAULT);
try (TransportClient tc = getInternalTransportClient(this.clusterInfo, Settings.EMPTY)) {
tc.admin().indices().create(new CreateIndexRequest("myindex1")
.mapping("mytype1", FileHelper.loadFile("mapping1.json"), XContentType.JSON)).actionGet();
tc.admin().indices().create(new CreateIndexRequest("myindex2")
.mapping("mytype2", FileHelper.loadFile("mapping2.json"), XContentType.JSON)).actionGet();
tc.admin().indices().create(new CreateIndexRequest("myindex3")
.mapping("mytype3", FileHelper.loadFile("mapping3.json"), XContentType.JSON)).actionGet();
tc.admin().indices().create(new CreateIndexRequest("myindex4")
.mapping("mytype4", FileHelper.loadFile("mapping4.json"), XContentType.JSON)).actionGet();
}
RestHelper rh = nonSslRestHelper();
System.out.println("############ write into mapping 1");
String data1 = FileHelper.loadFile("data1.json");
System.out.println(rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("nagilum", "nagilum")));
System.out.println(rh.executePutRequest("myindex1/mytype1/1?refresh", data1, encodeBasicHeader("nagilum", "nagilum")));
System.out.println("############ write into mapping 2");
System.out.println(rh.executePutRequest("myindex2/mytype2/2?refresh", data1, encodeBasicHeader("nagilum", "nagilum")));
System.out.println(rh.executePutRequest("myindex2/mytype2/2?refresh", data1, encodeBasicHeader("nagilum", "nagilum")));
System.out.println("############ write into mapping 3");
String parent = FileHelper.loadFile("data2.json");
String child = FileHelper.loadFile("data3.json");
System.out.println(rh.executePutRequest("myindex3/mytype3/1?refresh", parent, encodeBasicHeader("nagilum", "nagilum")));
System.out.println(rh.executePutRequest("myindex3/mytype3/2?routing=1&refresh", child, encodeBasicHeader("nagilum", "nagilum")));
System.out.println("############ write into mapping 4");
System.out.println(rh.executePutRequest("myindex4/mytype4/1?refresh", parent, encodeBasicHeader("nagilum", "nagilum")));
System.out.println(rh.executePutRequest("myindex4/mytype4/2?routing=1&refresh", child, encodeBasicHeader("nagilum", "nagilum")));
}
代码示例来源:origin: floragunncom/search-guard
tc.admin().indices().create(new CreateIndexRequest("a")).actionGet();
tc.admin().indices().create(new CreateIndexRequest("c")).actionGet();
tc.admin().indices().create(new CreateIndexRequest("test")).actionGet();
tc.admin().indices().create(new CreateIndexRequest("u")).actionGet();
代码示例来源:origin: floragunncom/search-guard
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();
代码示例来源:origin: floragunncom/search-guard
tc.admin().indices().create(new CreateIndexRequest("twutter")).actionGet();
代码示例来源:origin: floragunncom/search-guard
@Test
public void test557() throws Exception {
final Settings settings = Settings.builder()
.put(ConfigConstants.SEARCHGUARD_ROLES_MAPPING_RESOLUTION, "BOTH")
.build();
setup(Settings.EMPTY, new DynamicSgConfig(), settings);
try (TransportClient tc = getInternalTransportClient(this.clusterInfo, Settings.EMPTY)) {
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();
}
final RestHelper rh = nonSslRestHelper();
HttpResponse res = rh.executePostRequest("/*/_search", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":10}}}}", encodeBasicHeader("nagilum", "nagilum"));
System.out.println(res.getBody());
Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode());
Assert.assertTrue(res.getBody().contains("starfleet_academy"));
res = rh.executePostRequest("/*/_search", "{\"size\":0,\"aggs\":{\"indices\":{\"terms\":{\"field\":\"_index\",\"size\":10}}}}", encodeBasicHeader("557", "nagilum"));
System.out.println(res.getBody());
Assert.assertEquals(HttpStatus.SC_OK, res.getStatusCode());
Assert.assertTrue(res.getBody().contains("starfleet_academy"));
}
代码示例来源:origin: floragunncom/search-guard
tc.admin().indices().create(new CreateIndexRequest("copysf")).actionGet();
代码示例来源:origin: floragunncom/search-guard
tc.admin().indices().create(new CreateIndexRequest("copysf")).actionGet();
代码示例来源:origin: floragunncom/search-guard
tc.admin().indices().create(new CreateIndexRequest("searchguard")).actionGet();
} catch (Exception e) {
代码示例来源:origin: floragunncom/search-guard
CreateIndexResponse cir = tc.admin().indices().create(new CreateIndexRequest("vulcan")).actionGet();
Assert.assertTrue(cir.isAcknowledged());
代码示例来源:origin: floragunncom/search-guard
CreateIndexResponse cir = tc.admin().indices().create(new CreateIndexRequest("vulcan")).actionGet();
Assert.assertTrue(cir.isAcknowledged());
代码示例来源:origin: floragunncom/search-guard
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();
代码示例来源:origin: floragunncom/search-guard
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();
代码示例来源:origin: org.elasticsearch/elasticsearch
createIndexRequest.cause("auto(task api)");
client.admin().indices().create(createIndexRequest, new ActionListener<CreateIndexResponse>() {
@Override
public void onResponse(CreateIndexResponse result) {
代码示例来源:origin: floragunncom/search-guard
tc.admin().indices().create(new CreateIndexRequest("copysf")).actionGet();
代码示例来源:origin: org.elasticsearch/elasticsearch
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index"));
if (request.hasContent()) {
createIndexRequest.source(request.content(), request.getXContentType());
}
if (request.hasParam("update_all_types")) {
DEPRECATION_LOGGER.deprecated("[update_all_types] is deprecated since indices may not have more than one type anymore");
}
createIndexRequest.updateAllTypes(request.paramAsBoolean("update_all_types", false));
createIndexRequest.timeout(request.paramAsTime("timeout", createIndexRequest.timeout()));
createIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", createIndexRequest.masterNodeTimeout()));
createIndexRequest.waitForActiveShards(ActiveShardCount.parseString(request.param("wait_for_active_shards")));
return channel -> client.admin().indices().create(createIndexRequest, new RestToXContentListener<>(channel));
}
}
代码示例来源:origin: ujmp/universal-java-matrix-package
private synchronized void createIndex() {
CreateIndexResponse response = client.admin().indices().create(new CreateIndexRequest(index)).actionGet();
if (!response.isAcknowledged()) {
throw new RuntimeException("cannot create index " + index);
}
client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
}
代码示例来源:origin: dqeasycloud/easy-cloud
@Override
public boolean createIndex(String indexName) {
Assert.notNull(indexName, "No index defined for Query");
return getIndicesAdminClient().create(Requests.createIndexRequest(indexName)).actionGet().isAcknowledged();
}
内容来源于网络,如有侵权,请联系作者删除!