On the surface, searching with Spotlight is pretty straightforward. In our previous installment, we covered the basics of using and customizing the Spotlight menu. But if your search involves multiple terms, or if you need to narrow down your results to dig up a particularly elusive file, knowing how to put together a good search query will pay off. By mastering a few simple tricks, you can limit your search to specific types of data, exclude terms, and more—helping Spotlight locate exactly what you need. and then take you inside some of its lesser know features—including how to use keywords to limit your search to specific dates, authors, or file types.
Fix your phrasing
You can narrow down the search results by using quotation marks—this tells Spotlight that the words must appear next to one another. If you type "time machine", Spotlight will look only for files that contain the exact term inside the quotation marks. It will find Time Machine.doc and any file containing the term time machine, but it will skip over your presentation on the evolution of machines through time. You don’t even have to use both quotation marks; typing only the first one tells Spotlight that the words following it must appear together. However, if you want to add more search terms after the phrase, you’ll need to add the closing quotation mark.
Apply Boolean searching
One of the biggest additions to Spotlight is support for true Boolean searching, which uses logical operators (AND, OR, and NOT) to pinpoint results.
For instance, if you type "time machine" OR morlocks, you’ll get references to Leopard’s backup tool, as well as any files related to H. G. Wells’s fictional species. To find files that include time machine but make no mention of H. G. Wells, type "time machine" NOT Wells. When you perform a Boolean search, make sure to type operators in capital letters.
To see what sort of metadata a file is storing, select it in the Finder, press command-I to open the Get Info window, and click on the triangle next to More Info. However, you’re not limited to the metadata you see here. You can add your own keywords to any file. In the Get Info window, click on the triangle next to Spotlight Comments. In the text field that appears, enter any keywords that might help you in future searches, such as the project the file is related to or the last name of a person you associate with it. For example, by adding the comment HOUSE08 to any files having to do with the purchase and remodeling of your new home, you’ll be able to find all those files with one easy search.
If you use this trick often, you may want to create an Automator workflow that lets you apply the same comment to multiple files at once. To do this, launch Automator, select Files & Folders from the Library column, and drag Set Spotlight Comments For Finder Items from the Actions list to the workflow pane. Click on Options, and enable the Show This Action When Workflow Runs option. Then select File: Save As Plug-In. Give the plug-in a name, such as Spotlight Comments, and select Finder from the Plug-In For pull-down menu.
Take advantage of keywords
Even when you know what you’re looking for, you may get an overwhelming number of search results. To help limit searches to certain file types or time periods, use one of the many useful keywords that Spotlight understands. Place the appropriate keyword and a colon in front of your search term (but don’t accidentally insert a space before or after the colon—a common mistake).
Here how to take advantage of Spotlight’s keywords:
Search for File Names If you know the name of the file you’re looking for, you can limit your search to file names by using the name: keyword. For instance, when you type name:machine, Spotlight will find only files that contain the word machine in their names (though your search results may also turn up bookmarks, iCal events, and other items). As with regular search queries, you’ll need to use quotation marks to identify phrases—for example, name:"time machine".
Find an Author If you can’t remember the contents of a file but you know the name of the person who created it, you can try using the author: keyword. To look for a document written by your boss, Herbert, enter author:herbert in the search field. There’s just one catch: Spotlight will find only files produced by programs that save this attribute—Mail, iChat, Word, Excel, Pages, Numbers, and a few others.
Check the Date Looking for a file that was created during a specific time period? Spotlight has a handle on dates. Typing date:today will bring up files you created, read, received, or opened today. You can also use the date: keyword with yesterday and tomorrow (for the latter, Spotlight restricts its results to iCal events and to-do items).
The latest version of Spotlight also lets you specify more parameters (whether a file was created or modified on a certain date), as well as enter an exact date or a range of dates. For example, you can type created:12/25/07 to find files authored on that date; type modified:<11/30/06 to look for files changed before that date; or type created:1/1/06-12/31/06 to locate files created between these two dates. Unfortunately, date: keywords don’t seem to work correctly all the time.
Search by Kind One of the most useful ways to narrow down a search is by using the kind: keyword. This allows you to restrict your list of results to a certain file format. For instance, if you type time machine kind:pdf, Spotlight will pull up only PDF files containing the words time and machine. You can also limit your search to e-mail messages, music files, System Preferences, applications, and more.
While the original Spotlight recognized only a limited number of file types, the Leopard version can look for files created by specific applications, as well as certain file formats. Searching for kind:mp3 or kind:tiff will find files in one of those formats, and searching for kind:pages or kind:powerpoint will show only documents created in one of those programs. For a list of useful keywords, see “My Kind of Keyword.” But remember, for the keywords to work, you must have the appropriate categories enabled in Spotlight’s preferences.
My Kind of Keyword
To Search for:
kind:application, kind:applications, kind:app
kind:email, kind:emails, kind:mail message
kind:folder, kind:folders, kind:fol
iCal To-Do Items
kind:todo, kind:todos, kind:to do
Spotlight’s other tricks
Better search functionality is the main attraction of Leopard’s new and improved Spotlight. But it has other clever tricks that may come in handy.
Instant Dictionary Need the definition for tarradiddle? Look it up in Spotlight. Whenever you type a word into the Spotlight menu, a short definition appears in the list of results. Hover your cursor over this definition to view the full definition in a tooltip.
Math Genius Type an equation into the Spotlight menu, and let your Mac do your math. For example, type 2*2, and you’ll get 4. If you need the area of a circle with a radius of 10 feet, type pi*10*10. Need the square root of 1,024? Enter sqrt(1024). How about 64 squared? Just type pow(64,2).
Unfortunately, Apple has yet to publish a list of such commands, so you’ll have to memorize the basics for now.
[Kirk McElhearn writes about Macs and much more. Visit his blog, Kirkville, for information about Macs, iPods, books, music, and more.]
Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read ouraffiliate link policyfor more details.