How Spotlight Works Behind the Scenes

Spotlight can search for a file by its name, or it can search for information inside the file, such as text embedded in PDF documents or inside text documents; it can even search through what is called metadata attached to images, so you can search for the exposure setting of a picture imported from a digital camera.

Spotlight gets access to information through several means:

• It reads the OS X file system's entries and monitors the file system as you work with files to see the names and locations of all files stored on your Mac and accessible via attached devices, including documents stored in iCloud Documents (see Chapter 8).

• It reads the contents of files as you would, by opening them behind the scenes.

• It reads metadata stored with the files, as well as any metadata you or Spotlight-savvy applications add as Spotlight comments. Apple's applications are very Spotlight-savvy, which is why contacts, e-mail, calendars, browser histories, and other such information are easy to access via Spotlight. Adobe's Creative Suite applications also add lots of metadata to their files; likewise Microsoft Office applications also add some metadata to their files. And you can add your own information to files by modifying the Spotlight Comments field in the Info window, as the sidebar “Just what is metadata?” explains.

Spotlight builds an index of these files behind the scenes as you're working, so it doesn't have to actually search through your entire ...

Get OS X Mountain Lion Bible now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.