This commit is contained in:
2025-08-19 13:31:18 +08:00
parent 35c5abd81a
commit 96dbe96921
5 changed files with 83 additions and 37 deletions

View File

@@ -4,8 +4,29 @@ from ElasticSearch.Utils.EsSearchUtil import EsSearchUtil
# 创建EsSearchUtil实例
search_util = EsSearchUtil(Config.ES_CONFIG)
# 调用重建mapping方法
if search_util.rebuild_mapping():
print("重建mapping操作完成成功")
else:
print("重建mapping操作失败")
def rebuild_index(index_name):
"""
重建指定的索引
参数:
index_name: 要重建的索引名称
返回:
bool: 操作是否成功
"""
print(f"开始重建索引: {index_name}")
if search_util.rebuild_mapping(index_name):
print(f"重建索引 '{index_name}' 操作成功")
return True
else:
print(f"重建索引 '{index_name}' 操作失败")
return False
if __name__ == "__main__":
# 重建ds_db索引
rebuild_index(Config.ES_CONFIG['index_name'])
# 重建student_info索引
rebuild_index(Config.ES_CONFIG['student_info_index'])
print("所有索引重建操作完成")