Index only certain directories in Spotlight

Oct 02, '09 07:30:04AM

Contributed by: arcticmac

Since (apparently) later versions of 10.5, Spotlight has a file called VolumeConfig.plist which you can edit to index only certain directories. For example, I wanted to index only my Mail folder and my Documents folder because those don't usually have radical changes, and they're the only places I ever need search (especially Mail). To accomplish this, I first disabled Spotlight indexing on my hard disk:

sudo mdutil -i off /
Then, with root permissions, I opened /.Spotlight-V100/Store-V1/VolumeConfig.plist and edited it. I changed partialPath to Users/myusername/Library/Mail (note the lack of a leading slash), and policySearch to 3.

You can also copy the whole block describing the index (it has a long UUID string for its key, and then the dictionary that goes with it describes partialPath and policySearch), and change the UUID (use uuidgen in Terminal) to add additional paths that you want indexed. When you're done, save changes to the file, then restart mds:
sudo launchctl stop com.apple.metadata.mds
Now that you've set up the new indexes, you should be able to control them using mdutil:
mdutil -sv ~/Library/Mail
Use caution however, as you may undo your work if you run mdutil -i on /.

[robg adds: I haven't tested this one.]

Comments (1)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20090914124459567