Files
dsProject/dsLightRag/ElasticSearch/T1_RebuildMapping.py

32 lines
878 B
Python
Raw Normal View History

2025-08-19 14:02:48 +08:00
from Config import Config
from ElasticSearch.Utils.EsSearchUtil import EsSearchUtil
# 创建EsSearchUtil实例
search_util = EsSearchUtil(Config.ES_CONFIG)
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("所有索引重建操作完成")