赞
踩
注:
ES新建库就是所谓的新建索引。一个索引不要采用删除后重建数据迁移的方法,数据量太大,会有服务中断时间。
GET /库名(索引名)/_mapping
PUT /库名(索引名)/type(类型-可省略)/_mapping { "properties": { "new_field": { "type": "text",(类型:text-支持分词,keyword-不支持分词) "analyzer": "standard"(可省略--省略时为默认) } } }
在我们进行ES索引mapping结果修改后,已有数据是并没有改新增字段的
POST /库名(索引名)/_update_by_query { "script": { "inline":"new_field = '12222'" }, "query": { "match_all":{...} } }
只有在查询新字段时,系统会根据新字段类型自动返回默认值或者空值
PUT /{索引名}/_mapping { "properties": { "old_field": { "type":"object", "enabled": false } } }
PUT /{索引名}/_mapping { "properties": { "new_field": { "type": "text", "analyzer": "standard", "fields": { (新字段子属性) "keyword": { "type": "keyword", "ignore_above": 256 } }, "null_value": "null" (该字段的默认值) } } }
{ "query": "ALTER TABLE {索引名} ADD new_field TEXT" }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。