"""
重建索引，必须索引名不相同，不能自己重建自己。
"""
from base.utils.es_helper import es_query, es_insert_one, es


def doEsMove(index, index_new):
    body = {
        "source": {
            "index": index
        },
        "dest": {
            "index": index_new,
            "version_type": "internal"
        }
    }
    print(es.reindex(body))
    print(f"index:{index}已完成")


if __name__ == '__main__':
    doEsMove("test-2021.02", "test-2021.03")
    # thread_list = []
    # for i in range(7, 14):
    #     if i < 10:
    #         index = f"aic_ik-2021.01.0{i}"
    #     else:
    #         index = f"aic_ik-2021.01.{i}"
    #
    #     print(index)
    #     thread = threading.Thread(target=doEsMove, args=(index,))
    #     thread.start()
    #     thread_list.append(thread)
    # for i, thread in enumerate(thread_list):
    #     thread.join()
    #     print(f"监控线程ID:{i} 已完成")
    #
    #
    # print("全部完成")
