You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
556 B

from Config.Config import ES_CONFIG
from elasticsearch import Elasticsearch
import warnings
# 初始化ES连接
es = Elasticsearch(
hosts=ES_CONFIG["hosts"],
basic_auth=ES_CONFIG["basic_auth"],
verify_certs=ES_CONFIG["verify_certs"],
ssl_show_warn=ES_CONFIG["ssl_show_warn"]
)
# 在T3_LinkEs.py中添加测试
res = es.indices.analyze(
index="knowledge_base",
body={"text": "云南省初中在校生情况", "analyzer": "ik_smart"}
)
print(res)
# 预期输出:['云南省', '初中', '在校生', '情况']