Creating single index only

Hi,

output {
stdout {codec => rubydebug}
if [type] == "Apache" {
elasticsearch {
hosts => "localhost:9200"
index => "apache2"
}
} else {
elasticsearch {
hosts => "localhost:9200"
index => "auth2"
}
}
}

I have used this syntax .still it is creating only auth2 index