ElasticSearch不支持修改mapping,但是新增mapping还是挺简单的,偶尔倒是可以搞点骚操作。
添加mapping:
curl -X PUT \
http://{ElasticSearchHost}:{Port}/{index}/_mapping/{type} \
-d '{
"properties": {
"field": {
"type": "nested",
"properties": {
"name": {
"type": "string"
}
}
}
}
}'
如果不想添加mapping,可以新建index,然后使用alias将老的index指向新的index:
curl -XPOST localhost:port/_aliases -d '
{
"actions": [
{ "remove": {
"alias": "index",
"index": "old_index"
}},
{ "add": {
"alias": "index",
"index": "new_index"
}}
]
}
'
然后同步数据......
数据同步之后,删除老的索引即可。
除非注明,否则均为李锋镝的博客原创文章,转载必须以链接形式标明本文链接
文章评论