Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Since upgrading to Lion, my search in Mail has gotten drastically less helpful. Since I have read many reviews about what an improvement Mail 5.0's search is, I can only assume that my search index was not built correctly. Is there a file I can delete or a terminal command I can run to tell Mail to re-index my messages?

share|improve this question
    
Is the search slow? The improvements are more along the lines of filtering with what Apple calls "tokens". –  Nate Bird Jul 27 '11 at 18:48
    
No, I searched something that I knew without a doubt existed, and it never showed up. It just plain 'ol didn't find it. –  finiteloop Jul 28 '11 at 15:53

2 Answers 2

up vote 4 down vote accepted

Mail keeps a sqlite database of the index. To rebuild it, delete the index and restart Mail.

rm -f ~/Library/Mail/V2/MailData/Envelope\ Index
share|improve this answer
    
Mail is re-importing all of my messages as we speak. I have a feeling this is going to be the fix. When I first launched Mail 5.0 I had an incompatible plugin installed and I think Mail's warning me of that caused the importing of mailboxes to stop short. –  finiteloop Jul 28 '11 at 15:57
    
Note: running this command will wipe out your local cache of mail messages and require Mail.app to re-download everything. If all you want to do is rebuild your search index, see the mdutil command provided by aaltonen –  emmby Jul 5 '12 at 19:11

Here's what I've used in the past to rebuild the search index:

sudo mdutil -E /

The -E option "will cause each local store for the volumes indicated to be erased. The stores will be rebuilt if appropriate."

While I don't use Mail.app, I noticed similar behavior with Outlook 2011 -- which also uses Spotlight for search.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.