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));
}
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;
}
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();
});
}
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());
}
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);
}
Aggregations