org.elasticsearch.client.indices.PutIndexTemplateRequest Java Examples
The following examples show how to use
org.elasticsearch.client.indices.PutIndexTemplateRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticSearch7Client.java From skywalking with Apache License 2.0 | 6 votes |
public boolean createTemplate(String indexName, Map<String, Object> settings, Map<String, Object> mapping) throws IOException { indexName = formatIndexName(indexName); PutIndexTemplateRequest putIndexTemplateRequest = new PutIndexTemplateRequest(indexName).patterns( Collections.singletonList(indexName + "-*")) .alias(new Alias( indexName)) .settings(settings) .mapping(mapping); AcknowledgedResponse acknowledgedResponse = client.indices() .putTemplate(putIndexTemplateRequest, RequestOptions.DEFAULT); return acknowledgedResponse.isAcknowledged(); }
Example #2
Source File: TemplateElasticSearchIndexStrategy.java From jetlinks-community with Apache License 2.0 | 5 votes |
protected PutIndexTemplateRequest createIndexTemplateRequest(ElasticSearchIndexMetadata metadata) { String index = wrapIndex(metadata.getIndex()); PutIndexTemplateRequest request = new PutIndexTemplateRequest(getTemplate(index)); request.alias(new Alias(getAlias(index))); request.settings(properties.toSettings()); Map<String, Object> mappingConfig = new HashMap<>(); mappingConfig.put("properties", createElasticProperties(metadata.getProperties())); mappingConfig.put("dynamic_templates", createDynamicTemplates()); request.mapping(mappingConfig); request.patterns(getIndexPatterns(index)); return request; }
Example #3
Source File: ElasticSearchImpl.java From core-ng-project with Apache License 2.0 | 5 votes |
@Override public void putIndexTemplate(String name, String source) { var watch = new StopWatch(); try { client().indices().putTemplate(new PutIndexTemplateRequest(name).source(new BytesArray(source), XContentType.JSON), RequestOptions.DEFAULT); } catch (IOException e) { throw new UncheckedIOException(e); } finally { logger.info("put index template, name={}, elapsed={}", name, watch.elapsed()); } }