Fine-Tune Yahoo! Web Search Queries

By understanding how to phrase your searches, you’ll find more relevant search results.

Using Yahoo! Web Search (http://search.yahoo.com) is deceptively simple. You can type in any word or phrase and find matches in documents across the Web. The trade-off for this simplicity is having to look through hundreds, thousands, or millions of results to find the documents that are actually useful to you. By understanding how Yahoo! expects queries to be phrased, you can limit the results to include only those documents most relevant to you—saving you the time of looking through extraneous results.

Search Basics

To start building sophisticated queries, you need to know the basics. The following search basics will help you refine your Yahoo! searches:

Keyword

By default, Yahoo! searches for all of the words you type into a search form. If you type grammar into the search form, Yahoo! will return documents that contain the word grammar. A search for grammar school will return documents that contain both words somewhere within the document, but not necessarily together.

Complete phrase

To search for words in a specific order, enclose the words in quotation marks. A search for "grammar school" will return documents that contain the complete phrase grammar school. You can combine keyword and phrase searches. To find documents that contain the phrase grammar school and also have the word Oregon somewhere in the document, you could search for "grammar school" Oregon.

OR keyword

You can change the default behavior of keyword searches by using the capitalized keyword OR between words. A search for grammar OR primary will return documents that contain either grammar or primary, but not necessarily both words.

Exclude words or phrases

To find documents without a certain word, you can use the minus sign (-) along with the word you want to exclude. If a search for Oregon school returns too many pages for schools in the city of Portland, you could type Oregon school -Portland to exclude any pages with the word Portland from the results.

Once you have the basics down, you can start mixing and matching, and grouping queries together with parentheses. To find documents that contain the word Oregon, and the phrase grammar school or the phrase elementary school, you could type Oregon ("grammar school" OR "elementary school"). The parentheses are required to show where the OR should be used. Without the parentheses, Yahoo! would look for documents that contain both the word Oregon and the phrase grammar school, or documents that simply contain the phrase elementary school. Because the word Oregon is necessary across documents, the two secondary phrases need to be grouped into a single unit with parentheses.

Search Meta Words

In addition to the basic operators, there are keywords that Yahoo! calls Search Meta Words that you can use to refine your search:

site:

Use this keyword to limit search results to a single web site. You can search for the word marsz across NASA sites by typing mars site:nasa.gov. All of the results will be from sites hosted at the nasa.gov domain. You also use this keyword to limit results to a single top-level domain, such as .org, .com, or .edu. To find mentions of the word mars across academic sites, type mars site:.edu.

hostname:

This keyword limits results to a specific host at a site. For example, NASA’s Mars Exploration Program has a web site at http://mars.jpl.nasa.gov. If you want to search this specific section of the nasa.gov domain for the word rover, you could type rover hostname:mars.jpl.nasa.gov.

link:

You can use this keyword to find sites that link to a specific URL. This keyword works well if you want to judge the popularity of a specific page by finding the number of other sites linking to a particular page. You’ll need to include the full URL, so to find pages that link to the Amazon Hacks page at the O’Reilly Hacks site, type link: http://www.oreilly.com/catalog/amazonhks/.

linkdomain:

Instead of a specific page, this keyword looks for any links to a specific domain. If you’re interested in pages that link to http://www.oreilly.com, type linkdomain:oreilly.com.

url:

This keyword lets you look up a single page at Yahoo! by specifying the URL. You can look up the O’Reilly Hacks home page by typing url: http://hacks.oreilly.com. You could use this keyword to see how pages at a site are displayed in Yahoo!’s Web, Images, and Video Search results.

inurl:

Use this keyword to find sites that have a specific word within the URL. To find all sites that have the word mars in the URL, type inurl:mars.

intitle:

Like inurl:, this keyword returns documents that have a specific word in the document title. To find documents with mars in the title, use intitle:mars.

You can also use the basic search operators in combination with the Search Meta Words to refine your search. Say you’d like to search for the word mars across documents, but you don’t want pages from any nasa.gov site; type mars -site:nasa.gov. Because Yahoo! supports very long queries, you could specify a whole list of sites that you don’t want information from: mars -site:nasa.gov -site:mars.com -site:space.com. But to search those sites exclusively, take away the minus symbol, group the site list together with parentheses, and use the OR keyword like this: mars (site:nasa.gov OR site:mars.com OR site:space.com). Again, note that the use of the OR keyword requires the use of parentheses.

Some of these query combinations can also be accomplished with the advanced search form [Hack #5] available at http://search.yahoo.com/web/advanced.

Get Yahoo! Hacks 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.