MacOS – Spotlight doesn’t show applications

macbook promacosmojavespotlight

Setup

I've got a MacBook Air (13-inch, 2017)

Problem

When I type in the name of an application, Spotlight doesn't show the application. When I do sudo mdutil -E /, It says the following,

Error: unknown indexing state.

When I Select System Preferences, Click the Spotlight pane, select the Privacy tab and then click the Add (+) button and try to select anything, It says

Privacy List Error,
the item couldn’t be added or removed because of an unknown error.

What I tried

I've tried https://www.macrumors.com/how-to/rebuild-spotlight-search-index-on-mac/,
and Spotlight re-indexing takes too long or doesn't work. sudo rm -R .Spotlight-V100/ says

No such file or directory

sudo /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -seed -lint -r -f -v -dump -domain local -domain system -domain user -domain network

does a lot of stuff,

sudo rm -R .Spotlight-V100/ also says

Error: unknown indexing state.

sudo mdutil -E -i on /
says

Error: unable to perform operation. (-400) Error: unknown indexing
state.

How it happened

When I tried to download the macOS Catalina update, the mac got stuck in an endless loop of trying to update and then failing, forcing it into recovery mode, I tried to stop the update by using this link, https://www.mklibrary.com/technology/macos-sierra-stuck-endless-rebooting-loop/ but nothing worked, so I had to fully reinstall macOS, Spotlight now doesn't show any files or applications at all. It only shows other stuff like emails, Dictionary suggestions, etc.

(Note, I've also made sure to check all the categories in system preferences)

I've tried,

sudo mdutil -a -i off,

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist'''

sudo mdutil -a -i on

It worked, however, it stopped working again afterwards when my computer shut down.

Best Answer

With all the deleting of files that spotlight depends on, I would write off that system entirely. Make a good backup - maybe two if you use Time Machine which may not have a good backup due to spotlight and the filesystem likely being suspect or corrupted.

Erase the entire volume and then test spotlight on a clean install. Once you are convinced the hardware is working with none of your old data or system present, you can erase again and migrate back your data or run Migration Assistant and/or migrate back by hand.

In the future, when you suspect a spotlight issue - I would run mddiagnose which dumps all the log files and data needed to determine the state, error, conditions of the spotlight / mds / metadata collection and indexing subsystems as well as system logs that can help show issues.

In most cases where we see this, it's corrupt data (bad spotlight importer crashing) as the system crawls all the data that causes things, so restarting that process doesn't fix the underlying issue. With all you've done, it's going to be very hard to find out the case but you could try working with Apple Support on a mddiagnose analysis or take a stab at reviewing it yourself.