ES怎么进行字段添加索引,并保留原有数据

1、先将原索引进行备份

curl -XPOST '192.168.46.163:9200/_reindex?pretty' -H 'Content-Type: application/json' -d'

{

  "source": {

    "index": "t_finger"

  },

  "dest": {

    "index": "t_finger180131"

  }

}'

2、创建新索引

 

curl -XPUT 192.168.46.163:9200/t_finger

curl -XPUT 192.168.46.163:9200/t_finger/_mapping/t_finger?pretty -d '{

         "properties":{

                   "deviceId":{"type":"string"},

                   "fingerId":{"type":"string"},

                   "clientId":{"type":"string"},

                   "browser":{"type":"string"},

                   "ip":{"type":"string"},

                   "country":{"type":"string","index":"not_analyzed"}

    }

}'

3、迁移数据到新建索引

curl -XPOST '192.168.46.163:9200/_reindex?pretty' -H 'Content-Type: application/json' -d'

{

  "source": {

    "index": "t_finger180131"

  },

  "dest": {

    "index": "t_finger"

  }

}'

 

原文地址:https://www.cnblogs.com/atomicbomb/p/8391606.html