Chapter in this post:
I have been struggling with my Mac for a few days and it just doesn't search and find properly anymore. This manifests itself on the one hand in the Spotlight search, which I usually use to quickly find and start programs, and on the other hand in my search in Apple Mail. With a good 15 GB of mail data and up to 100 written and read mails a day, a collection quickly grows that can no longer be mastered without a search function. And that is exactly what fails in Mail, because the Spotlight index is also the basis for the mail search in Apple Mail. If you have a similar problem, the following solutions to rebuild the Spotlight Index may help.
Apparently the Mac doesn't throw away the files it is working on, because after a few minutes of Spotlight working, the problem was back on my Apple computer. I then scoured various pages for tips and found a few that I would like to show you below. In the headline I referred to them as “hard methods” - that's because you have to penetrate macOS with the terminal.
There are two single commands that you can use in the terminal of macOS on your Apple Mac, iMac or MacBook to rebuild the Spotlight index. The first is also used to invalidate the mds and mdworker processes and to run normally again by re-indexing the hard disk data, programs and files. After entering the data, there is of course a renewed CPU load, as the machine has to work a lot depending on the amount of data. The command to rebuild the Spotlight index for the terminal is:
sudo mdutil -E /
Another single command line is also responsible for recreating the Spotlight database. However, it also lists the processes and files indexed in the terminal. There may be pauses of one or two minutes here and there - depending on the file and size. If the command hangs completely on a file, you can locate the file and see whether it is damaged, should be deleted or other measures are necessary. The command line for the terminal is:
sudo fs_usage -f filesys mds mdworker mdworker32 | grep open
Important: The indexing process may take a few hours. To do this, you can simply leave the Mac on for a night. In the app Activity indicator you can then see whether it is through. As long as there is a process called mds_stores is high in the CPU usage, the Mac is still dodging to rebuild the Spotlight index.
If the above methods did not solve the problems of the CPU load or the search console that could not find anything or only for a short time, you can use further system commands. These go beyond simply recreating the Spotlight index and therefore require several command lines. You can, however, simply copy these from the list below and paste them into the terminal (cmd + c and cmd + v).
First you have to deactivate the Spotlight daemon, i.e. completely switch off the Spotlight search. To do this, enter the following command in the terminal and confirm with Enter:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
If you are asked for your administrator password, then enter it. If the command is through, Spotlight is finished. In the case of incorrectly running processes, you should be able to directly identify a relieved CPU.
Now it is necessary to access the root directory of the system hard drive in the terminal. To do this, enter the following command followed by Enter:
Once in the root directory, the Spotlight index directory must now be deleted. To delete it, you confirm the following command in the terminal:
sudo rm -rf .Spotlight-V100
Now it's time to re-enable the Spotlight search that was disabled with the above command to rebuild the index. For this you confirm the following, last command line:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
Since the Spotlight index is now being recreated, the procedure takes some time. Depending on the amount of space used on your hard drive, this can take a few hours.
If nothing really works, you could still use the "root user" - according to some advisors and Instructions For the faulty Spotlight search, this is not only time-consuming, it also only fixes the problem temporarily. So if the solutions shown here are of no use for a faulty Spotlight search, the help you are looking for may be in a complete, "clean" reinstallation of macOS. That means, you definitely have to make a backup of your files and then have your hard drive formatted during the reinstallation. Here are a few guides:
Your Spotlight search can't find anything? But the methods shown here to rebuild the Spotlight Index could help you? Then please leave a comment on the topic :)
Jens has been running the blog since 2012. He appears as Sir Apfelot for his readers and helps them with problems of a technical nature. In his free time he drives electric unicycles, takes photos (preferably with his iPhone, of course), climbs around in the Hessian mountains or hikes with the family. His articles deal with Apple products, news from the world of drones or solutions for current bugs.