李锋镝的博客

  • 首页
  • 时间轴
  • 留言
  • 插件
  • 左邻右舍
  • 关于我
    • 关于我
    • 另一个网站
    • 我的导航站
  • 赞助
Destiny
自是人生长恨水长东
  1. 首页
  2. 原创
  3. 正文

ElasticSearch添加mapping

2019年6月14日 19177点热度 0人点赞 0条评论

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"
        }}
    ]
}
'

然后同步数据......

数据同步之后,删除老的索引即可。

除非注明,否则均为李锋镝的博客原创文章,转载必须以链接形式标明本文链接

本文链接:https://www.lifengdi.com/article/137

相关文章

  • SpringBoot整合Elasticsearch游标查询(scroll)
  • Elasticsearch零停机迁移数据
  • Elasticsearch的分布式文档存储原理
  • 解决Elasticsearch分页查询窗口数据太大问题
  • Elasticsearch常用查询
本作品采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可
标签: ElasticSearch
最后更新:2019年6月14日

李锋镝

既然选择了远方,便只顾风雨兼程。

打赏 点赞
< 上一篇
下一篇 >

文章评论

1 2 3 4 5 6 7 8 9 11 12 13 14 15 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 46 47 48 49 50 51 52 53 54 55 57 58 60 61 62 63 64 65 66 67 69 72 74 76 77 78 79 80 81 82 85 86 87 90 92 93 94 95 96 97 98 99
取消回复

COPYRIGHT © 2025 lifengdi.com. ALL RIGHTS RESERVED.

Theme Kratos Made By Dylan

津ICP备2024022503号-3