Skip to content Skip to navigation

Additional Search Parameters

Overview

The as_q and as_oq parameters allow you to add search terms to the query your web site passes to the Stanford Google Custom Search. Unlike as_sitesearch, these parameters allow you to combine multiple terms or URLs with boolean AND or OR. Restriction to multiple site URLs is not supported.

as_sitesearch with as_dt

use: restrict search to a specific URL

<input type="hidden" name="as_dt" value="i" />
<input type="hidden" name="as_sitesearch" value="www.gsb.stanford.edu" />

result: finds only pages in the www.gsb.stanford.edu site that include the user's search term(s)

use: exclude pages from a specific URL

<input type="hidden" name="as_dt" value="e" />
<input type="hidden" name="as_sitesearch" value="gostanford.com" />

result: finds pages in the Stanford collection, but not on the gostanford.com site, that include the user's search term(s).

as_q

use: add one or more search terms to the query, combined with boolean 'AND'

<input type="hidden" name="as_q" value="gsb sloan" />

result: finds only pages in the Stanford collection that contain the user's search term(s) AND the terms 'gsb' AND 'sloan'.

as_oq

use: add one or more search terms to the query, combined with boolean 'OR'

<input type="hidden" name="as_oq" value="gsb sloan" />

result: finds only pages in the Stanford collection that include the user's search term(s) OR the terms 'gsb' AND 'sloan'.

Before you start

The as_q and as_oq parameters have some effects on the results page that you should be aware of before using them on your site.

Displaying Results

When the results page for a search is displayed, the query term is shown in a bar at the top of the results, like this:

Results 1-10 of about 5930. Search took 0.18 seconds.Searched for admissions.

("admissions" is the search term entered by the user)

When you add search terms to a query, those terms are also displayed in the blue bar. For example, if you use as_sitesearch to restrict the search to a specific site, it would display like this:

Results 1-10 of about 29. Search took 0.09 seconds.Searched for admissions site:scpd.stanford.edu.

If you use as_q to add key words to a query:

Results 1-10 of about 122. Search took 0.08 seconds.Searched for admissions gsb AND sloan.

If you use as_oq to add multiple URLs to a query:

Searched for hennessy site:www.stanfordalumni.org/news+site:www.stanford.edu/news+(etc.)

The bar stretches in width — depending on how many URLs you've specified—to the point where it may exceed the browser window size and require horizontal scrolling.

Next Search

When you use the as_sitesearch, as_q or as_oq parameters to pass query terms to  the Stanford Google Custom Search, the results page displays the complete query in the blue bar, but only the user's search term in the search box. If the user changes or adds to their search term, the next search will be done against the entire Stanford collection — your parameters will no longer be included.

Use the sitesearch parameter if you need your search parameters to be included in the next search. Unlike as_sitesearch, the sitesearch parameter is not affected by the as_dt parameter. The sitesearch and as_sitesearch parameters are handled differently in the XML results. The sitesearch parameter's value is not appended to the search query in the results. The original query term is not modified when you use the sitesearch parameter.

Using the as_q and as_oq parameters

(See Information and Instructions for Web Creators for details about the <form> tag.)

as_q (AND)

Add the following line to the search <form> tag in your web page:

<input type="hidden" name="as_q" value="<yourterms>" />

In place of <yourterms>, list the terms you want to add to your users' queries, separated by a space.
e.g.: 'gsb sloan'

as_oq (OR)

Add the following line to the search <form> tag in your web page:

<input type="hidden" name="as_oq" value="<yourterms>" />

e.g.: 'gsb sloan'

In place of <yourterms>, list the terms you want to add to your users' queries, separated by a space.

If you have questions about using these parameters with the Stanford Google Custom Search, please submit a HelpSU request.

Last modified May 11, 2012