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

posted on 2021-11-15 13:53  InnoLeo  阅读(730)  评论(0编辑  收藏  举报