The schematic shown above is the most conservative, letting the generator to take over whenever there is a slightest sign of life from that generator. As the system performed reliably, I decided, eventually, to tip the balance more towards the batteries. The particular values would, generally, depend on the relay and on the taste, and should be experimented with. In my case, the batteries now take over when the light driven by a generator gets quite dim. Without the diodes, you will fry the delicate relay poles in no time.
Capacitors are useless for the purpose.
Finding a right charging adapter turned out to be quite tricky. Do not count on the different relay poles to fire simultaneousely. Solar cells can deliver a respectable charging current in bright sun. However, the current becomes abysmal under cloudy winter skies. Standard battery holders are not practical on a bicycle.