ElasticSearch 复制数据到新的 索引中 copy data to new index

问题:index一旦建立后,无法再修改内部的setting、mapping ,所以只能通过新建备份index,再把data copy过去,然后再把原来的删了,重新建立全新的index

首先需要安装一个插件

elasticsearch-dump  

参考官网:https://github.com/taskrabbit/elasticsearch-dump

新建一个修改后的 index 

然后通过dump命令同步数据

elasticdump \
  --input=http://localhost:9200/cust_2018031916571000000_test\
  --output=http://localhost:9200/cust_2018031916571000000 \
  --type=data
以下共享一个比较复杂的 索引内容,不明白的地方,可以留言问我
PUT cust_2018031916571000000
{
    "settings": {
        "analysis": {
          "analyzer": {
            "my_ngram_analyzer": {
              "tokenizer": "my_ngram_tokenizer"
            }
          },
          "tokenizer": {
            "my_ngram_tokenizer": {
              "token_chars": [
                "letter",
                "digit"
              ],
              "min_gram": "1",
              "type": "nGram",
              "max_gram": "8"
            }
          }
        }
   },
   "mappings": {
      "customer_type": {
        "properties": {
          "createTime": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss"
          },
          "custGrade": {
            "type": "integer"
          },
          "custName": {
            "type": "text",
            "boost": 8,
            "store": true,
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            },
            "analyzer": "my_ngram_analyzer",
            "fielddata": true
          },
          "email": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "followupState": {
            "type": "integer"
          },
          "groups": {
            "type": "long"
          },
          "idInt": {
            "type": "long"
          },
          "mobile": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            },
            "analyzer": "ik_max_word",
            "fielddata": true
          },
          "orgId": {
            "type": "long"
          },
          "salerId": {
            "type": "long"
          },
          "sex": {
            "type": "integer"
          },
          "source": {
            "properties": {
              "type": {
                "type": "long"
              },
              "value": {
                "type": "long"
              }
            }
          },
          "tagCount": {
            "properties": {
              "2534": {
                "type": "long"
              }
            }
          },
          "tags": {
            "type": "long"
          }
        }
      },
      "cust_*": {
        "_all": {
          "enabled": false
        },
        "dynamic_templates": [
          {
            "string_template": {
              "match": "*",
              "match_mapping_type": "string",
              "mapping": {
                "type": "string"
              }
            }
          }
        ],
        "properties": {
          "address": {
            "type": "text"
          },
          "assignTime": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss"
          },
          "birthday": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss"
          },
          "city": {
            "type": "text",
            "analyzer": "ik_max_word",
            "fielddata": true
          },
          "companyName": {
            "type": "text"
          },
          "country": {
            "type": "text",
            "analyzer": "ik_max_word",
            "fielddata": true
          },
          "createTime": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss"
          },
          "custGrade": {
            "type": "integer"
          },
          "custName": {
            "type": "text",
            "boost": 8,
            "store": true,
            "analyzer": "my_ngram_analyzer",
            "include_in_all": true,
            "fielddata": true
          },
          "email": {
            "type": "text"
          },
          "followupState": {
            "type": "integer"
          },
          "groups": {
            "type": "long"
          },
          "idInt": {
            "type": "long"
          },
          "language": {
            "type": "text"
          },
          "lastContactTime": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss"
          },
          "microId": {
            "type": "integer"
          },
          "mobile": {
            "type": "text",
            "analyzer": "ik_max_word",
            "fielddata": true
          },
          "orgId": {
            "type": "long"
          },
          "originalId": {
            "type": "text",
            "fields": {
              "id": {
                "type": "keyword",
                "index": false
              }
            },
            "fielddata": true
          },
          "position": {
            "type": "text"
          },
          "province": {
            "type": "text",
            "analyzer": "ik_max_word",
            "fielddata": true
          },
          "qq": {
            "type": "integer"
          },
          "remark": {
            "type": "text"
          },
          "salerId": {
            "type": "long"
          },
          "sex": {
            "type": "integer"
          },
          "source": {
            "type": "object"
          },
          "tagCount": {
            "type": "object"
          },
          "tags": {
            "type": "long"
          },
          "weibo": {
            "type": "text"
          },
          "wxHeadImgUrl": {
            "type": "text"
          },
          "wxNickname": {
            "type": "text",
            "boost": 8,
            "store": true,
            "analyzer": "my_ngram_analyzer",
            "include_in_all": true,
            "fielddata": true
          },
          "wxOpenid": {
            "type": "text",
            "fields": {
              "id": {
                "type": "keyword",
                "index": false
              }
            },
            "fielddata": true
          },
          "wxPOenid": {
            "type": "text"
          },
          "wxSubscribe": {
            "type": "integer"
          },
          "wxSubscribeTime": {
            "type": "date",
            "format": "yyyy-MM-dd HH:mm:ss"
          },
          "wxUnionid": {
            "type": "text"
          }
        }
      }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值