我有一些文件名为'Contact.txt‘的2000+文档,我正在尝试修改所有这些文件的名为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')发布于 2019-05-31 11:10:16
文档中不存在text字段,因此更新脚本应如下所示:
{
"script": {
"source": "ctx._source['text'] = params.text",
"params": {
"text": {
"class": "contact"
}
},
"lang": "painless"
},
"query": {
"match": {
"name": "Contact.txt"
}
}
}https://stackoverflow.com/questions/56387374
复制相似问题