score:7
Presumably you're flying on Air Baltic. Here's what they say on their website:
Security check and passport control. If you are travelling from:
Schengen to Schengen country - you do not need to go through a security check and passport control.
Schengen to Non-Schengen country - you have to go through passport control.
Non-Schengen to Schengen country - you have to go through a security check and passport control.
Non-Schengen to Non-Schengen country - you have to go through a security check.
Germany is a Schengen country and Ukraine is not. So on the way there, you'll have to go through passport control but not security; and on the way back, you'll have to go through both security and passport control.
Upvote:3
To leave the transit area anywhere you need to have the paperwork to enter the country
Once you left you need to go through security at least again. Border control is possible too.
Latvia is in the Schengen area so you can leave the airport and there will be no passport checks.
Before boarding a non-Schengen flight, you need to go through a passport control (exit check).
Take care of how you route yourself in the airport: you might face some problems if you go through the passport control leaving Schengen and then decide to leave the airport -- this requires another passport control to enter Schengen and possibly some scrunity of WTF are you doing.