我有大约2000多个文档,文件名为“ Contact.txt”,我正在尝试通过执行以下操作为所有这些文件修改一个名为text: {class: 'contact'}
的字段:
q = {
"script": {
"inline": "ctx._source.text.class='contact'",
"lang": "painless"
},
"query": {
"match": {
"name": "Contact.txt"
},
}
}
try:
es.update_by_query(body=q, index='index_name')
except Exception as e:
print(e)
我的try / catch给我错误:
TransportError(500, 'script_exception', 'runtime error')
答案 0 :(得分:1)
文档中不存在text
字段,因此,更新脚本应如下所示:
{
"script": {
"source": "ctx._source['text'] = params.text",
"params": {
"text": {
"class": "contact"
}
},
"lang": "painless"
},
"query": {
"match": {
"name": "Contact.txt"
}
}
}