1、无密码情况
curl -X POST 'localhost:9200/_reindex?pretty' -H 'content-Type:application/json' -d '{"source":{"remote":{"host":"http://172.31.187.255:9200"},"size":100,"index":"x-pack","query":{"match_all":{}}},"dest":{"index":"x-pack"}}'
2、有密码情况
curl -X POST 'localhost:9200/_reindex?pretty' -H 'content-Type:application/json' -d '{"source":{"remote":{"host":"http://172.31.187.255:9200","username":"elastic","password":"pica_elastic@1"},"size":100,"index":"x-pack","query":{"match_all":{}}},"dest":{"index":"x-pack"}}'
3、本地服务也有密码
curl --user elastic:pica_elastic@1 -X POST 'localhost:9200/_reindex?pretty' -H 'content-Type:application/json' -d '{"source":{"remote":{"host":"http://172.31.187.255:9200","username":"elastic","password":"pica_elastic@1"},"size":100,"index":"ocm_event_test","query":{"match_all":{}}},"dest":{"index":"ocm_event_test"}}'
注意:请求尽量都归为一行,避免不必要的错误。