Wednesday, September 23, 2015

Solving Problems with Mac OS Server Spotlight Sharing

We have a Mac server for our advertising department that contains tons of images.  They use spotlight on their Macs to search the shared volumes from the server.  There were a few folders that had somehow become stuck and new files and folders in that stuck folder would not be found when searching.

I connected to the server and found that searching on the actual server worked just fine on the problem folders.  This ruled out any spotlight exclusions for those folders since they should never be found in that case.

I decided to check the index status using mdutil

mdutil -as

Surprisingly it showed the stuck folder as having its own index and that it was working fine.  I tried to figure out how to modify the list of folders that have their own indexes and couldn't find anything about it.  The stuck folder did not have a mount independent of the main volume one, so it should not have been there.

Eventually after much searching I found that at the root of each volume inside the .Spotlight-V100 folder there is a config file that contains the configuration for the volume's indexing called VolumeConfig.plist.  For some reason this config file contained special configuration for my stuck
folder.  So I edited it and took out the offending configuration leaving only the block for the root of the volume using:

sudo vi /Volumes//.Spotlight-V100/Store-V1/VolumeConfig.plist

Once that was gone I restarted the indexing service using

sudo launchctl stop com.apple.metadata.mds

Now new files and folders added inside my stuck folder instantly appeared in the search box on a remote computer.  Existing stuff still didn't show up though so I still needed

sudo mdutil -E /Volumes/

to force it to reindex the volume

Now everything is working great!

My assumption is that at some point this folder was shared as its own volume.  This got the folder in the configuration list so that it had it's own index.  Then the volume was deleted but the index remained for some reason.  It seems that spotlight on the local system is aware of the potential for multiple indexes and searches them all, but remote searching only searches the index at the root of the volume.  Also the index util for some reason doesn't index folders with independent indexes into the root index.

I'm sure there are some bugs here, but this seems to resolve the issue.

Enjoy!!