我正在使用 aws 弹性服务并索引了 650 000 个数据。
我需要向已索引的文档添加两个新字段。
当我尝试调用 updateByQuery 函数时出现错误,“类型 [inline]、操作 [update] 和 lang [groovy] 的脚本被禁用”。
我已经通过添加修复了它
script.engine.groovy.inline.aggs:开启
script.engine.groovy.inline.update:在elasticsearch.yml上,它在本地完美运行。
如何在 aws es 上添加此配置?
当我更新 aws elastic 服务中的文档时,我遇到了同样的错误。
这是我的代码。我想通过添加新字段“站点”和“时间”来更新所有记录(其中“device”= deviceVal)。
var site = 'some value';
var deviceVal = '123';
var theScript = {
"inline": "ctx._source.Site = '"+ site + "';ctx._source.Time = '"+ new Date().getTime() + "'"
}
var match = {
"match": { "device": deviceVal }
}
client.updateByQuery({
index: 'my_index',
type:'txt',
"body": {
"query": match,
"script":theScript
}
}, function (error, response) {
// console.log("success")
console.log('error--',error)
console.log('response--',response)
});
最佳答案
构建于 the other answer当我们使用 Logstash 重新索引到 AWS ES 集群时,您只需要再添加一个转换,其中提到了# add other conversions
。
在您的情况下,输入部分需要包含设备的查询:
input {
elasticsearch {
hosts => ["my-elasticsearch-domain.us-west-2.es.amazonaws.com:80"]
index => "my_index"
query => '{"query": {"match":{"device": "123"}}}'
docinfo => true
}
}
过滤器部分将归结为这一点,即我们重命名 @timestamp
字段并添加 Site
字段:
filter {
mutate {
remove_field => [ "@version" ]
rename => { "@timestamp" => "Time" }
add_field => { "Site" => "some value" }
}
}
关于amazon-web-services - 如何在 AWS ES 中启用动态脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40766848/