# Groovy to Painless, get logstash event

**URL:** <https://discuss.elastic.co/t/groovy-to-painless-get-logstash-event/71920>\
**Category:** Elasticsearch\
**Created:** [January 17, 2017, 10:47pm UTC](https://discuss.elastic.co/t/groovy-to-painless-get-logstash-event/71920 "2017-01-17T22:47:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebz](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sebz](https://discuss.elastic.co/u/sebz)\
**Post date:** [January 17, 2017, 10:47pm UTC](https://discuss.elastic.co/t/groovy-to-painless-get-logstash-event/71920/1 "2017-01-17T22:47:58Z")

</div>

Hello,

I'm getting data from logstash, using update by script (indexed or file).  
I need to update a field, only if the value already indexed is less than the one in the logstash event.

With groovy, it works well by using something like:

> if ( ctx.\_source.FIELD \< event.FIELD ) { ctx.\_source.FIELD = event.FIELD }

But I can't find if there's a way to do this with painless. I tried many things like params.FIELD, but I'm unable to get any data.

Here's my output:

> ```
> elasticsearch {
> 
> ```
> 
> hosts =\> ["127.0.0.1:9200"]  
> index =\> "log-%{+YYYY.MM}"  
> document\_type =\> "logdata"  
> action =\> "update"  
> doc\_as\_upsert =\> "true"  
> script\_type =\> "file"  
> script\_lang =\> "painless"  
> script\_var\_name =\> "params"  
> script =\> "updatescript"  
> flush\_size =\> "1500"  
> document\_id =\> "%{[@metadata][generated\_id]}"  
> manage\_template =\> false  
> }

Does anyone have an advice ? Is it still possible to get logstash params from a script ?

Thank you

---

<div class="post-metadata">

**Author:** ![sebz](https://avatars.discourse-cdn.com/v4/letter/s/d2c977/32.png) [@sebz](https://discuss.elastic.co/u/sebz)\
**Post date:** [January 18, 2017, 4:42pm UTC](https://discuss.elastic.co/t/groovy-to-painless-get-logstash-event/71920/2 "2017-01-18T16:42:33Z")

</div>

Ok I found it !

Instead "event.FIELD", I'm able to get params from logstash using "params.event.get("FIELD")"

---

<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:** [February 15, 2017, 4:43pm UTC](https://discuss.elastic.co/t/groovy-to-painless-get-logstash-event/71920/3 "2017-02-15T16:43:24Z")

</div>

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