Make Mac Work:

Helping Manage The Macintosh Enterprise

CreativeTechs

Repair Spotlight Indexing

You’re looking for an email invitation you sent months ago, but the option to search through each “Entire Message” in Mail is grayed out entirely. Instead, you search iCal for the appointment itself, only to find the results are empty. Thinking you have the minutes stored somewhere on your hard drive, you try searching in the Finder but discover that even items displayed in open windows can’t be located. Spotlight indexing has broken on your local machine.

Leopard brought a number of improvements to Spotlight, the OS X search mechanism, including system-wide integration with the Finder and native applications. This is accomplished with an indexing process, mdworker, that runs in the background at all times organizing file metadata. While this feature has proven to be quite powerful, it’s also proved quite troublesome, as issues that would previously effect only Spotlight can now disable the ability to search the content of email messages and calendars as well.

When Spotlight attempts to scan a corrupt file, it can stall or crash, failing to properly index your disks and (as a result) disabling the search functionality in other Apple applications. To figure out what Spotlight’s choking on, you’ll first need it to stop indexing entirely. Make sure you’ve quit out of all your effected applications, then open the Terminal and type:

sudo mdutil -i off /Volumes/*

Once the Spotlight process is disabled, remove the old index files Spotlight built of your existing file system, replacing DISKNAME for the name of each mounted volume:

sudo rm -r /Volumes/DISKNAME/.Spotlight-V100

Next, open the Console application in the Utilities folder. View “All Messages” in the left hand column, and use the “Filter” field in the top right to search for “mdworker” (the behind-the-scenes process that indexes data for Spotlight). If the remaining errors end in file names, you’ve found a likely source for your Spotlight woes.

Make sure these corrupt files are safe to move (and not within Application bundles or required by the OS), then relocate them to a removable drive or erase them entirely. With your suspect files out of the way, you can restart Spotlight indexing:

sudo mdutil -E -i on /Volumes/*

Once the indexing is complete, check the Console logs again to make sure the errors haven’t repeated. You can now reopen your applications, and the ability to search messages and appointments should be restored.