Spotlight search can't find anything? Rebuild Spotlight Index - Using Hard Methods

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.

Spotlight search doesn't find anything? You can rebuild the Spotlight index using the macOS Terminal. Here are the step-by-step instructions!

Spotlight search doesn't find anything? You can rebuild the Spotlight index using the macOS Terminal. Here are the step-by-step instructions!

Spotlight search doesn't find anything

Now I have already used the "normal" way several times, with which you get Spotlight to recreate the index: You go over that Apple menu ( in the menu bar) into the System Settings, there too  Spotlight, choose the tab Privacy Policy and there briefly adds the startup disk (in my case "Macintosh HD") and deletes it again immediately. The indexing starts again. You can also find these instructions and options for automating the process in this post: mdworker process slows down Mac - helps rebuild Spotlight index.

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.

Rebuild Spotlight Index (Easy Ways)

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.

Delete and recreate Spotlight index (more extensive way)

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:

cd /

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. 

Last option: completely reinstall macOS

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 :)

-
 

18 comments

  1. Manfred Weil says:

    Hallo,
    I have the process sudo fs_usage -f filesys mds mdworker32 | grep open <and it's been running for 48 hours. (MBPro 15 "mid 2012, i7 2,6Ghz, High Sierra 10.13.6).
    I have the terminal open.
    How can I tell that the process is complete?
    If I now want to close the terminal, does the message appear that I will then abort the process?
    But I think that after 48 hours my hard drive (1 TB SSD occupied by 650 GB) was completely re-indexed, in any case the search in Mail works again.
    Would be nice to get an answer.

    PS:
    however, the mds and mdworker processes used very little processor power.
    In the past, however, it was sometimes quite a load and the temp went up and the fans started.

    Thanks for the hint.

    Kind regards Manfred

    • sir appleot says:

      Hello Manfred! I'm not the king of terminals, but actually the mdworker process starts by itself when Spotlight tries to index. Presumably it always runs in the background and only needs more resources every now and then. I had that for a while, too the "mdworker" process really slowed my MacBook Pro. Behind the link is the corresponding article. ;-) But that hasn't happened since Mojave and my new MacBook Pro 2017. Either the new hardware pays off or Mojave has it better under control with the mds and mdworker.

      To your questions: If you close the terminal window, only the process that has been triggered will be stopped. In the background there is certainly still an independent process from macOS itself. I just checked the "Activity Monitor" tool and there were several at work, but all of them without any noteworthy CPU load ... all at 0% load.

  2. Michael says:

    I tried the "more extensive way", but unfortunately I get the message "no such file or directory" on the command cd /. Am I doing something wrong?

  3. Michael says:

    Second attempt with the more extensive route: The individual steps in the terminal went very quickly (in what felt like a hundredth of a second). And after a few minutes of waiting, the search in Mail actually works again. Thank you for the solution!

  4. Stephen Weiss says:

    Hello Sir! I have a strange question. Windows 10 is installed on my Mac with Parallels, which works like a normal system, i.e. fast, stable and without problems for a long time. I also have a PC, hardware parameters like Mac and the Windows works like a Windows, ie with a lot of annoying problems and much slower, unstable. When it comes to updates, I only have problems with the PC, although everything has been done to be a little better. I did a lot of research but couldn't find an answer for this huge difference. For example: a cumulative update for Mac 70 sec. , at the same time on PC for more than 12 minutes. Do you have an explanation? Thanks. Stefan Weiss

    • sir appleot says:

      Hello Stefan! Well, I would say the Mac is just better! : D But not, that might be too easy. I don't know the hardware features of the Mac and PC, but it could be that the Mac has a Fusion Drive, which dramatically speeds up the hard drive. If the PC doesn't have something like that (SSD), then this point alone could make a big difference. But the funny thing is that we had the same experience. I also had a "real" PC once and it always caused problems. Since my Windows started running on the Mac, there has hardly been any trouble. I assume that this is also due to the fact that the hardware components are known on the Mac and Parallels Desktop knows so "exactly" which drivers etc. are needed. But I can't say for sure either. VG! Jens

  5. Andrea says:

    Dear Sir Apfelot,

    I think my Mac also suffers from the phenomenon described.
    So I've just tried to go the more extensive way (after the first command actually didn't change anything) - but this command probably won't get through because the Mac says: Operation not permitted while System Integrity Protection is engaged

    What do I do now please ???

    Thank you very much for your help!
    Best Regards
    Andrea

    • sir appleot says:

      Hello Andrea! This is due to the SIP of macOS. You can turn this off by starting the Mac in recovery mode (hold down CMD + R when restarting). Then go to Terminal in the Utilities menu and enter this command: csrutil disable
      Then the Mac has to be restarted and now SIP should be switched off. If you want to turn it on again, you can do this with the command csrutil enable
      I would recommend not leaving it turned off permanently as it is some degree of protection against malware.

  6. Andreas says:

    Hello Sire,
    Initial problem:
    Neither in mail nor in the Finder could I reliably find all files by name or mails by subject when I searched for. (Presumably that was much more dramatic with the content, but I didn't actively observe that, I noticed more in the background that it didn't work well either) All right, I was with the command "sudo fs_usage -f filesys mds mdworker mdworker32 | grep open "in Terminal and followed what's going on via the activity display: Started at 09:20. At the beginning high utilization with mds_stores, the lines were added quickly until 12:25. Since then, nothing has been going on, mds_stores no longer needs any CPU time, statistics tell me, 3:33:50 CPU time was used by mds-Stores. Now the activity meter tells me that 95% is inactive. I started Filemaker briefly to see if the terminal notices it - it does. but everything seems to be in place with the indexing. If I go to the Finder, it now finds 0 files, even if they exist and can be seen.

    WHAT CAN I DO? Before I get into out-of-round emotions, I very much hope for a relieving hint!
    Thanks in advance
    Andreas

    • sir appleot says:

      Hi Andreas! Have you ever tried to copy the startup volume 1: 1 to an external hard drive with Carbon Copy Cloner or Super Duper and then re-create the index there when you start from the external hard drive? That ultimately helped me. I think some file was corrupted and made indexing unusable over and over again. Cloning the hard drive then probably skipped this file and allowed the Mac to index normally again.

  7. Andreas says:

    Hi Jens,

    I've arranged for a new hard drive to come and then I'll try. Until then, I'll keep my hope up.
    If I got it right:
    1. Copy to the new external disk with CarbonCopy.
    2. Boot from the external disk
    3. Create an index - via System Settings -> Spotlight, the standard method, or again via Terminal?
    I hope the hard drive will be delivered soon, under current conditions a bit more difficult than usual to get it.
    In any case, thank you that I am not yet deprived of all hope with your advice.

    • sir appleot says:

      Hi Andreas! Yeah, just like you wrote. If Spotlight runs clean on the external hard drive again, you can empty the internal hard drive and clone everything from the external to the internal with CarbonCopyCloner. In the future you will start again from the internal disk.

      • Andreas says:

        Hello Jens,
        I copied to the external drive and I managed to start the computer from the external drive.
        I went to the System Settings -> Spotlight, moved the entire external hard disk into it in privacy, closed the system settings, waited a little, opened it again, removed the external hard disk from the list and made the system settings again.
        now I have to wait, because until now spotlight is still finding as much as before, namely nothing. in the terminal you don't see anything going on either.
        Am I still on the right track? Do i just need patience? Until tomorrow?
        I hope so
        with good wishes for a nice evening
        Andreas

        • sir appleot says:

          Hi Andreas! So basically you did everything right. The complete indexing may take a few hours, but I got results from Apple Mail after a few seconds. Or, for example, it should also find programs directly. If it doesn't, we haven't resolved the problem yet. But right now I don't know what else we could do. Maybe create a new user and see if Spotlight runs properly under this user?

Leave a Comment

Your e-mail address will not be published. Required fields are marked with * .