How to use script upsert in logstash for updating document

I am using below output block to upsert the document and incrementing the counter (partial updates) for an existing document with matching ID.

Currently, post first doc entry into elasticsearch , "script" has not impact through the subsequent update calls. It is not incrementing the counter value

Below is the output block of logstash using upsert and script:

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

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