赞
踩
在已存在的索引mapping中添加字段,基于es7.17.6
private static void putMapping() { try { // 创建PutMappingRequest对象 PutMappingRequest request = new PutMappingRequest(indexName); // 定义字段的映射 String mappingJson = "{" + " \"properties\":{" + " \"field_name\": {" + " \"type\": \"keyword\"" + " }" + " }" // 将JSON字符串添加到请求中 request.source(mappingJson, XContentType.JSON); // 发送请求更新映射 client.indices().putMapping(request, RequestOptions.DEFAULT); System.out.println("Mapping updated successfully");
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。