How to update by inline script using logstash ES output

I use the following config to update document by id with inlined script, but it is not working. Any one knows why?

elasticsearch {
  index => "announcement%{[@metadata][suffix]}"
  document_type => "announcement"
  document_id => "%{[@metadata][id]}"
  hosts => ["localhost:9200"]
  action => "update"
  doc_as_upsert => true
  script => "ctx._source.roles.add(event[@metadata][role_id])"
  script_lang => "painless"
  script_var_name => "event"
  script_type => "inline"
}

The input data is correct because I print out the data:

stdout {
  codec => rubydebug { metadata => true }
}
1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.