I suspect you are unconditionally doing both the
add_field => { "indexname" => "field_reference1" }
and
add_field => { "indexname" => "field_reference2" }
for the same events. In that case indexname will be an array and if the logstash calls .to_s to convert that to a string (which the index option has to be) then it will end up with comma separated names, causing elasticsearch to throw that exception.