POST _reindex
{
"source":{
"index":"my_index",
"type":"my_type",
"query":{
"term":{"title":"elasticsearch"}
}
},
"dest":{"index":"my_index3"}
} 8 收缩索引
直接参考官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/5.4/indices-shrink-index.html,非常详细。
The shrink index API allows you to shrink an existing index into a new index with fewer primary shards. The requested number of primary shards in the target index must be a factor of the number of shards in the source index. For example an index with 8 primary shards can be shrunk into 4, 2or 1 primary shards or an index with 15 primary shards can be shrunk into 5, 3 or 1. If the number of shards in the index is a prime number it can only be shrunk into a single primary shard. Before shrinking, a (primary or replica) copy of every shard in the index must be present on the same node.
Shrinking works as follows:
First, it creates a new target index with the same definition as the source index, but with a smaller number of primary shards.
Then it hard-links segments from the source index into the target index. (If the file system doesn’t support hard-linking, then all segments are copied into the new index, which is a much more time consuming process.)
Finally, it recovers the target index as though it were a closed index which had just been re-opened.