Searching in the Spotlight
Glance at the outside of the Mac OS X 10.4 box and you’ll see that the massive metallic gray X is bathed in a bright spotlight. Could there be a clearer indication of how important this new search technology, Spotlight, is to Apple?
But Spotlight’s significance to Tiger goes beyond simply being touted in Tiger’s packaging and advertising. It resides in the deepest levels of the operating system, performing feats far beyond simple Finder searches.
What sets Spotlight apart from previous search schemes is its ability to catalog and search metadata —information about the data contained in a file, such as the brand of camera used to take a digital photo, the bit rate of an iTunes track, or the author of an e-mail message. This metadata index makes it possible for you to enter a search term such as “tiger” and see not only documents that contain the word in their title, but pictures from your child’s last trip to the zoo, any e-mail exchanges that discuss Apple’s recently released operating system update, a new desktop pattern, and—if your musical taste runs to early-80’s anthems—Survivor’s now-regrettable hit from Rocky III .
Spotlight does its work by accessing two indexes per volume—one that contains metadata and another that handles contents searches. These indexes are created on-the-fly and in the background, so the search results you see are always up-to-date. Unlike with search systems found on other platforms, there’s no need to instruct Spotlight to update its index. And Spotlight is fast because it taps this smaller metadata index before accessing the much larger contents index.
If you find that even metadata and contents searches fail to create searches refined enough for your tastes, you’re welcome to open a file’s Info window and tag the file with a comment in Spotlight Comment field. Yes, Spotlight can search for these comments too.
The most obvious manifestation of Spotlight is the magnifying-glass icon that appears in the upper right corner of the Mac’s menubar (pictured right). Click this icon (or press Command-Spacebar), and the blue spotlight field appears. Type your query and, as you type, results begin to appear, narrowing as you continue typing. You can get even more specific when typing your queries by telling Spotlight what kind of item you’re looking for. For example, typing
kind:applicationproduces a list of all the applications on your Mac, regardless of where they’re stored. You can also combine typed queries—entering
kind:email date:todaylists all the e-mail messages you’ve received today.
From the up-to-20 most relevant results that appear, select the result you want and the document—an iTunes music track or e-mail message, for example—opens in the application associated with it. If you don’t find what you’re looking for, continue typing to narrow your search or click the Show All entry at the top of the list to view all the results in a separate Spotlight window. (By default this window also appears if you press Option-Command-Spacebar.)
Within the Spotlight window you can continue to refine your search by entering additional text. You can also group and sort the results in a variety of ways—by date, kind, or location, for instance. Within these groups you’ll see the five most relevant results followed by a blue link that tells you how many other results remain. Click this link and all the found items appear.
If you have a hard drive packed with files, you can narrow what Spotlight searches for by calling up its preferences and enabling only those files you want it to look for—documents, mail messages and images, for example, but not applications and music files. In this same system preference you can instruct Spotlight to keep out of specific locations. And speaking of butting out, Spotlight respects OS X’s permissions and won’t search the files of another user account on your Mac.
The Spotlight window supports multimedia in a big way. For example, you can view images as thumbnails or as a slideshow (as shown below). Within that slideshow, you can view the images individually or as an index sheet. You can also add an image to iPhoto with a single click (as shown to the right). If you select a movie file in the Spotlight window and click the small Information icon to its right, you can view the movie as a thumbnail, complete with sound. Drag that movie to the Desktop to copy the entire movie. Audio files work similarly.
The first page of a PDF file can also be displayed in a small preview window. Additionally, the Spotlight window’s contextual menus allow you to add a file to an Automator workflow or direct it to Mail as an attachment.
Beyond the Finder
Spotlight is more than a convenient way for search for files from the menubar. Its technology underlies some of the new finding and sorting tricks found in Tiger’s Finder, Mail, Address Book, and System Preferences
In the Finder, Mail, and Address Book, Spotlight’s influence will be familiar to anyone who has ever used iTunes’ Smart Playlists and iPhoto’s Smart Albums. Similar to these live filtering mechanisms, Spotlight allows you to create Smart items in these other applications.
You can now create Smart Folders in the Finder—saved searches using such criteria as name, last opened, kind, size, as well as a host of metadata—that update as you add or change files. These Smart Folders appear not only in Finder windows’ sidebar, but in the sidebar within Tiger’s Open and Save dialog boxes.
Tiger’s Mail offers Smart Mailboxes, a kind of “live rule” that gathers e-mail messages meeting a set of criteria—missives from your boss, for example, or messages related to a particular project. And Address Book contacts that meet certain conditions—those who live within a particular zip code or belong to a certain e-mail domain, for instance—can be gathered together in Smart Groups. (Address Book even allows you to choose a contact and invoke a Spotlight Joe Blow command that will show you all files accessible to you that pertain to the selected contact.)
Spotlight lives up to its name in Tiger’s System Preferences. With it you can now enter a query in System Preferences’ Spotlight field and any system preferences related to the query will be highlighted with a white spotlight. For example, entering “update” places a strong spotlight on Software Update and a dimmer spotlight on QuickTime to convey that the most relevant system preference to the query is Software Update. Along with this eye candy comes a list of topics related to your query that appear below the Spotlight field.
Demonstrating that Spotlight runs deep in the operating system, UNIX-savvy users can use the Terminal’s command line to perform Spotlight searches. The
mdlscommand lists all the metadata attributes of a file and
mdfindperforms a Spotlight-like search from the command line.
More to Come
And finally, Spotlight is extensible. Spotlight works with the help of a series of plug-ins—each plug-in is created for a specific file type or set of file types (for example, one plug-in tackles all image types that OS X natively supports).
Developers are welcome to create Spotlight plug-ins for their applications, meaning that with developer support, it should be possible to find any file, of any type, on your Mac in no time. Microsoft says Word, Excel, and PowerPoint documents will appear in Spotlight searches (but not Entourage, due to the way the e-mail client was built). Ovolab, the developer of Phlink, has also updated its telephony software to include Spotlight support. Other software makers are likely to follow suit in the coming weeks.
And because of that, Spotlight’s future looks very bright indeed.
[ Christopher Breen is a Macworld contributing editor. ]
Sidebar: Spotlight Tips
Eager to make Spotlight shine? Here are three quick tips for getting the most out of Tiger’s new search technology.— Jim Dalrymple
• To quickly jump to the top hit in your Spotlight search results, just hold down the Command key.
• If you know that you changed a file today, but have no idea where you put it, try this. Instead of searching for keywords in Spotlight type in
date:today(no spaces). All the files that changed today will appear in the spotlight menu.
• If you know the type file you are looking for, you can adjust your searches with the
kind:prefix. For example, limit your searches to Keynote and PowerPoint presentations by including
kind:presentationin your search terms.