'commit'
This commit is contained in:
@@ -71,20 +71,6 @@ def save_student_info_to_es(user_id, info):
|
|||||||
es_conn = search_util.es_pool.get_connection()
|
es_conn = search_util.es_pool.get_connection()
|
||||||
try:
|
try:
|
||||||
# 确保索引存在,如果不存在则创建
|
# 确保索引存在,如果不存在则创建
|
||||||
if not es_conn.indices.exists(index="student_info"):
|
|
||||||
es_conn.indices.create(
|
|
||||||
index="student_info",
|
|
||||||
body={
|
|
||||||
"mappings": {
|
|
||||||
"properties": {
|
|
||||||
"user_id": {"type": "keyword"},
|
|
||||||
"info": {"type": "object"},
|
|
||||||
"update_time": {"type": "date", "format": "yyyy-MM-dd HH:mm:ss"}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
logger.info("创建student_info索引成功")
|
|
||||||
es_conn.index(index="student_info", id=doc_id, document=doc)
|
es_conn.index(index="student_info", id=doc_id, document=doc)
|
||||||
logger.info(f"学生 {user_id} 的信息已保存到ES: {info}")
|
logger.info(f"学生 {user_id} 的信息已保存到ES: {info}")
|
||||||
finally:
|
finally:
|
||||||
|
Reference in New Issue
Block a user