So we just recently got an iMac at home. After setting it all up, I was coonfused and disappointed that Spotlight (OS X’s new “search your whole computer” tool) was not finding keywords from most of my e-mails. It would find one or two e-mails from keywords that should have found dozens.
What the heck?
It took me a while to figure this out. I found help from the handy mdutil, mdfind, and mdimport man pages. The crux of the issue: Spotlight automatically ignored entire directory trees that have names that begin with a period (“.”). Doh!
Let me explain…
On my mail server, all the folders under my INBOX are stored in $HOME/.elm/Mail (only the crustier Unix folks reading this mail will recognize how old that is — I stopped using elm many years ago, but have always left my folders down there and directed my mail client to look there for them. It was just easier). True to form, I put in “.elm/Mail” in my IMAP directory setup on the OS X Mail client. OS X dutifully found all my folders, and everything was fine.
However, unbeknownst to me, OS X Mail was caching my e-mails locally in a directory called “.elm/Mail/…”. This makes perfect sense from OS X Mail’s point of view (allowing potentially multiple different prefixes from a single IMAP server), but it caught me by surprise. Additionally, since Spotlight ignored the entire “.elm” tree, it didn’t index any of the mails below my INBOX.
Problem solved by renaming .elm to something else on my mail server (something that does not being with “.”). I’ve finally been dragged into the 21st century.