How Do I Reset My Spotlight Database?

| MGG Answers

Question:

Scott writes: For some time now I’ve been trying to figure out why Spotlight won’t find messages based on a few key words within the message body of an email.

For example, say I had an email from my friend and they had put the words “Dinner at 8pm” in the message body. When I search for that exact text Spotlight finds nothing even though I know the message is there. I’ve checked and I definitely have “Mail Messages” selected in my Spotlight System Preference pane.

What can I do?

Answer:

Well, this is interesting, Scott. Just to test that this should work, I pulled up a Spotlight search for “Dinner at 8pm” and your message came to the top of the list! So it should work.

That said, it sounds like one of two things is happening: either your Mail data folder is being excluded from Spotlight, or the Spotlight cache needs to be rebuilt.

First, go to System Preferences > Spotlight > Privacy and ensure that your [home]/Library/Mail folder isn’t somehow being excluded (it could be the folder itself or anything that contains it, including [home] or your entire hard drive). If it is being excluded, remove it from the list (and know that Spotlight will now re-index and return results from it.

Check Your Spotlight Privacy Settings

If that doesn’t do it, your next step is to rebuild your Spotlight database. Onyx will do this (and while you’re at it, rebuild Mail’s Envelope Index, too), or you can do it from the command line with:

sudo mdutil -E /

Make sure you type the command exactly as it is above. You’ll be asked for your password. Please enter it, and then the process should begin. If you’re curious, this command means:

  • sudo: execute as a privileged/root user (this is why you need to type your password)
  • mdutil: the command-line utility that manages the Spotlight database
  • -E: erase the Spotlight database from whatever path I specify next
  • /: The “/” means your “main” hard drive (or the root of the current drive, which on the Mac is always going to be your current boot drive)

Hopefully that helps!

This question was originally answered on MGG 283: iPhoto, Spotlight, Swap, and More!

About MGG Answers:

Each week Dave Hamilton and John F. Braun provide some great troubleshooting advice to listeners of the Mac Geek Gab podcast. Here with MGG Answers we share some of those tips with the rest of the world!

Sign Up for the Newsletter

Join the TMO Express Daily Newsletter to get the latest Mac headlines in your e-mail every weekday.

Comments

vasic

Some say that you could also wipe out your spotlight index database by putting your entire ‘Macintosh HD’ into the exclusion list. You restart the Mac, then remove the disk from the exclusion list and let Spotlight re-index the whole thing.

I would also let the Mac run until indexing is complete (the little white dot in the spotlight magnifying glass goes away).

Log-in to comment