It indexes as a background job, even (especially) during sleep.
The indexer eats quite a bit of battery in the process -- it's not a bad idea to leave it plugged in overnight to index. I believe the indexer runs faster when charging, probably because it knows it can safely use a lot more power without running down the battery while you are trying to read.