Effective Searching in Safari
Save Hours Searching in Safari with This Short Tutorial

by Allen Noren
November 2003

Safari Bookshelf is a continuously updated, online library featuring the best IT titles anywhere. Available on an enterprise or individual subscription basis, Safari includes the latest publications from Adobe Press, Addison Wesley Professional, Cisco Press, New Riders, O'Reilly & Associates, Peachpit Press, Prentice Hall PTR, Que, and Sam's Publishing.

Whether you're a Safari subscriber or not, you can search the entire online reference library to find the code, tools, and understanding you need to solve computing challenges. To make your searches as efficient and effective as possible, you should be aware of the three types of searches in Safari: Basic, Advanced, and Find a Specific Book. How are they different, and which should you use?

Basic Search

You'll find a Basic Search box conveniently located in the upper-left corner of every Safari page.

Basic Search allows you to search in four ways:

  • All Books: Searches all books in Safari.
  • My Books: Searches only the books on your Safari bookshelf.
  • Current Book: Searches only the book you have open.
  • Code Fragments Only: Searches all code fragments from all books in Safari.
Safari Basic Search: Default Safari Basic Search: While Viewing a Book
Figure 1: Safari Basic Search (Left: Default; Right: While Viewing a Book)

Basic Search allows the user to find general information within the Safari Bookshelf. Sometimes, however, the number of results can be overwhelming, and the specific information you're after may not be readily apparent. You can improve your Basic Search results and zero-in on your query by using some Advanced Search techniques.

For example, a search for the dir command returns 999 matches in 360 different books (as of this date). Many different development environments and programming languages are represented in those results. Suppose you were simply looking for how to execute dir on a Windows machine? You'd have to go to the third results page before finding a Windows book addressing the subject. But if you include a search operator and Safari's search syntax in your Basic Search, you'll get more targeted results. For example, the first two search results are Windows books when you search for dir AND windows. Note that Safari's search syntax and Boolean operators always use capital letters.

Basic Search gets better when your search is more specific, with or without operators, in the "Current Book" and "Code Fragments only" modes. Searching for code fragments is one of Safari's hidden strengths.

Advanced Search

Advanced Search is where the power of Safari's search engine and thorough metadata become most evident, and it's probably the way to go if you're uncomfortable conducting Boolean searches or haven't memorized the relevant operators. You get Safari's Advanced Search by clicking the words "Advanced Search" at the bottom of the Basic Search box in the upper-left corner of every Safari page. The Advanced Search looks like this:

Safari Advanced Search
Figure 2: Safari Advanced Search

Using Advanced Search allows you to search as broadly or as finely as you desire, and it delivers very accurate results. With Advanced Search, you can conduct complex searches, such as finding books "with exactly these words," published between 2001 and 2003, and by a specific publisher, like O'Reilly.

Further, Advanced Search is helpful when you have only fragmentary information about a book or topic. If you type "Swing" in the "Words in Book Titles" box, and "Robert" in the "Author" box, you'll get Java Swing by Robert Eckstein. Similarly, selecting "Code Fragments only" and searching for $ ex will take you directly to Chapter 5, Section 1 of Learning the vi Editor, where you can brush up on ex Commands.

Want to return to a search you've already conducted? No problem. Click the "Recent Searches" tab at the top of your Safari screen and you'll get a page of all your recent searches. Click on any of them and you'll be taken back into Safari. You can also sort your searches by Date and Search Term.

Find a Specific Book

You'll find this search option at the bottom of the left navigation bar on every Safari page. Click on "Author," "ISBN," "Title," or "Publisher," and you're taken to the following page:

Find a Specific Book
Figure 3: Find a Specific Book

While this search is really another version of the Advanced Search, there is convenience in having your cursor pre-loaded in the form field you've requested: click "ISBN" and your cursor will be in the ISBN form field; click "Title" and your cursor will be waiting for the words that follow there.

Lastly

Technically, "Browse by Category" (the category list in Safari's left navigation bar), as well as "New This Week" and "Top Books" (available when you've clicked the "My Safari" tab at the top of the Safari page), are also searches of a sort, though they result in a list view and have no associated search form.

Safari XML Gateway Search Syntax

Here's a formal description of the Safari search syntax. Please note that the keywords are case-sensitive.

EXPRESSION = ['NOT'] (QUERY | '(' EXPRESSION ')')
[LOGICAL_OPERATOR EXPRESSION]
QUERY = (['TEXT'] FTQUERY)
| (('CODE' | 'CAPTION' | 'TITLE') FTQUERY)
| 'SUBSCRIBED'
| 'NEWTHISWEEK'
| 'BOOK'2
| (CONTEXT RELATIONAL_OPERATOR TEXT)
CONTEXT = 'XMLID'
| 'XCATID'
| 'PUBLID'
| 'PUBLDATE'
| 'ISBN'
| 'AUTHORS'
| 'BOOKTITLE'
LOGICAL_OPERATOR = 'AND' | 'OR' | 'NEAR'
RELATIONAL_OPERATOR = '='
| '>='
| '<='
| '>'
| '<'
| '<>'
| 'LIKE'

Examples of valid search expressions:

• XSLT
• XSLT NEAR XPath
• XSLT OR XPath
• Java AND compiler
• "Java AND compiler"
• "Java compiler*"
• TITLE jabber
• (java compiler) AND (PUBLID = 12)
• CODE "private static"
• (applet) AND (BOOKTITLE java) AND (PUBLDATE >= 19990101) AND (PUBLDATE <= 20011231)
• BOOK AND (BOOKTITLE groupware) AND (AUTHOR udell)