Add two value from two record

Pretty much anything is possible in logstash. You could do this in an aggregate filter. There are a couple of approaches, but in both you will have to save the name and code1 values in the map, then event.cancel those events. Once you receive the code2 value, create an array that contains both records you want in elasticsearch and then use a split filter to convert it to two events. You may then need to move fields to the top level.

Note, you will need a task_id on the events to combine them. That can be a constant.

mutate { add_field => { "myTaskId" => "1" } }

If it is literally always name/code1/code2 you could do something like example 1 in the documentation. map_action would be create for 'name', update for 'code1' and 'code2', and end_of_task would be set for 'code2'.

Alternatively, use something like example 3, where you set push_map_as_event_on_timeout to true.