Every output allows you to specify the codec option because it is implemented by the base codec class that they extend. But that doesn't mean they use the codec to send the event to the destination.
The elasticsearch output ignores the codec option and formats the event as a JSON string, because that's what the _bulk API requires.
If you use store_xml you have to specify a target, if you want to move the fields back up to the top-level of the event then see this thread.