Need help in creating one single query which returns list and also does processing when no document found

Hi,

switchIfEmpty takes an object, not a function, so you can put dsBucket.async().get(retryGetWithNewKey(id)) directly.
and yes they are all inside the flatMap as you need to keep a reference to the id.