Occasionally problems can arise with search results in Spotlight. This is caused by the search index getting corrupt. When searching for something, Spotlight doesn’t search every file on your computer, that would take way to long. What happens instead, is that all the contents on your computer is added to an index, the Spotlight Index. This includes meta tag data, every word inside your documents, emails… and pretty much everything else.
It’s not unheard of for Spotlight to have some issues, and keeping track of the constant ever changing data on your computer has been known to trip it up every now and then. Sometimes when search for something, Spotlight may refuse to acknowledge it’s existence, even if you’re blatantly staring at in on your desktop.
Also, if you’re having issues with it taking a long time, these methods will also speed up Spotlight search.
How to Re-Index using Terminal
Terminal is an application that comes pre-installed on all Macs. You can find it in your Applications/Utilities folder. Open it and enter:
sudo mdutil -E /
Press Enter/Return. Then enter your password if it’s requested. Next enter:
sudo mdutil -i on /
Again press the Enter/Return button.
Since the first code uses the sudo command, you will be required to enter your password. Once you’ve input your password, entered the second code and pressed enter, it may take a minute or two for the re-indexing to start. In my case, it took just over a minute. You can check on its progress by clicking on the spotlight icon (magnifying glass on the upper right hand side of the menu bar).
Also note, that usually re-indexing Spotlight can take a while. In my case it took around 30 minutes, don’t be surprised if yours takes an hour or two.
The terminal method can also be used to re-index specific external drives on your Mac. To do this all you need to do is modify the ending of the above code. I’ll give an example. I have an external drive called AppDucate. To re-index it in Spotlight I’d type in:
sudo mdutil -E /Volumes/AppDucate/
If you have an external drive you want to re-index, just replace the “AppDucate” part with the name of your drive.
How to Re-Index in System Preferences
A somewhat simpler method, is to use System Preferences. Using this method, we’ll tell the Mac to stop indexing the drive, and then change that back to allow indexing. Doing this will cause the Mac create a new index, fixing any issues with the current spotlight index. Do do this:
- Open System Preferences
- Open the Privacy tab
All you need to do is drag the drive that you want to re-index into the window as shown in the screenshot. Another method is to click the “+” button, which will slide down a little navigation window that can be used to select the drive to rescan.
Once your desired drive is located in the window, just click the “-” button. This will remove it from the list, and your Mac will create a new Spotlight Index.
This also works for external drives that aren’t indexing properly. Just drag them into the window, then remove them. To check on the progress just click the spotlight icon (magnifying glass) in the menu bar.
One thing I should mention with this method, when I first tried this I received an error when trying to remove it from the list. The error was, “The item couldn’t be added or removed because of an unknown error”. The fix for this was to simply close and reopen System Preferences. Clicking on the “-” button afterwards did not produce the same error and within less than a minute it started to re-index the drive.