5.x版本使用reindex进行分割:
#创建时间取余3进行分割,分割成3个索引
_reindex?wait_for_completion=false
{
"conflicts": "proceed",
"source": {
"index": "yourIndex"
},
"dest": {
"index": "yourIndex-"
},
"script": {
"inline": "ctx._index='yourIndex-' + Long.valueOf(ctx._source.createTime%3).toString();"
}
}
#按照id hashcode进行区分
{
"conflicts": "proceed",
"source": {
"index": "yourIndex"
},
"dest": {
"index": "yourIndex-"
},
"script": {
"inline": "ctx._index='yourIndex-'+((int)Math.abs(ctx._id.hashCode()%2));"
}
}