'Index document to multiple indicies at once from logstash

So I have no issues with indexing a record from logstash, however I want to be able to index the same record to multiple indicies.

Currently in my logstash output i have this:

output{
     elasticsearch {
        hosts => ["myHost"]
        user => "myUser"
        password => "myPassword"
        cacert => "myCert.pem"
        index => "myIndex_primary"
        document_id => "12345"
        action => "update"
        doc_as_upsert => true
        manage_template => false
    }
}

Lets say I also wanted to save the same record to a 'secondary' index. Is this possible from the same elasticsearch or would have be forces to duplicate the entire elasticsearch call?

My thought would be something like:

output{
    elasticsearch {
        hosts => ["myHost"]
        user => "myUser"
        password => "myPassword"
        cacert => "myCert.pem"
        index => ["myIndex_primary", "myIndex_secondary"]
        document_id => "12345"
        action => "update"
        doc_as_upsert => true
        manage_template => false
   }
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source