gpt4 book ai didi

amazon-web-services - 如何在AWS ES中启用动态脚本编制?

转载 作者:行者123 更新时间:2023-12-02 22:23:40 25 4
gpt4 key购买 nike

我正在使用AWS flex 服务并已索引650 000数据。
我需要在已经建立索引的文档中添加两个新字段。
当我尝试调用updateByQuery函数时收到错误消息,“类型为[inline],操作[update]和lang [groovy]的脚本被禁用”。
我通过添加来修复它
script.engine.groovy.inline.aggs:在
script.engine.groovy.inline.update:在elasticsearch.yml上启用,并且在local上效果很好。
如何在AWS ES上添加此配置?
在AWS Elastic Service中更新文档时遇到相同的错误。

这是我的代码。我想通过添加新字段“站点和时间”来更新所有记录(其中“设备” = 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)
});

最佳答案

在我们使用logstash将索引重新索引到AWS ES集群的the other answer的基础上,您只需要在提到了# add other transformations here的地方再添加一个转换。

在您的情况下,输入部分需要包含设备查询:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com