我正在使用下面的输出块来向上插入文档,并为具有匹配ID的现有文档增加计数器(部分更新)。
当前,将第一个文档条目发布到elasticsearch中,“脚本”不会影响后续的更新调用。它不会增加计数器值
下面是使用upsert和脚本的logstash输出块:
`output {
stdout { }
elasticsearch {
hosts => "localhost"
index => "test_dest"
script => "ctx._source.views+=1"
script_lang => "painless"
script_type => "inline"
# scripted_upsert => true
doc_as_upsert => true
document_id => "%{[userId]}"
}
stdout {
codec => "json"
}
}`
答案 0 :(得分:0)
尝试将scripted_upsert
设置为“ update” ,将output {
elasticsearch {
action => "update"
hosts => "localhost"
index => "test_dest"
script => "ctx._source.views+=1"
script_lang => "painless"
script_type => "inline"
scripted_upsert => true
document_id => "%{[userId]}"
}
}
设置为“ true” ,如下所示:
02(\d{14})37