开发者学堂课程【ElasticSearch 入门精讲:es helper 介绍】学习笔记,与课程紧密连接,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/631/detail/9987
es helper 介绍
使用 Helper 方式新增索引
*/
@Test
public void testNewAddIndexHelperWay( throws l0Exception {
System. out.printIn("正式开始使用[使用 Helper 方式新增索引]了...;
XContentBuilder xContentBuilder = XContentFactory. contentBuilder(XContentType.JSOM
.startObject()
.field( name: "name", value: "sqoop")
.field( name: "author", value: "小鱼儿”)
.field( name: "version", value: "2.1.1")
.endObject();
IndexResponse response = client.preparelndex(INDEX, TYP).setSource(xContentBuilder).get();
System. outprintf("待新增的索引信息是: %s, es 集群反馈的结果是: %s%n" ',xContentBuilder,response.toString();