本文整理汇总了Java中org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest类的典型用法代码示例。如果您正苦于以下问题:Java PutIndexTemplateRequest类的具体用法?Java PutIndexTemplateRequest怎么用?Java PutIndexTemplateRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PutIndexTemplateRequest类属于org.elasticsearch.action.admin.indices.template.put包,在下文中一共展示了PutIndexTemplateRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareRequest
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
@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));
}
示例2: updateTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
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.defaultMappingMap)
.create(false)
.settings(updateSettings)
.template(templateName + "*");
for (String alias : md.aliases()) {
request = request.alias(new Alias(alias));
}
transportPutIndexTemplateAction.execute(request);
}
示例3: updateTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
private ListenableFuture<Long> updateTemplate(Map<String, Object> newMappings,
Settings newSettings,
TableIdent tableIdent,
AbstractDDLAnalyzedStatement statement) {
String templateName = PartitionName.templateName(tableIdent.schema(), tableIdent.name());
IndexTemplateMetaData indexTemplateMetaData =
clusterService.state().metaData().templates().get(templateName);
if (indexTemplateMetaData == null) {
return Futures.immediateFailedFuture(new RuntimeException("Template for partitioned table is missing"));
}
// merge mappings
Map<String, Object> mapping = mergeTemplateMapping(indexTemplateMetaData, newMappings);
// merge settings
Settings.Builder settingsBuilder = Settings.builder();
settingsBuilder.put(indexTemplateMetaData.settings());
settingsBuilder.put(newSettings);
PutIndexTemplateRequest request = new PutIndexTemplateRequest(templateName)
.create(false)
.mapping(Constants.DEFAULT_MAPPING_TYPE, mapping)
.order(indexTemplateMetaData.order())
.settings(settingsBuilder.build())
.template(indexTemplateMetaData.template());
request.putHeader(LoginUserContext.USER_INFO_KEY, statement.getParameterContext().getLoginUserContext());
for (ObjectObjectCursor<String, AliasMetaData> container : indexTemplateMetaData.aliases()) {
Alias alias = new Alias(container.key);
request.alias(alias);
}
SettableFuture<Long> result = SettableFuture.create();
transportActionProvider.transportPutIndexTemplateAction().execute(request,
new SettableFutureToNullActionListener<PutIndexTemplateResponse>(result));
return result;
}
示例4: createTemplateRequest
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
private PutIndexTemplateRequest createTemplateRequest(CreateTableAnalyzedStatement statement) {
PutIndexTemplateRequest putIndexTemplateRequest = new PutIndexTemplateRequest(statement.templateName())
.mapping(Constants.DEFAULT_MAPPING_TYPE, statement.mapping())
.create(true)
.settings(settings(statement))
.template(statement.templatePrefix())
.order(100)
.alias(new Alias(statement.tableIdent().indexName()));
putIndexTemplateRequest.putHeader(LoginUserContext.USER_INFO_KEY, statement.getParameterContext().getLoginUserContext());
return putIndexTemplateRequest;
}
示例5: buildRequest
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
private PutIndexTemplateRequest buildRequest(ESCreateTemplateNode node) {
PutIndexTemplateRequest templateRequest = new PutIndexTemplateRequest(node.templateName())
.mapping(Constants.DEFAULT_MAPPING_TYPE, node.mapping())
.create(true)
.settings(node.indexSettings())
.template(node.indexMatch());
if (node.alias() != null) {
templateRequest.alias(new Alias(node.alias()));
}
templateRequest.putHeader(LoginUserContext.USER_INFO_KEY, getParamContext().getLoginUserContext());
return templateRequest;
}
示例6: handleRequest
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name"));
putRequest.template(request.param("template", putRequest.template()));
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());
client.admin().indices().putTemplate(putRequest, new AcknowledgedRestListener<PutIndexTemplateResponse>(channel));
}
示例7: execute
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
@Override
public void execute(IndexTemplate indexTemplate) {
try {
createClient().admin().indices().putTemplate(
new PutIndexTemplateRequest()
.name(indexTemplate.getName())
.source(indexTemplate.getSource(), XContentType.JSON)
);
} catch (Exception e) {
LOG.error("Unable to add index template", e);
}
}
示例8: execute
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
@Override
public void execute(IndexTemplate indexTemplate) {
try {
createClient().admin().indices().putTemplate(
new PutIndexTemplateRequest()
.name(indexTemplate.getName())
.source(indexTemplate.getSource())
);
} catch (Exception e) {
LOG.error("Unable to add index template", e);
}
}
示例9: before
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
@Before
public void before() throws IOException {
repository = factory.create(Person.class);
repository.refreshPolicy(IMMEDIATE);
final IndicesAdminClient indices = client.admin().indices();
final PutIndexTemplateRequest datas = indices.preparePutTemplate("datas")
.setSource(toByteArray(getClass().getResourceAsStream("/datas.json")), JSON)
.request();
checkState(indices.putTemplate(datas).actionGet().isAcknowledged());
}
示例10: ensureTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
@Override
public void ensureTemplate(String name, String indexTemplate) {
GetIndexTemplatesResponse existingTemplates =
client.admin().indices().getTemplates(new GetIndexTemplatesRequest(name))
.actionGet();
if (!existingTemplates.getIndexTemplates().isEmpty()) {
return;
}
client.admin().indices().putTemplate(
new PutIndexTemplateRequest(name).source(indexTemplate)).actionGet();
}
示例11: getClusterTemplateMapping
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
public static PutIndexTemplateRequest getClusterTemplateMapping(IndicesAdminClient indicesAdminClient) {
try {
PutIndexTemplateRequestBuilder builder = new PutIndexTemplateRequestBuilder(indicesAdminClient, "generic_template");
builder.setTemplate(String.format("%s-*", ElasticsearchUtils.TABLENAME_PREFIX));
System.out.println(getDocumentMapping().string());
builder.addMapping(DOCUMENT_TYPE_NAME, getDocumentMapping());
return builder.request();
} catch (IOException ex) {
logger.error("TEMPLATE_CREATION_FAILED", ex);
return null;
}
}
示例12: setIndexTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
public boolean setIndexTemplate(String indexName, String template, Client esClient) {
try {
esClient.admin().indices().putTemplate(new PutIndexTemplateRequest(indexName).source(template));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例13: toXContent
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
@Override
protected XContentBuilder toXContent(PutIndexTemplateRequest request, PutIndexTemplateResponse response, XContentBuilder builder) throws IOException {
builder.startObject()
.field(Fields.OK, true)
.field(Fields.ACKNOWLEDGED, response.isAcknowledged())
.endObject();
return builder;
}
示例14: putTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
@Override
public ActionFuture<PutIndexTemplateResponse> putTemplate(final PutIndexTemplateRequest request) {
return execute(PutIndexTemplateAction.INSTANCE, request);
}
示例15: putIndexTemplate
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; //导入依赖的package包/类
public void putIndexTemplate(PutIndexTemplateRequest request, ActionListener<PutIndexTemplateResponse> listener) {
putIndexTemplateActionHandler.execute(request, listener);
}