我创建了一个文件,即,
testfile.painless
ctx._source.b_id=params.b_id;
然后将
testfile.painless
文件放置在集群节点上的 config/scripts 文件夹中,然后尝试使用 _update_by_query
{
"script": {
"id": "testfile",
"params": {
"b_id": "1W"
}
},
"query": {
"bool": {
"must": [
{
"match": {
"a_core": "71"
}
},
{
"match": {
"cid": "3IM"
}
}
]
}
}
}
当我运行更新查询时,我收到无法在集群状态中找到脚本 [testfile] 的信息
脚本不能再存储在文件中,你需要将它们存储在集群状态中,如下所示:
PUT _scripts/testfile
{
"script": {
"source": "....source code of your script..."
}
}
然后您可以像现在一样运行更新查询。