本文整理汇总了Java中org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse类的典型用法代码示例。如果您正苦于以下问题:Java GetIndexTemplatesResponse类的具体用法?Java GetIndexTemplatesResponse怎么用?Java GetIndexTemplatesResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GetIndexTemplatesResponse类属于org.elasticsearch.action.admin.indices.template.get包,在下文中一共展示了GetIndexTemplatesResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: wipeAllTemplates
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
/**
* Removes all templates, except the templates defined in the exclude
*/
public void wipeAllTemplates(Set<String> exclude) {
if (size() > 0) {
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates().get();
for (IndexTemplateMetaData indexTemplate : response.getIndexTemplates()) {
if (exclude.contains(indexTemplate.getName())) {
continue;
}
try {
client().admin().indices().prepareDeleteTemplate(indexTemplate.getName()).execute().actionGet();
} catch (IndexTemplateMissingException e) {
// ignore
}
}
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:TestCluster.java
示例2: prepareRequest
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final String[] names = Strings.splitStringByCommaToArray(request.param("name"));
final GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names);
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
final boolean implicitAll = getIndexTemplatesRequest.names().length == 0;
return channel ->
client.admin()
.indices()
.getTemplates(getIndexTemplatesRequest, new RestToXContentListener<GetIndexTemplatesResponse>(channel) {
@Override
protected RestStatus getStatus(final GetIndexTemplatesResponse response) {
final boolean templateExists = response.getIndexTemplates().isEmpty() == false;
return (templateExists || implicitAll) ? OK : NOT_FOUND;
}
});
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RestGetIndexTemplateAction.java
示例3: testThatGetIndexTemplatesWorks
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testThatGetIndexTemplatesWorks() throws Exception {
logger.info("--> put template_1");
client().admin().indices().preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.setVersion(123)
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("field1").field("type", "text").field("store", true).endObject()
.startObject("field2").field("type", "keyword").field("store", true).endObject()
.endObject().endObject().endObject())
.execute().actionGet();
logger.info("--> get template template_1");
GetIndexTemplatesResponse getTemplate1Response = client().admin().indices().prepareGetTemplates("template_1").execute().actionGet();
assertThat(getTemplate1Response.getIndexTemplates(), hasSize(1));
assertThat(getTemplate1Response.getIndexTemplates().get(0), is(notNullValue()));
assertThat(getTemplate1Response.getIndexTemplates().get(0).patterns(), is(Collections.singletonList("te*")));
assertThat(getTemplate1Response.getIndexTemplates().get(0).getOrder(), is(0));
assertThat(getTemplate1Response.getIndexTemplates().get(0).getVersion(), is(123));
logger.info("--> get non-existing-template");
GetIndexTemplatesResponse getTemplate2Response =
client().admin().indices().prepareGetTemplates("non-existing-template").execute().actionGet();
assertThat(getTemplate2Response.getIndexTemplates(), hasSize(0));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:SimpleIndexTemplateIT.java
示例4: testBrokenMapping
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testBrokenMapping() throws Exception {
// clean all templates setup by the framework.
client().admin().indices().prepareDeleteTemplate("*").get();
// check get all templates on an empty index.
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates().get();
assertThat(response.getIndexTemplates(), empty());
MapperParsingException e = expectThrows( MapperParsingException.class,
() -> client().admin().indices().preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.addMapping("type1", "{\"foo\": \"abcde\"}", XContentType.JSON)
.get());
assertThat(e.getMessage(), containsString("Failed to parse mapping "));
response = client().admin().indices().prepareGetTemplates().get();
assertThat(response.getIndexTemplates(), hasSize(0));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:SimpleIndexTemplateIT.java
示例5: testInvalidSettings
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testInvalidSettings() throws Exception {
// clean all templates setup by the framework.
client().admin().indices().prepareDeleteTemplate("*").get();
// check get all templates on an empty index.
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates().get();
assertThat(response.getIndexTemplates(), empty());
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> client().admin().indices().preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setSettings(Settings.builder().put("does_not_exist", "test"))
.get());
assertEquals("unknown setting [index.does_not_exist] please check that any required plugins are" +
" installed, or check the breaking changes documentation for removed settings", e.getMessage());
response = client().admin().indices().prepareGetTemplates().get();
assertEquals(0, response.getIndexTemplates().size());
createIndex("test");
GetSettingsResponse getSettingsResponse = client().admin().indices().prepareGetSettings("test").get();
assertNull(getSettingsResponse.getIndexToSettings().get("test").getAsMap().get("index.does_not_exist"));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:SimpleIndexTemplateIT.java
示例6: testAliasInvalidFilterValidJson
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testAliasInvalidFilterValidJson() throws Exception {
//invalid filter but valid json: put index template works fine, fails during index creation
client().admin().indices().preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.addAlias(new Alias("invalid_alias").filter("{ \"invalid\": {} }")).get();
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("template_1").get();
assertThat(response.getIndexTemplates().size(), equalTo(1));
assertThat(response.getIndexTemplates().get(0).getAliases().size(), equalTo(1));
assertThat(response.getIndexTemplates().get(0).getAliases().get("invalid_alias").filter().string(), equalTo("{\"invalid\":{}}"));
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> createIndex("test"));
assertThat(e.getMessage(), equalTo("failed to parse filter for alias [invalid_alias]"));
assertThat(e.getCause(), instanceOf(ParsingException.class));
assertThat(e.getCause().getMessage(), equalTo("no [query] registered for [invalid]"));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:SimpleIndexTemplateIT.java
示例7: testOrderAndVersion
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testOrderAndVersion() {
int order = randomInt();
Integer version = randomBoolean() ? randomInt() : null;
assertAcked(client().admin().indices().preparePutTemplate("versioned_template")
.setPatterns(Collections.singletonList("te*"))
.setVersion(version)
.setOrder(order)
.addMapping("test", "field", "type=text")
.get());
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("versioned_template").get();
assertThat(response.getIndexTemplates().size(), equalTo(1));
assertThat(response.getIndexTemplates().get(0).getVersion(), equalTo(version));
assertThat(response.getIndexTemplates().get(0).getOrder(), equalTo(order));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:SimpleIndexTemplateIT.java
示例8: handleRequest
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(request.param("name"));
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
client.admin().indices().getTemplates(getIndexTemplatesRequest, new RestResponseListener<GetIndexTemplatesResponse>(channel) {
@Override
public RestResponse buildResponse(GetIndexTemplatesResponse getIndexTemplatesResponse) {
boolean templateExists = getIndexTemplatesResponse.getIndexTemplates().size() > 0;
if (templateExists) {
return new BytesRestResponse(OK);
} else {
return new BytesRestResponse(NOT_FOUND);
}
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:18,代码来源:RestHeadIndexTemplateAction.java
示例9: assertIndexTemplateMissing
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
/**
* Assert that an index template is missing
*/
public static void assertIndexTemplateMissing(GetIndexTemplatesResponse templatesResponse, String name) {
List<String> templateNames = new ArrayList<>();
for (IndexTemplateMetaData indexTemplateMetaData : templatesResponse.getIndexTemplates()) {
templateNames.add(indexTemplateMetaData.name());
}
assertThat(templateNames, not(hasItem(name)));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:ElasticsearchAssertions.java
示例10: assertIndexTemplateExists
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
/**
* Assert that an index template exists
*/
public static void assertIndexTemplateExists(GetIndexTemplatesResponse templatesResponse, String name) {
List<String> templateNames = new ArrayList<>();
for (IndexTemplateMetaData indexTemplateMetaData : templatesResponse.getIndexTemplates()) {
templateNames.add(indexTemplateMetaData.name());
}
assertThat(templateNames, hasItem(name));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:ElasticsearchAssertions.java
示例11: testIndexTemplatesWithBlocks
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testIndexTemplatesWithBlocks() throws IOException {
// creates a simple index template
client().admin().indices().preparePutTemplate("template_blocks")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("field1").field("type", "text").field("store", true).endObject()
.startObject("field2").field("type", "keyword").field("store", true).endObject()
.endObject().endObject().endObject())
.execute().actionGet();
try {
setClusterReadOnly(true);
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("template_blocks").execute().actionGet();
assertThat(response.getIndexTemplates(), hasSize(1));
assertBlocked(client().admin().indices().preparePutTemplate("template_blocks_2")
.setPatterns(Collections.singletonList("block*"))
.setOrder(0)
.addAlias(new Alias("alias_1")));
assertBlocked(client().admin().indices().prepareDeleteTemplate("template_blocks"));
} finally {
setClusterReadOnly(false);
}
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:29,代码来源:IndexTemplateBlocksIT.java
示例12: testDuplicateAlias
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testDuplicateAlias() throws Exception {
client().admin().indices().preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.addAlias(new Alias("my_alias").filter(termQuery("field", "value1")))
.addAlias(new Alias("my_alias").filter(termQuery("field", "value2")))
.get();
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("template_1").get();
assertThat(response.getIndexTemplates().size(), equalTo(1));
assertThat(response.getIndexTemplates().get(0).getAliases().size(), equalTo(1));
assertThat(response.getIndexTemplates().get(0).getAliases().get("my_alias").filter().string(), containsString("\"value1\""));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:SimpleIndexTemplateIT.java
示例13: testAliasInvalidFilterInvalidJson
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testAliasInvalidFilterInvalidJson() throws Exception {
//invalid json: put index template fails
PutIndexTemplateRequestBuilder putIndexTemplateRequestBuilder = client().admin().indices().preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.addAlias(new Alias("invalid_alias").filter("abcde"));
IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> putIndexTemplateRequestBuilder.get());
assertThat(e.getMessage(), equalTo("failed to parse filter for alias [invalid_alias]"));
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("template_1").get();
assertThat(response.getIndexTemplates().size(), equalTo(0));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:14,代码来源:SimpleIndexTemplateIT.java
示例14: handleRequest
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
final String[] names = Strings.splitStringByCommaToArray(request.param("name"));
GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names);
getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local()));
getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout()));
final boolean implicitAll = getIndexTemplatesRequest.names().length == 0;
client.admin().indices().getTemplates(getIndexTemplatesRequest, new RestBuilderListener<GetIndexTemplatesResponse>(channel) {
@Override
public RestResponse buildResponse(GetIndexTemplatesResponse getIndexTemplatesResponse, XContentBuilder builder) throws Exception {
boolean templateExists = getIndexTemplatesResponse.getIndexTemplates().size() > 0;
Map<String, String> paramsMap = Maps.newHashMap();
paramsMap.put("reduce_mappings", "true");
ToXContent.Params params = new ToXContent.DelegatingMapParams(paramsMap, request);
builder.startObject();
for (IndexTemplateMetaData indexTemplateMetaData : getIndexTemplatesResponse.getIndexTemplates()) {
IndexTemplateMetaData.Builder.toXContent(indexTemplateMetaData, builder, params);
}
builder.endObject();
RestStatus restStatus = (templateExists || implicitAll) ? OK : NOT_FOUND;
return new BytesRestResponse(restStatus, builder);
}
});
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:32,代码来源:RestGetIndexTemplateAction.java
示例15: ensureTemplate
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
@Override
public void ensureTemplate(String name, String indexTemplate) {
GetIndexTemplatesResponse existingTemplates =
client.admin().indices().getTemplates(new GetIndexTemplatesRequest(name))
.actionGet();
if (!existingTemplates.getIndexTemplates().isEmpty()) {
return;
}
client.admin().indices().putTemplate(
new PutIndexTemplateRequest(name).source(indexTemplate)).actionGet();
}
开发者ID:liaominghua,项目名称:zipkin,代码行数:12,代码来源:NativeClient.java
示例16: testThatTemplateIsAdded
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
@Test
public void testThatTemplateIsAdded() throws Exception {
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("metrics_template").get();
assertThat(response.getIndexTemplates(), hasSize(1));
IndexTemplateMetaData templateData = response.getIndexTemplates().get(0);
assertThat(templateData.order(), is(0));
assertThat(templateData.getMappings().get("_default_"), is(notNullValue()));
}
开发者ID:elastic,项目名称:elasticsearch-metrics-reporter-java,代码行数:10,代码来源:ElasticsearchReporterTest.java
示例17: testThatTemplateIsNotOverWritten
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
@Test
public void testThatTemplateIsNotOverWritten() throws Exception {
client().admin().indices().preparePutTemplate("metrics_template").setTemplate("foo*").setSettings("{ \"index.number_of_shards\" : \"1\"}").execute().actionGet();
elasticsearchReporter = createElasticsearchReporterBuilder().build();
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates("metrics_template").get();
assertThat(response.getIndexTemplates(), hasSize(1));
IndexTemplateMetaData templateData = response.getIndexTemplates().get(0);
assertThat(templateData.template(), is("foo*"));
}
开发者ID:elastic,项目名称:elasticsearch-metrics-reporter-java,代码行数:13,代码来源:ElasticsearchReporterTest.java
示例18: getTemplates
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
@Override
public ActionFuture<GetIndexTemplatesResponse> getTemplates(final GetIndexTemplatesRequest request) {
return execute(GetIndexTemplatesAction.INSTANCE, request);
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AbstractClient.java
示例19: testSimpleIndexTemplateTests
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testSimpleIndexTemplateTests() throws Exception {
// clean all templates setup by the framework.
client().admin().indices().prepareDeleteTemplate("*").get();
// check get all templates on an empty index.
GetIndexTemplatesResponse response = client().admin().indices().prepareGetTemplates().get();
assertThat(response.getIndexTemplates(), empty());
client().admin().indices().preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setSettings(indexSettings())
.setOrder(0)
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("field1").field("type", "text").field("store", true).endObject()
.startObject("field2").field("type", "keyword").field("store", true).endObject()
.endObject().endObject().endObject())
.get();
client().admin().indices().preparePutTemplate("template_2")
.setPatterns(Collections.singletonList("test*"))
.setSettings(indexSettings())
.setOrder(1)
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("field2").field("type", "text").field("store", false).endObject()
.endObject().endObject().endObject())
.get();
// test create param
assertThrows(client().admin().indices().preparePutTemplate("template_2")
.setPatterns(Collections.singletonList("test*"))
.setSettings(indexSettings())
.setCreate(true)
.setOrder(1)
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("field2").field("type", "text").field("store", false).endObject()
.endObject().endObject().endObject())
, IllegalArgumentException.class
);
response = client().admin().indices().prepareGetTemplates().get();
assertThat(response.getIndexTemplates(), hasSize(2));
// index something into test_index, will match on both templates
client().prepareIndex("test_index", "type1", "1")
.setSource("field1", "value1", "field2", "value 2")
.setRefreshPolicy(IMMEDIATE).get();
ensureGreen();
SearchResponse searchResponse = client().prepareSearch("test_index")
.setQuery(termQuery("field1", "value1"))
.addStoredField("field1").addStoredField("field2")
.execute().actionGet();
assertHitCount(searchResponse, 1);
assertThat(searchResponse.getHits().getAt(0).field("field1").getValue().toString(), equalTo("value1"));
// field2 is not stored.
assertThat(searchResponse.getHits().getAt(0).field("field2"), nullValue());
client().prepareIndex("text_index", "type1", "1")
.setSource("field1", "value1", "field2", "value 2")
.setRefreshPolicy(IMMEDIATE).get();
ensureGreen();
// now only match on one template (template_1)
searchResponse = client().prepareSearch("text_index")
.setQuery(termQuery("field1", "value1"))
.addStoredField("field1").addStoredField("field2")
.execute().actionGet();
if (searchResponse.getFailedShards() > 0) {
logger.warn("failed search {}", Arrays.toString(searchResponse.getShardFailures()));
}
assertHitCount(searchResponse, 1);
assertThat(searchResponse.getHits().getAt(0).field("field1").getValue().toString(), equalTo("value1"));
assertThat(searchResponse.getHits().getAt(0).field("field2").getValue().toString(), equalTo("value 2"));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:78,代码来源:SimpleIndexTemplateIT.java
示例20: testThatGetIndexTemplatesWithSimpleRegexWorks
import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; //导入依赖的package包/类
public void testThatGetIndexTemplatesWithSimpleRegexWorks() throws Exception {
logger.info("--> put template_1");
client().admin().indices().preparePutTemplate("template_1")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("field1").field("type", "text").field("store", true).endObject()
.startObject("field2").field("type", "keyword").field("store", true).endObject()
.endObject().endObject().endObject())
.execute().actionGet();
logger.info("--> put template_2");
client().admin().indices().preparePutTemplate("template_2")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("field1").field("type", "text").field("store", true).endObject()
.startObject("field2").field("type", "keyword").field("store", true).endObject()
.endObject().endObject().endObject())
.execute().actionGet();
logger.info("--> put template3");
client().admin().indices().preparePutTemplate("template3")
.setPatterns(Collections.singletonList("te*"))
.setOrder(0)
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
.startObject("field1").field("type", "text").field("store", true).endObject()
.startObject("field2").field("type", "keyword").field("store", true).endObject()
.endObject().endObject().endObject())
.execute().actionGet();
logger.info("--> get template template_*");
GetIndexTemplatesResponse getTemplate1Response = client().admin().indices().prepareGetTemplates("template_*").execute().actionGet();
assertThat(getTemplate1Response.getIndexTemplates(), hasSize(2));
List<String> templateNames = new ArrayList<>();
templateNames.add(getTemplate1Response.getIndexTemplates().get(0).name());
templateNames.add(getTemplate1Response.getIndexTemplates().get(1).name());
assertThat(templateNames, containsInAnyOrder("template_1", "template_2"));
logger.info("--> get all templates");
getTemplate1Response = client().admin().indices().prepareGetTemplates("template*").execute().actionGet();
assertThat(getTemplate1Response.getIndexTemplates(), hasSize(3));
templateNames = new ArrayList<>();
templateNames.add(getTemplate1Response.getIndexTemplates().get(0).name());
templateNames.add(getTemplate1Response.getIndexTemplates().get(1).name());
templateNames.add(getTemplate1Response.getIndexTemplates().get(2).name());
assertThat(templateNames, containsInAnyOrder("template_1", "template_2", "template3"));
logger.info("--> get templates template_1 and template_2");
getTemplate1Response = client().admin().indices().prepareGetTemplates("template_1", "template_2").execute().actionGet();
assertThat(getTemplate1Response.getIndexTemplates(), hasSize(2));
templateNames = new ArrayList<>();
templateNames.add(getTemplate1Response.getIndexTemplates().get(0).name());
templateNames.add(getTemplate1Response.getIndexTemplates().get(1).name());
assertThat(templateNames, containsInAnyOrder("template_1", "template_2"));
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:60,代码来源:SimpleIndexTemplateIT.java
注:本文中的org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论