# How to update by inline script using logstash ES output

**URL:** <https://discuss.elastic.co/t/how-to-update-by-inline-script-using-logstash-es-output/119176>\
**Category:** Logstash\
**Created:** [February 9, 2018, 6:51am UTC](https://discuss.elastic.co/t/how-to-update-by-inline-script-using-logstash-es-output/119176 "2018-02-09T06:51:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zt\_Zeng](https://avatars.discourse-cdn.com/v4/letter/z/b77776/32.png) [@Zt\_Zeng](https://discuss.elastic.co/u/Zt_Zeng)\
**Post date:** [February 9, 2018, 6:51am UTC](https://discuss.elastic.co/t/how-to-update-by-inline-script-using-logstash-es-output/119176/1 "2018-02-09T06:51:23Z")

</div>

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 }
}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 9, 2018, 6:51am UTC](https://discuss.elastic.co/t/how-to-update-by-inline-script-using-logstash-es-output/119176/2 "2018-03-09T06:51:27Z")

</div>

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