71 lines
2.5 KiB
Python
71 lines
2.5 KiB
Python
from APP.exts import client_init
|
|
|
|
es = client_init()
|
|
|
|
def create_prescription_index():
|
|
index_name = "prescription_index"
|
|
index_mappings = {
|
|
"mappings": {
|
|
"properties": {
|
|
"prescription_name": {"type": "text"},
|
|
"provenance": {"type": "text"},
|
|
"composition": {"type": "text"},
|
|
"function": {"type": "text"},
|
|
"main_indication": {"type": "text"},
|
|
"usage": {"type": "text"},
|
|
"taboo": {"type": "text"},
|
|
"explain": {"type": "text"},
|
|
"variation": {"type": "text"},
|
|
"Additional_Formulas": {"type": "text"},
|
|
"annotation": {"type": "text"},
|
|
"document": {"type": "text"}
|
|
}
|
|
}
|
|
}
|
|
|
|
try:
|
|
response = es.indices.create(index=index_name, body=index_mappings)
|
|
print(response)
|
|
except Exception as e:
|
|
print(f"Error creating index: {e}")
|
|
|
|
def create_record_index():
|
|
index_name = "record_index"
|
|
index_mappings = {
|
|
"mappings":{
|
|
"properties": {
|
|
"record_department_name": {"type": "text"},
|
|
"record_clasification_name": {"type": "text"},
|
|
"patient_name": {"type": "text"},
|
|
"patient_age": {"type": "text"},
|
|
"patient_gender": {"type": "text"},
|
|
"medicalLibrary_name": {"type": "text"},
|
|
"doctorName": {"type": "text"},
|
|
"treatment_time": {"type": "text"},
|
|
"treatment_number": {"type": "text"},
|
|
"clinical_manifestation": {"type": "text"},
|
|
"tongue_nature": {"type": "text"},
|
|
"tongue_coating": {"type": "text"},
|
|
"pulse_condition": {"type": "text"},
|
|
"WM_disease": {"type": "text"},
|
|
"TCM_disease": {"type": "text"},
|
|
"TCM_syndrome": {"type": "text"},
|
|
"therapeutic_method": {"type": "text"},
|
|
"prescription_name": {"type": "text"},
|
|
"medicine_composition": {"type": "text"},
|
|
"acupuncture_point": {"type": "text"},
|
|
"medicalText": {"type": "text"},
|
|
"source": {"type": "text"},
|
|
}
|
|
}
|
|
}
|
|
try:
|
|
response = es.indices.create(index=index_name, body=index_mappings)
|
|
print(response)
|
|
except Exception as e:
|
|
print(f"Error creating index: {e}")
|
|
|
|
# 然后在需要的时候调用这个函数
|
|
# create_prescription_index()
|
|
# create_record_index()
|