How to Fix Spotlight Indexing in OS X

| How-To

Spotlight – Apple's system-wide search engine – was introduced way back in 2005 when OS X 10.4 Tiger was unleashed. Our favorite search tool has improved markedly over the past eight years, and it seems to improve with every iteration of OS X. It's even integrated within iOS.

In spite of Spotlight's nimble and highly reliable nature, there can be a number of reasons for causing a raise of one or more eyebrows. You might discover that there are some files and folders that Spotlight can't – or won't – find at all. For example, it will only find the ones you have permission to view and access.

Spotlight also ignores files in the trash, the ones inside zipped archives and disk image (.dmg) files. Time Machine backups are ignored, as are certain System files. There may also be files and folders that you do not want Spotlight to search. Finally, on rare occasions, Spotlight may run into trouble and simply stop producing results.

Let's gain a better understanding of Spotlight and learn how to apply a fix if it ever misbehaves.

First things first. Why don't we all get on the same page and understand that Spotlight is designed to let us find all kinds of files, pictures, music, apps, folders, and more on our Macs, and find all these at lightning speeds. Not only can Spotlight find what you're looking for based on searching file names, but also based on the contents of documents and any metadata (information about the data) associated with the files.

Examples of metadata include date created, file size, tags, Finder comments, camera EXIF data, author and copyright information, and tons more. When you consider the sheer number of files found on a typical Mac, it's... well, it boggles the mind.

The reason that Spotlight works so efficiently – and so fast – is that it creates a special database called the Spotlight Index. Think of it this way: Spotlight keeps track of (it "indexes") every single word within the body of your documents as well as the file names and metadata. Each time you create, edit and save your file, Spotlight is indexing its contents and metadata. By doing so, when you later search for a word or expression, Spotlight consults the index and instantly begin returning results to you, listing the files that contain your search query.

The Spotlight search bar expands to display the search results.

Doing a Spotlight search on my mentor and confessor produces quite a few "hits"

As with any computer file or database, there could be a number of reasons that some sort of file corruption or other problem will cause Spotlight to malfunction, resulting in it not finding what you ask. Spotlight may not be able to read and/or update the index.

For example, you could do a search for some very specific text in a document that you are certain is present on the drive. Yet, you notice that Spotlight is unable to find it. You even locate the file manually to verify its existence – and that of the specific text contents. Unless you explicitly exclude the file from being searched, it's clear that Spotlight's index is damaged and needs fixing.

The solution is to rebuild the Spotlight index, and this can be done quite easily. You start by accessing Spotlight's Preferences panel, via  > System Preferences > Spotlight. Then, click on the Privacy tab at the top of the panel.

The Privacy panel in Spotlight Preferences.

The Privacy panel in Spotlight Preferences is where you tell Spotlight to exclude folders and drives/volumes from indexing

Let's pause and take a look at Spotlight's Privacy panel. It's very handy because it allows you to easily exclude any folder – or an entire storage volume/drive – from being indexed. You know, everyone's got at least one folder they don't want others to perform searches on. A more likely example though, would be this: if you make clone backups of your main drive, you would generally want to exclude the clone from being indexed by Spotlight. This will preclude search results listing files on the clone. If you were to access the files on the clone drive, you would stand a pretty good chance of unintended file editing or deletion, version skew and an overall bad day at the computer.

You'll notice a little instruction blurb at the top of the Spotlight Privacy panel that succinctly tells you what you need to do to exclude items from being indexed. You click the familiar add (+) button at the bottom, then select the file, folder or entire volume/drive when prompted. Alternatively, you can simply drag-and-drop folder and drive icons directly onto the list to exclude them from indexing.

The Mac's hard drive icon being dragged from from the desktop and dropped into the Spotlight Exclude list.

Drag-and-Dropping a disk or folder into the Spotlight Exclude list is one way to to add items

OK, so you know how to add items to the exclusion list. Good. So, what about fixing a corrupted index?

Here's the technique for re-indexing an entire drive (the same can be done to just re-index individual folders). First, you must add your drive to the list using the method explained above – the add (+) button or the drag-and-drop method.

As already explained, this action tells the system to exclude the drive from Spotlight indexing. More importantly, it also deletes any existing index. If prompted for confirmation, click OK. By the way, you can only add folders or volumes that you have ownership permissions for to the Privacy list.

Spotlight's alert dialog asking if you are sure you want to prevent Spotlight from searching the hard drive you are adding to the Spotlight Exclude list.

This appears as a result of dragging my hard disk icon onto the Spotlight Exclude list

Here's the critical step: remove the volume you just added to the list by selecting it and clicking the minus (–) button at the bottom. Finally, close Spotlight Preferences.

Spotlight now proceeds to re-index the contents of the volume; this occurs in the background. Depending on how much data is on the drive, this can take a considerable amount of time – hours, in fact. However, you can continue to work with only a slight performance hit due to disk activity.

By the way, Spotlight will automatically re-index when you perform major OS X upgrades (for example, when going from Snow Leopard to Mountain Lion), when you reinstall OS X from scratch, and when you do a full-drive recovery from Time Machine.

I love that dot!

I know... you're asking, "What dot?" There is a tell-tale indication that Spotlight is actively indexing. A teeny-tiny dot, only a couple of molecules across, pulsates right in the center of the Spotlight's magnifying glass on the right side of the Mac's menu bar.

I love that dot! It makes me happy. It tells me that Spotlight is chugging along just fine. Only thing is, starting in Mountain Lion, I noticed that this dot only appears initially, while determining which files need indexing. The dot used to appear during the entire indexing process. I want that dot back full-time!

An enlarged menu bar Spotlight icon showing the indexing dot in the center of the magnifying glass.

The pulsating dot in the center of Spotlight's menu bar icon indicates active indexing

During active indexing, Spotlight disables searching. If you try clicking the magnifying glass to attempt a search, you will instead see an indexing status message with a progress bar.

The Spotlight indexing progress dialog.

The Spotlight indexing status dialog gives you a progress report on the indexing activity

Spotlight is a key feature in OS X. Understand how it works and how to maintain it, and Spotlight will return the love.

Sign Up for the Newsletter

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

4 Comments

dmarcoot

I find on my 2012 MB Pro with 8 GM of RAM that ” you can continue to work with only a slight performance hit due to disk activity.”  is simply not true.

In fact almost nothing slows my mac down more than with Spotlight starts indexing.

I was hoping for some insight on how to force spotlight to only index after machine has been idle for some period of time.

Placing my HD into the privacy tab is not a solution.

RandNotAyn

It’s the solution…not a great one.

I’d like Spotlight to re-index every night at 1 am… appleScript?

Hummingsong

I also find that Indexing hugely slows the performance of my (relatively new and high specced) MacBook Pro. You can turn it off in terminal but then it has to reindex when you turn it back on, so you’re hardly saving yourself time. I agree that ideally you’d want to be able to have it index only during certain hours, or when idle, or have a pause button on the process; but I can’t see this can be done without a change in OSX so it’s probably best to send requests to Apple themselves!

If I’m wrong, please Tweet me!

Ca RiVa

Thank you! After migrating from my old Macbook to a Macbook air, spotlight didn’t find many of my files. I did what you recommended and it fixed everything!

Log-in to comment