スキーマって言うとめっちゃコラコラされそうだが。(正確にはmapping
環境
- Ubuntu 16.04
- Elasticsearch5
ElasticsearchのReindex APIはElasticsearch 2.3.0以降で実装された機能で、その名の通り既存のindexのドキュメントをコピーすることができる。
ここではindex「twitter」から「twitter_new」にコピーするとする。
やりかた
まずコピー先のindexを先に作成する。
curl -XPUT localhost:9200/twitter_new -d@tw.json
当然中身はまだ空
次にreindex用のjsonをreindex.jsonとして用意する。typeは指定しないとindex内の全ドキュメントをコピーするので注意。
{ "source": { "index": "twitter", "type": "tweet" }, "dest": { "index": "twitter_new", "type": "tweet" } }
あとは作ったjsonを指定してreindex APIを叩くだけ
curl -XPOST dev41:9200/_reindex -d@reindex.json
以下のような返ってくればおk
{ "took": 16808, "timed_out": false, "total": 152257, "updated": 0, "created": 152257, "deleted": 0, "batches": 153, "version_conflicts": 0, "noops": 0, "retries": { "bulk": 0, "search": 0 }, "throttled_millis": 0, "requests_per_second": -1, "throttled_until_millis": 0, "failures": [] }