Spotlight search on network volumes
Before we get on with the particular issue of using Spotlight search on network volumes, let's just say that two different types of search are supported in the Path Finder's Find window. First, we have Spotlight search, as shown in the following picture:
This uses system Spotlight functionality to search for files.
The other type of search is what we call Old style search shown in the following picture:
Now that we know the difference between the two, let's explain why you usually don't see any results if you try to use Spotlight search (the type of search most users use by default) on network volumes. We'll also explain how to make this work and also mention some issues you may expect while using this functionality.
In order to be searched with the Spotlight technology, a disk volume must be indexed, that is Spotlight must first create the Spotlight query database for that volume. After this database is initially created, it's constantly being updated as the volume contents changes (e.g. files are created and deleted, their attributes are changed and so on). With the system volume (the one the OS X is installed on), this database is initially created right after installation of the operating system. For other volumes (both internal and external), index database is created the first time the volume is mounted. You can confirm this process is going on by clicking the Spotlight icon in the menubar. You will see something like in the following picture:
This shows the progress of indexing an external volume connected to the USB port.
Once indexing of a volume is finished, you can use Spotlight search to search for files/folders on that volume.
However, Spotlight will automatically only index volumes physically attached to the machine (internal drives and drives physically connected via USB/Firewire/Thunderbolt ports). It does NOT index network volumes! That actually means you CANNOT use Spotlight search to search for files on network volumes. Please note that Apple announced a possibility to search network shares in Snow Leopard (OS X 10.6.x), but it particularly stated you would be able to search for files on another Mac which is a network share connected through the AFP protocol. Spotlight would actually use the database created locally on that Mac. But this doesn't mean you can use Spotlight on any arbitrary network volume, as it won't be indexed automatically when mounted for the first time.
The good thing is you can force indexing of network volumes yourself. If you have a network share named e.g. MyShare and it's mounted in the standard path in /Volumes, all you have to do is to type the next line in the terminal:
mdutil -i on /Volumes/MyShare
After you do this, you'll see Spotlight actually indexing the volume, like shown in the next picture:
You can also check if Spotlight is enabled for a particular volume typing in the terminal:
mdutil -s /Volumes/MyShare
and if it is, the outcome will be something like:
/Volumes/MyShare: Indexing enabled.
Note that you need to have write permission for the volume in order to force Spotlight indexing for it
Once the indexing is done, you'll be able to use Spotlight to search for files/folders on it, like you use it for other connected volumes.
And this is all we can be certain about. The rest of the story is just some observations we had using Spotlight search on network volumes. We don't know how exactly all aspects of Spotlight on network volumes really work, as it isn't documented anywhere. Also, many questions regarding this addressed to Apple are left unanswered. So, we'll present here our experience. Yours may vary.
Firstly, you may need to execute mdutil command to force Spotlight indexing every a time network volume is mounted. Our experience with this vary and we can't tell anything for sure. For example, we would mount a network volume for the first time and check whether Spotlight was enabled for it. We got Status: Indexing Disabled, as expected. We would then force Spotlight indexing for the volume and checking the status would give us the expected Status: Indexing Enabled. Every next time we would mount the same volume (after it's been unmounted) we weren't sure what result status checking would return. Sometimes it would say that Spotlight indexing was disables, sometimes that it was enabled. So, the only sure bet is to force Spotlight indexing every time the volume is mounted. Doing it every time manually is tedious, but it can be automated. It's beyond the scope of this article, so you better check out this link. It explains a lot about this same issue and also gives an example how to automatically force Spotlight indexing every time a network volume is mounted using system deamon launchd and a custom shell script.
The other odd thing is that sometimes Spotlight search wouldn't return complete results when executed on a network volume, even though the indexing was enabled and the volume was indexed. For example, there would be 20+ items matching certain search criterium, but Spotlight search would return only the first ten. We couldn't figure out why this happens. We only observed we get accurate result more often if we always force Spotlight indexing when a volume is mounted, no matter what result indexing status check returns.
At the end, let's just say that in our experience Old type search works reliably on network volumes. It doesn't give you all the options as Spotlight does (e.g. searching files with particular contents, tags, or keywords) though.