Not sure what indexed shifters are, but assuming it was your front gear (the one with the pedals), here's a method that works for me:
- While riding, as soon as you realize the chain came off, stop pedaling.
- Stop riding and dismount.
- Shift the gears of the bike all the way opposite of the side the chain fell off. So if the chain fell to the right, you want the derailleur all the way to the left, and vice versa
- Lift the back wheel of the bike off the ground. Some bikes have a kickstand in a location that allows the bike to be leaned rather than lifted, which is easier.
- Start pedaling the bike with your hands.
The chain should go back onto the gears on its own, but it might slip a few times.
Naturally, if it feels wrong or the chain feels like its under a lot of stress, stop. It's better to get your hands dirty than to break a chain.