elasticsearch reindex

  • 本地reindex
POST _reindex?wait_for_completion=true
{
  "source": {
    "index": "person"
  },
  "dest": {
    "index": "people"
  }
}
View Code
  • 远程reindex

elasticsearch.yml  加入

reindex.remote.whitelist: [sorce:9200]

否则出现以下错误

"reason" : "[xxxxxxx:9200] not whitelisted in reindex.remote.whitelist"

对SSL,要加入源的证书,要不会报错

 unable to find valid certification path to requested target

reindex.ssl.certificate_authorities: certs/elasticsearch-ca.pem
reindex.ssl.verification_mode: certificate

开始reindex

POST _reindex?wait_for_completion=false
{
  "source": {
    "remote": {
      "host": "https://win88.inno.com:9200",
      "username": "elastic",
      "password": "xxxxxxx"
    },
    "index": "student"
  },
  "dest": {
    "index": "student"
  }
}

查看结果成功

get student/_search
  • Modify documents during reindexing

POST _reindex
{
  "source": {
    "index": "my-index-000001"
  },
  "dest": {
    "index": "my-new-index-000001",
    "version_type": "external"
  },
  "script": {
    "source": "if (ctx._source.foo == 'bar') {ctx._version++; ctx._source.remove('foo')}",
    "lang": "painless"
  }
}

参考:

https://www.elastic.co/guide/en/elasticsearch/reference/7.15/docs-reindex.html

每天进步一点点,多思考,多总结 版权声明:本文为CNblog博主「zaituzhong」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文地址:https://www.cnblogs.com/tingxin/p/15555974.html