备注:
test_idx: 索引名称
test: 索引中 mappings 的下一级对象
bookNum: 需要添加的属性
obj1: 索引中的子对象
响应如下才能说明新增成功
2.给新增的字段增加默认值
背景:
Elasticsearch具有动态mapping的功能,如果没有设置字段的映射,Elasticsearch将会对字段进行动态映射。但是有时候动态映射会出现不符合业务需求的字段映射,比如时间戳的映射,elasticsearch将其自动映射为long类型,但是在业务使用中需要date类型。
更改索引blog中的动态映射字段priority数据类型:由long更改为date
一、新建动态索引模板,此时time字段为long类型
puthttp://localhost:9200/_template/test
2、存入样本数据
post http://localhost:9200/test_001/test
3、更改动态模板中time的字段类型为date,并新建索引模板,同步骤1
put http://localhost:9200/_template/test
4、将test_001数据reindex到test_001_new
post http://localhost:9200/_reindex
5、删除旧索引 test_001
delete http://localhost:9200/test_001
6、将test_001_new数据reindex到test_001
post http://localhost:9200/_reindex
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)