For some reason macOS reindexes a file if it was read or opened by another program, so cache dirs are heavy offenders. Can be checked with sudo fs_usage mdworker mds
A list to start with, you can add these paths by going to System Preferences
then Spotlight and finally Privacy, clicking the +
and then doing cmd+shift+g or programatically (see below).
My current list contains the following
sudo defaults read /System/Volumes/Data/.Spotlight-V100/VolumeConfiguration.plist Exclusions
NB: Change the /Users/yt
to reflect your OWN user.
(
"/Applications/Slack.app/Contents",
"/Library/Application Support/com.eset.remoteadministrator.agent",
"/Library/Application Support/org.pqrs",
"/Users/yt/Library/Application Support/Code/",
"/Users/yt/Library/Application Support/Google",
"/Users/yt/Library/Application Support/Slack",
"/Users/yt/Library/Containers/com.apple.Safari/Data/Library/Caches",
"/private/var/log",
"/private/var/logs"
)
Adding a new one is done by
sudo defaults write /System/Volumes/Data/.Spotlight-V100/VolumeConfiguration.plist Exclusions -array-add '/Users/yt/Library/Application\ Support/Code/'
and then you have to restart MDS: sudo launchctl stop com.apple.metadata.mds && sudo launchctl start com.apple.metadata.mds