Search in sources :

Example 1 with PutIndexTemplateRequest

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));
}
Also used : Loggers(org.elasticsearch.common.logging.Loggers) BaseRestHandler(org.elasticsearch.rest.BaseRestHandler) Arrays(java.util.Arrays) DeprecationLogger(org.elasticsearch.common.logging.DeprecationLogger) IOException(java.io.IOException) RestController(org.elasticsearch.rest.RestController) Strings(org.elasticsearch.common.Strings) Settings(org.elasticsearch.common.settings.Settings) PutIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest) RestRequest(org.elasticsearch.rest.RestRequest) NodeClient(org.elasticsearch.client.node.NodeClient) Collections(java.util.Collections) AcknowledgedRestListener(org.elasticsearch.rest.action.AcknowledgedRestListener) PutIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest)

Example 2 with PutIndexTemplateRequest

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\"}");
}
Also used : PutIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest) Test(org.junit.Test)

Example 3 with PutIndexTemplateRequest

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\"}");
}
Also used : PutIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest) Test(org.junit.Test)

Example 4 with PutIndexTemplateRequest

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\"}");
}
Also used : PutIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest) Test(org.junit.Test)

Example 5 with PutIndexTemplateRequest

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);
}
Also used : Alias(org.elasticsearch.action.admin.indices.alias.Alias) PutIndexTemplateRequest(org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest)

Aggregations

PutIndexTemplateRequest (org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest)9 Test (org.junit.Test)4 IOException (java.io.IOException)2 Alias (org.elasticsearch.action.admin.indices.alias.Alias)2 Settings (org.elasticsearch.common.settings.Settings)2 FutureActionListener (io.crate.action.FutureActionListener)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 GetIndexTemplatesRequest (org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesRequest)1 GetIndexTemplatesResponse (org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse)1 PutIndexTemplateResponse (org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse)1 NodeClient (org.elasticsearch.client.node.NodeClient)1 AliasMetaData (org.elasticsearch.cluster.metadata.AliasMetaData)1 IndexTemplateMetaData (org.elasticsearch.cluster.metadata.IndexTemplateMetaData)1 Strings (org.elasticsearch.common.Strings)1 DeprecationLogger (org.elasticsearch.common.logging.DeprecationLogger)1 Loggers (org.elasticsearch.common.logging.Loggers)1 IndexClosedException (org.elasticsearch.indices.IndexClosedException)1 BaseRestHandler (org.elasticsearch.rest.BaseRestHandler)1