Search in sources :

Example 1 with GetIndexTemplatesRequest

use of org.elasticsearch.client.indices.GetIndexTemplatesRequest in project graylog2-server by Graylog2.

the class ClientES7 method templateExists.

@Override
public boolean templateExists(String templateName) {
    final GetIndexTemplatesRequest request = new GetIndexTemplatesRequest("*");
    final GetIndexTemplatesResponse result = client.execute((c, requestOptions) -> c.indices().getIndexTemplate(request, requestOptions));
    return result.getIndexTemplates().stream().anyMatch(indexTemplate -> indexTemplate.name().equals(templateName));
}
Also used : GetIndexTemplatesResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.indices.GetIndexTemplatesResponse) GetIndexTemplatesRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.indices.GetIndexTemplatesRequest)

Example 2 with GetIndexTemplatesRequest

use of org.elasticsearch.client.indices.GetIndexTemplatesRequest in project LinkAgent by shulieTech.

the class GetIndexTemplatesRequestIndexRename method reindex0.

@Override
public List<String> reindex0(Object target) {
    GetIndexTemplatesRequest req = (GetIndexTemplatesRequest) target;
    List<String> names = req.names();
    for (int i = 0, size = names.size(); i < size; i++) {
        String name = names.get(i);
        /**
         * 如果索引在白名单中,则不需要走
         */
        if (GlobalConfig.getInstance().getSearchWhiteList().contains(name)) {
            continue;
        }
        if (!Pradar.isClusterTestPrefix(name)) {
            name = Pradar.addClusterTestPrefixLower(name);
        }
        names.set(i, name);
    }
    return names;
}
Also used : GetIndexTemplatesRequest(org.elasticsearch.client.indices.GetIndexTemplatesRequest)

Example 3 with GetIndexTemplatesRequest

use of org.elasticsearch.client.indices.GetIndexTemplatesRequest in project spring-data-elasticsearch by spring-projects.

the class ReactiveIndexTemplate method getTemplate.

@Override
public Mono<TemplateData> getTemplate(GetTemplateRequest getTemplateRequest) {
    Assert.notNull(getTemplateRequest, "getTemplateRequest must not be null");
    GetIndexTemplatesRequest getIndexTemplatesRequest = requestFactory.getIndexTemplatesRequest(getTemplateRequest);
    return Mono.from(operations.executeWithIndicesClient(client -> client.getTemplate(getIndexTemplatesRequest))).flatMap(response -> {
        if (response != null) {
            TemplateData templateData = ResponseConverter.getTemplateData(response, getTemplateRequest.getTemplateName());
            if (templateData != null) {
                return Mono.just(templateData);
            }
        }
        return Mono.empty();
    });
}
Also used : TemplateData(org.springframework.data.elasticsearch.core.index.TemplateData) GetIndexTemplatesRequest(org.elasticsearch.client.indices.GetIndexTemplatesRequest)

Example 4 with GetIndexTemplatesRequest

use of org.elasticsearch.client.indices.GetIndexTemplatesRequest in project spring-data-elasticsearch by spring-projects.

the class RestIndexTemplate method getTemplate.

@Override
public TemplateData getTemplate(GetTemplateRequest getTemplateRequest) {
    Assert.notNull(getTemplateRequest, "getTemplateRequest must not be null");
    // getIndexTemplate throws an error on non-existing template names
    if (!existsTemplate(new ExistsTemplateRequest(getTemplateRequest.getTemplateName()))) {
        return null;
    }
    GetIndexTemplatesRequest getIndexTemplatesRequest = requestFactory.getIndexTemplatesRequest(getTemplateRequest);
    GetIndexTemplatesResponse getIndexTemplatesResponse = restTemplate.execute(client -> client.indices().getIndexTemplate(getIndexTemplatesRequest, RequestOptions.DEFAULT));
    return ResponseConverter.getTemplateData(getIndexTemplatesResponse, getTemplateRequest.getTemplateName());
}
Also used : GetIndexTemplatesResponse(org.elasticsearch.client.indices.GetIndexTemplatesResponse) ExistsTemplateRequest(org.springframework.data.elasticsearch.core.index.ExistsTemplateRequest) GetIndexTemplatesRequest(org.elasticsearch.client.indices.GetIndexTemplatesRequest)

Example 5 with GetIndexTemplatesRequest

use of org.elasticsearch.client.indices.GetIndexTemplatesRequest in project graylog2-server by Graylog2.

the class ClientES7 method existingTemplates.

private String[] existingTemplates() {
    final GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest();
    final GetIndexTemplatesResponse result = client.execute((c, requestOptions) -> c.indices().getIndexTemplate(getIndexTemplatesRequest, requestOptions));
    return result.getIndexTemplates().stream().map(IndexTemplateMetadata::name).toArray(String[]::new);
}
Also used : GetIndexTemplatesResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.indices.GetIndexTemplatesResponse) GetIndexTemplatesRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.indices.GetIndexTemplatesRequest)

Aggregations

GetIndexTemplatesRequest (org.elasticsearch.client.indices.GetIndexTemplatesRequest)7 GetIndexTemplatesResponse (org.elasticsearch.client.indices.GetIndexTemplatesResponse)4 List (java.util.List)2 HttpHost (org.apache.http.HttpHost)2 CreateIndexRequest (org.elasticsearch.action.admin.indices.create.CreateIndexRequest)2 GetIndexRequest (org.elasticsearch.action.admin.indices.get.GetIndexRequest)2 GetRequest (org.elasticsearch.action.get.GetRequest)2 IndexRequest (org.elasticsearch.action.index.IndexRequest)2 RequestOptions (org.elasticsearch.client.RequestOptions)2 RestClient (org.elasticsearch.client.RestClient)2 RestHighLevelClient (org.elasticsearch.client.RestHighLevelClient)2 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1