How to optimize a Solr index from Sunspot

Posted: July 17, 2010. Tags: Solr, SunSpot

It doesn't look like SunSpot has a builtin optimize command.
Here's one way you can do it:

Sunspot.session.session.send(:connection).update RSolr::Message::Generator.new.build { |b| b.optimize }

Anyone know of a simpler one?