use of org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest in project elasticsearch by elastic.
the class RestPutIndexTemplateAction method prepareRequest.
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name"));
if (request.hasParam("template")) {
DEPRECATION_LOGGER.deprecated("Deprecated parameter[template] used, replaced by [index_patterns]");
putRequest.patterns(Collections.singletonList(request.param("template")));
} else {
putRequest.patterns(Arrays.asList(request.paramAsStringArray("index_patterns", Strings.EMPTY_ARRAY)));
}
putRequest.order(request.paramAsInt("order", putRequest.order()));
putRequest.masterNodeTimeout(request.paramAsTime("master_timeout", putRequest.masterNodeTimeout()));
putRequest.create(request.paramAsBoolean("create", false));
putRequest.cause(request.param("cause", ""));
putRequest.source(request.content(), request.getXContentType());
return channel -> client.admin().indices().putTemplate(putRequest, new AcknowledgedRestListener<>(channel));
}
use of org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest in project zipkin by openzipkin.
the class LazyClientTest method tokenizedTraceId_2x.
@Test
public void tokenizedTraceId_2x() {
LazyClient lazyClient = new LazyClient(ElasticsearchStorage.builder().strictTraceId(false));
PutIndexTemplateRequest request = new PutIndexTemplateRequest("zipkin").source(lazyClient.versionSpecificTemplate("2.4.0"));
assertThat(request.mappings().get("span")).contains("\"traceId\":{\"type\":\"string\",\"analyzer\":\"traceId_analyzer\"}");
}
use of org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest in project zipkin by openzipkin.
the class LazyClientTest method defaultsToKeywordTraceId_5x.
@Test
public void defaultsToKeywordTraceId_5x() {
LazyClient lazyClient = new LazyClient(ElasticsearchStorage.builder());
PutIndexTemplateRequest request = new PutIndexTemplateRequest("zipkin").source(lazyClient.versionSpecificTemplate("5.0.0"));
assertThat(request.mappings().get("span")).contains("\"traceId\":{\"type\":\"keyword\"}");
}
use of org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest in project zipkin by openzipkin.
the class LazyClientTest method tokenizedTraceId_5x.
/** Also notice, fielddata must be true in this case (which is expensive) */
@Test
public void tokenizedTraceId_5x() {
LazyClient lazyClient = new LazyClient(ElasticsearchStorage.builder().strictTraceId(false));
PutIndexTemplateRequest request = new PutIndexTemplateRequest("zipkin").source(lazyClient.versionSpecificTemplate("5.0.0"));
assertThat(request.mappings().get("span")).contains("\"traceId\":{\"type\":\"string\",\"fielddata\":\"true\",\"analyzer\":\"traceId_analyzer\"}");
}
use of org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest in project crate by crate.
the class DocIndexMetaData method updateTemplate.
private void updateTemplate(DocIndexMetaData md, TransportPutIndexTemplateAction transportPutIndexTemplateAction, Settings updateSettings) {
String templateName = PartitionName.templateName(ident.schema(), ident.name());
PutIndexTemplateRequest request = new PutIndexTemplateRequest(templateName).mapping(Constants.DEFAULT_MAPPING_TYPE, md.mappingMap).create(false).settings(updateSettings).template(templateName + "*");
for (String alias : md.aliases()) {
request = request.alias(new Alias(alias));
}
transportPutIndexTemplateAction.execute(request);
}
Aggregations