我有大量文档矢量化得很差/正在使用旧的 multimodal_field_combination。
mappings={
'combo_text_image': {
"type": "multimodal_combination",
"weights": {
"name": 0.05,
"description": 0.15,
"image_url": 0.8
}
}
},
但是我需要更新到
mappings={
'combo_text_image': {
"type": "multimodal_combination",
"weights": {
"name": 0.2,
"image_url": 0.8
}
}
},
我意识到要在同一个索引中执行此操作,我应该删除文档然后重新索引,但我一直找不到
mq.delete_all_documents()
调用。最好的方法是什么?
这是一个代码片段,它将从索引中删除所有文档:
def empty_index(index_name):
index = mq.index(index_name)
res = index.search(q = '', limit=400)
while len(res['hits']) > 0:
id_set = []
for hit in res['hits']:
id_set.append(hit['_id'])
index.delete_documents(id_set)
res = index.search(q = '', limit=400)