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 I installed Lion, the Spotlight database keeps reindexing (which is taking several hours). It does this at least every second day.

Are any other users experiencing this problem with Lion (i.e. is it just a 10.7.0 bug)? If not, how can I diagnose what is causing it - I see no suspicious entries in Console?

Just being able to reset the spotlight history and have it rebuild would be nice to know.

share|improve this question
4  
See: superuser.com/questions/46195/… which shows a technique to figure out which file is failing on indexing. –  Andrew Vit Nov 22 '11 at 7:18

7 Answers 7

I, too, had the reindexing problem happening after I upgraded to Lion. However the problem didn't exist for every user, just for the one that was using FileVault 1.

After a few weeks I got overfrustrated and ran… †

$ sudo mdutil -a -i off

… in Terminal — and the same minute I realised that the setting was applied system–wide. I shrugged and enjoyed a few hours worth of reindexing–free session after which I decided to turn Spotlight back on, as it is crucial to my workflow on other user accounts; so:

$ sudo mdutil -a -i on

And while I was at it, I decided to erase the old index and rebuild new from scratch with:

$ sudo mdutil -aE

I did this about a month ago and I haven't encountered "useless" reindexing since. I'm happily surprised because fixing the issue was merely a coincidence.

So, have you tried turning it off and on again?


†) the -a flag will apply the action to all volumes which might not be something you want — and actually wasn't what I wanted either, but I just wanted to go blitzkrieg on the issue.

share|improve this answer
    
To note on the bounty: I'm on iMac with no SSD, sorry, but it might fix the problem regardless. –  koiyu Nov 22 '11 at 9:48
3  
This was what I was going to suggest. For the really paranoid, delete the existing index manually using sudo rm -rfv /.Spotlight-V100 –  TJ Luoma Nov 26 '11 at 8:36
    
So strange. I just upgraded to Lion on Friday and Spotlight died. Tried mdutil to no avail yesterday and then tried this again today and voila! Re-indexing. Strange... –  Valien Feb 7 '12 at 14:06
up vote 9 down vote accepted

I figured this out. One of the spotlight plugins was causing errors, which closer scrutiny of the Console log revealed.

I found out which app was causing the problem by looking in

/Library/Logs/DiagnosticReports

There I found several crash reports from mdworker (the backend to Spotlight). All crashes were caused by the same app plugin. I have now deleted that plugin from my system.

share|improve this answer
    
But which plugin was it in your case? –  Jason Salaz Nov 22 '11 at 8:21
2  
Mathematica (an earlier version - current version is fine). –  dan8394 Nov 22 '11 at 8:39

New theory: my system drive keeps running low on space — sometimes down to only a few hundred MB free. When the OS detects this situation, it deletes the Spotlight indices. When I free up space again, it has to rebuild the indices.

share|improve this answer
    
I've been experiencing this as well. I don't know if the same happened in 10.6 though because I switched to an SSD and Lion at the same time. –  ؘؘؘ Dec 21 '11 at 23:19
    
I'm experiencing the issue with low space as well, and I think it already happened on Snow Leopard (10.6). The problem is that Lion deletes the index (to keep space from running out, I guess), but the second it is deleted, it starts getting recreated, which at the end causes the same problem again and again (instead of turning Spotlight Off temporarily until you solve the low space situation). –  Ricardo Sánchez-Sáez Jan 16 '12 at 14:08

@koiyu, @TJ Luoma - It was a combination of both of your answers that got my Late 2010 MacBook Air (SSD) from overheating and crashing nightly.

I combined your answers in a script that I called mdutil_rebuild.sh. Save it as 'whatever_name_you_like.sh' and run it from the terminal with sh whatever_name_you_like.sh. Fyi - for me it takes about 7 hours to rebuild my ~130GB index on my machine. Might be worth doing it overnight if you're going to need all your processor for anything.

#!/bin/sh

#  Force rebuild the spotlight index from scratch.
#    Compiled on 12-14-2012 in response to runaway 
#    reindexing processes from answers by @koiyu
#    and @TJ Luoma.
#
#  Ask Different Question: http://bit.ly/SYTE1j 

# Turn off spotlight.
  sudo mdutil -a -i off

# Remove the index files.
  sudo rm -rfv /.Spotlight-V100

# Turn on spotlight.
  sudo mdutil -a -i on

# Reindex all mounted /Volumes
  sudo mdutil -aE
share|improve this answer

Two things I discovered while investigating this same issue:

32-bit Spotlight Importers

These seem to be one of the reasons mds and mdworker (the system processes behind Spotlight) were tripping up and failing to complete the index. (And might explain the mysterious "Unable to talk to lsboxd" messages.) Since mds and mdworker are 64-bit processes, it probably couldn't work with the older 32-bit Spotlight Importers (I found three on my system).

To find out if you have any, use Terminal.app and enter this command: mdimport -L

That'll give you a list of paths where you can find each of the Spotlight Importers (some are embedded in third-party applications). Use the Finder "Go to Folder..." command to open the enclosing folder of each Spotlight Importer. In the Finder, "Get Info" on each to see if it says "(32-bit)". I moved these to the trash and tried the process suggested above and it seemed to work better.

Rebuild Mail.app mailboxes

This was what finally got Spotlight to index email that hadn't been included in previous attempts, even following the processes suggested above and elsewhere. Only after Mail.app rebuild the mailboxes did Spotlight begin to return search results from those locations.

share|improve this answer

Try going to disk utilities, select the hard disk and repair permissions. This worked for me a for a related spotlight problem.

share|improve this answer

Two very simple things to try right off the bat - that often alleviate this kind of Spotlight shenanigans for me.. 

1: First, if you've got root access... sudo killall mds from the terminal.. Which kills the "mds" process.. (meta data searcher??) that'll get you out of whatever kerfluffle X, Y, Or Z plugin, file, or whatnot that made spotlight croak in the first place.. Force quit now, troubleshoot later... That's what my father always said. Just kidding, I'm an orphan..

Or 

2: For a more more pedestrian solution.. Open up spotlight prefs and a: remove any non-indexed "private" items... And b: if you wanna reset the volume index.. I believe you can do so by actually adding your boot drive to that list, closing and re-opening the system prefs and then remove your aforementioned "Macintosh HD" from the privacy list it... This will reindex the drive.. Hopefully with less kvetching, this time. Oy! 

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.