I've had to disable Spotlight on some datasets to prevent Spotlight from apparently failing during indexing, causing it to stop returning all file related results (only extra search results from the web, dictionary etc. are shown). But this isn't a good long term option as some of my datasets really need to be searchable.
What seems to be happening is that Spotlight is indexing the dataset(s), but right at the end it discards the dataset's .Spotlight-V100 database and starts again, this can be seen by the presence of a bunch of files being moved to .Spotlight-V100/Store-V2/DeadFiles which seems to contain the old database as it's being deleted and a new one created.
I've already tried the usual Spotlight steps of running:
- Code: Select all
mdutil -i off /path/to/dataset
mdutil -X /path/to/dataset
mdutil -i on /path/to/dataset
After the second command I tend to verify that the .Spotlight-V100 folder has been fully deleted using a suitable rm command (as always with rm, take care to ensure it's only deleting what it needs to, I like to use ls first, then change to rm once I'm happy it's correct). I do this because mdutil -X doesn't seem to delete the entire folder structure, but I usually prefer to force Spotlight to recreate the whole thing fresh to eliminate any possible permissions issues or whatever.
However this doesn't fix the problem, Spotlight just indexes to what appears to be completion and then decides to throw away all of its work and start again, after several rounds of this the Spotlight server will go "offline" and Spotlight will stop returning any results at all (mdutil -as will show all volumes as "no index" or "spotlight server disabled") until it eventually restarts and the problems starts all over.
I never had any problems like this under Catalina, so it seems that Apple has somehow made Spotlight a lot less resilient in one of the newer macOS versions. Has anyone else experienced anything like this, and have you discovered any ways to fix it? Spotlight is an area of macOS that I have no experience debugging – I haven't been able to find any logs to point to any kind of obvious cause, or indicate an actual crash that I could look into.