|
|
|
@ -45,3 +45,51 @@ if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
# 创建新的原始文本索引
|
|
|
|
|
manage_index("create", "text")
|
|
|
|
|
|
|
|
|
|
# 修改knowledge_base索引的mapping
|
|
|
|
|
knowledge_base_mapping = {
|
|
|
|
|
"properties": {
|
|
|
|
|
# 在knowledge_base_mapping中添加
|
|
|
|
|
"content": {
|
|
|
|
|
"type": "text",
|
|
|
|
|
"analyzer": "ik_max_word",
|
|
|
|
|
"search_analyzer": "ik_smart",
|
|
|
|
|
"fields": {
|
|
|
|
|
"keyword": {
|
|
|
|
|
"type": "keyword",
|
|
|
|
|
"ignore_above": 8192 # 可以设置为1024/2048等更大值
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
# 在raw_texts_mapping中添加
|
|
|
|
|
"raw_text": {
|
|
|
|
|
"type": "text",
|
|
|
|
|
"analyzer": "ik_max_word",
|
|
|
|
|
"fielddata": True # 允许对长文本进行聚合
|
|
|
|
|
},
|
|
|
|
|
"vector": {
|
|
|
|
|
"type": "dense_vector",
|
|
|
|
|
"dims": 200,
|
|
|
|
|
"index": True,
|
|
|
|
|
"similarity": "cosine"
|
|
|
|
|
},
|
|
|
|
|
"timestamp": {
|
|
|
|
|
"type": "date",
|
|
|
|
|
"format": "strict_date_optional_time||epoch_millis"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 修改raw_texts索引的mapping
|
|
|
|
|
raw_texts_mapping = {
|
|
|
|
|
"properties": {
|
|
|
|
|
"raw_text": {
|
|
|
|
|
"type": "text",
|
|
|
|
|
"analyzer": "ik_max_word"
|
|
|
|
|
},
|
|
|
|
|
"timestamp": {
|
|
|
|
|
"type": "date",
|
|
|
|
|
"format": "strict_date_optional_time||epoch_millis"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|