Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Apple > Operating Systems

  • Print
  • + Share This
This chapter is from the book

Using Spotlight and Quick Look

Spotlight was a significant new feature in Mac OS X v10.4 that revolutionized the way users searched for files on their Macs. Spotlight enables you to perform nearly instantaneous searches that go wider and deeper than previous Mac desktop search technology. Spotlight has the ability to go beyond simple file system searches and actually search for relevant metadata inside application files and databases. For example, an application like Address Book stores contact information in a database that appears opaque to the file system. Nevertheless, Spotlight can return search results from Address Book along with results from other databases and the entire file system hierarchy nearly instantly.

Though Spotlight was pretty amazing when it debuted, Apple added a few more tricks to Spotlight over the years. These included the ability to search through the contents of shared files from other Mac clients, servers, AirDisk volumes over the network, and Time Machine backups. Lion introduced the ability for Spotlight searches to automatically return results from your default web search engine and Wikipedia.

Apple has also incorporated the ability to use advanced search operations while performing Spotlight searches from the Finder or menu bar. Advanced Spotlight search operations include:

  • The use of multiple search criteria types in a single search
  • The use of Boolean logic by using AND, OR, or NOT
  • The use of exact phrases and dates by using quotation marks
  • The use of search ranges by using greater-than and less-than symbols.

Another feature, dubbed Quick Look, augments Spotlight by allowing you to quickly preview the content of most files even if you don’t have the application that created the file installed on your Mac. The combination of Spotlight and Quick Look allows you to locate and preview items with unmatched ease and speed.

Using Spotlight for Searching

You can initiate a Spotlight search any time by clicking the Spotlight icon on the far right of the menu bar or using the Command-Space bar keyboard shortcut. The Spotlight search is so fast that the results will actually change in real time as you type in your search query. In the results list, moving your mouse over an object (but not clicking) or using the arrow keys will open a Quick Look preview of the content. Clicking on an item or pressing the Return key with a result selected will open it immediately.


Selecting Show All in Finder from the Spotlight search results menu will open a new Finder window with the results. You could also arrive at this same window by opening a new Finder window and entering your search in the Spotlight field from the Finder’s toolbar, or by selecting File > Find from the menu bar, or using the Command-F keyboard shortcut. Selecting an item from the search results will show you the path to the selected item at the bottom of the Finder window. Selecting an item and then tapping the Space bar will open a Quick Look preview of the selected item.


You can refine your Spotlight search from a Finder search window by clicking the small plus buttons on the right below the search field. This will allow you to add as many specific search attributes as you need. After you add a new search attribute, click the first word in the search attribute to choose another type from the pop-up menu.


If you don’t see the search attribute you’re looking for, you can add literally dozens of other attributes that aren’t enabled by default. To enable additional search attributes, select any attribute, and from the pop-up menu select the Other option. This will reveal a dialog that allows you to add search attributes to the pop-up menu. Two especially useful search attributes for administrators are “File visibility” and “System files,” neither of which is shown by default in any Spotlight search.


Clicking the Save button on the right will save these search criteria as a Smart Folder. Smart Folders are like normal folders in that they can be given a unique name and placed anywhere you like, including the Finder’s sidebar. Smart Folders are special because their contents will always match your search criteria no matter how the file system changes. In fact, the All My Files item in the Finder’s sidebar is simply a predefined Smart Folder searching for the most recently opened documents in the user’s home folder.


Using Quick Look for Previewing

Again, Quick Look allows you to preview nearly any file type without having to open any additional applications, or even having those applications installed on your Mac. This makes Quick Look the most convenient method to view the contents of any file. Quick Look previews can be accessed, or dismissed, by pressing the Space bar from any Finder view, the Time Machine restore interface, most open and save browser dialogs, the Mail application, or any other application that supports Quick Look. A new feature in Lion makes Quick Look preview windows stay open in the Finder until closed, just like traditional windows. The Quick Look close window button is in the top-left corner, again just like a traditional window. You can also quickly dismiss the Quick Look preview by pressing the Space bar again.


With the Quick Look preview window open, you can resize the window by clicking and dragging any edge of the window, or you can go full-screen by clicking the twin arrow button at the top right of the preview window. Note the Open with Application button next to the full-screen button. Use the arrow keys to navigate and preview the items adjacent to the original previewed item in the Finder. If the previewed file has multiple pages, you’ll be able to scroll through the document. In some cases—Keynote presentations, for example—Quick Look will show a thumbnail preview of each slide, allowing you to scroll through the thumbnails as well. Finally, if you select multiple items to preview, the Quick Look window will allow some basic slideshow features via buttons at the top left of the window.


Quick Look technology is also used to provide the Finder with previews for files in icon view, previews in column view, and the preview section of the Get Info and Inspector windows. Finally, Quick Look also provides previews for the Finder’s Cover Flow view. This view allows you to browse folder content in a similar way to browsing with iTunes or Apple’s other mobile devices. Quick Look can be accessed from any Finder window by selecting its icon in the toolbar.


Quick Look Plug-ins

Quick Look is able to preview an ever-growing variety of file types using a plug-in technology. Each Quick Look plug-in is designed to preview specific types of files. Many Quick Look plug-ins are included by default, but Apple and third-party developers can create additional plug-ins to expand Quick Look’s preview capabilities.

Included Quick Look plug-ins enable you to:

  • Preview any audio or video file that can be decoded by QuickTime
  • Preview a variety of graphics files, including many digital camera files, PDF files, EPS files, and any standard graphics file
  • Preview a variety of productivity files, including standard text files, script files, and files created by the iWork and Microsoft Office suites
  • Preview a variety of Internet-centric files, including mailboxes, iChat transcripts, and web archives

Quick Look plug-ins, like any other system resource, are stored inside the various Library folders. Apple’s built-in Quick Look plug-ins are always found in the /System/Library/QuickLook folder and sometimes appear in the /Library/QuickLook folder. Third-party plug-ins should always be installed in either /Library/QuickLook or the ~/Library/QuickLook folder, depending on who needs access to them.

Understanding the Spotlight Service

Spotlight is able to perform wide and deep searches quickly because it works in the background to maintain highly optimized databases of indexed metadata for each local volume. When you first set up Lion, it will create these databases by indexing all the available local volumes. The system will also index new local volumes when they are first attached.

On your Mac, a background process called mds, short for metadata server, will automatically update the index databases on the fly as changes are made throughout the file system. Because these indexes are kept current, the Spotlight process need only search through the databases to return thorough results. Essentially, Spotlight preemptively searches everything for you in the background so you don’t have to wait for the results when you need them.

You can find the Spotlight general index databases at the root level of every volume in a folder named .Spotlight-V100. A few applications maintain their own databases separate from these general index databases. One example is the built-in email application Mail. It maintains its own optimized email database in each user’s folder at ~/Library/Mail/Envelope Index. Also, the Spotlight index database for a Legacy FileVault user is stored at the root level inside his encrypted home folder for enhanced security. If you are experiencing problems with Spotlight, you can force it to rebuild the index databases by deleting them and restarting your Mac or by managing the Spotlight settings as covered later in this chapter.

Spotlight Security

In order to provide security on par with the rest of the file system, Spotlight also indexes every item’s permissions. Even though Spotlight indexes every item on a volume, it will automatically filter search results to show only items that the current user has permissions to access. There is still a security concern, though, when users search through locally attached non-system volumes because they can choose to ignore ownership on these volumes. In other words, all users can search through locally attached non-system volumes, including mounted disk images, even if another user attached the device.

Spotlight Plug-ins

Spotlight is able to create indexes, and thus search, from an ever-growing variety of metadata using a plug-in technology. Each Spotlight plug-in is designed to examine specific types of files or databases. Many Spotlight plug-ins are included by default, but Apple and third-party developers can create additional plug-ins to expand Spotlight’s search capabilities.

Included Spotlight plug-ins enable you to:

  • Search via basic file metadata, including name, file size, creation date, and modification date
  • Search via media-specific metadata from picture, music, and video files, including time code, creator information, and hardware capture information
  • Search through the contents of a variety of file types, including text files, iLife related files and databases, Photoshop files, PDF files, iWork files, and Microsoft Office files
  • Search through personal information like Address Book contacts and iCal calendar events
  • Search for correspondence information like the contents of Mail emails and iChat chat transcripts
  • Search for highly relevant information like your favorites or web browser bookmarks and history

Spotlight plug-ins, like any other system resource, are stored inside the various Library folders. Apple’s built-in Spotlight plug-ins are always found in the /System/Library/Spotlight folder and sometimes appear in the /Library/Spotlight folder. Third-party plug-ins should always be installed in either the /Library/Spotlight or the ~/Library/Spotlight folder, depending on who needs access to it.

Managing Spotlight Settings

From the Spotlight preferences, any user can choose to disable specific categories from appearing in Spotlight searches. A user can also prevent volumes from being indexed by specifying those volumes in the privacy list. However, by default all new volumes are automatically indexed, so a user must manually configure Spotlight to ignore a volume.

The Spotlight privacy list is a computer-level setting that remains the same across all user accounts, but it’s not protected by administrative access, which means any user can change the privacy list. In this case, the Spotlight privacy list isn’t any less secure than the rest of the file system, as any user can still have full access to locally connected non-system volumes because the system defaults to ignoring ownership on those volumes.

To change Spotlight settings:

  1. Open the Spotlight preferences by choosing Apple menu > System Preferences, and then clicking the Spotlight icon.

    The Spotlight preferences will open to the Search Results tab, allowing you to disable specific categories from the search results.

  2. Simply deselect the checkboxes next to the categories you wish to ignore.

    You can also drag categories to change their order in the search results. Each user has her own separate Search Results settings.

  3. To prevent Spotlight from indexing specific items, click the Privacy tab to reveal the list of items for Spotlight to ignore.

    To add new items, click the small plus icon at the bottom of the privacy list and choose the items from a browser dialog, or simply drag and drop items into the privacy list.

  4. You can delete an item from the privacy list by selecting it and then clicking the minus icon at the bottom of the list.

All Spotlight settings are applied immediately. If you add an entire volume to the privacy list, then the system will delete the Spotlight index database from that volume. In turn, removing a volume from the privacy list will rebuild the Spotlight index database on that volume. This technique, to rebuild the Spotlight index databases by adding, then removing, a volume from the privacy list, is the most common method to resolve problematic Spotlight performance.

  • + Share This
  • 🔖 Save To Your Account