Recently, I tried doing a search of my Gmail respository from OS X Mail. I got almost no results. Gmail, by contrast, returned hundreds of hits.
It wasn't hard to figure out the cause of this discrepancy. The default mail.app IMAP setup doesn't actually store messages locally. It only creates a local store for messages that have been read locally, and only those may be indexed by Spotlight.
To create a searchable IMAP repository, you need to change an advanced setting ...
Mail.app Proper Set up on MaxOSX for IMAPI had to restart Mail.app to activate this setting. Then I let it run overnight, pulling in and indexing 45K messages. My Spotlight searches now work against this email archive.
... Next go to Advanced, and the defaults for Enable this Account [checked], Include when automatically checking for new mail [checked], Compact mailboxes automtically [checked and greyed out], the location of the account directory, and Keep Copies of Messages for Offline Viewing [drop down menu with All messages and their attachments selected] should be fine...
There's still a problem with Mail.app search of Gmail files -- the Gmail tag/IMAP folder mapping means messages may be replicated between folders. (Because a Gmail message may have many tags, but an IMAP message can belong to only one folder.)