My favorites | English | Sign in

More personalization in Google Friend Connect New!

Google Custom Search API

Improving User Queries for More Relevant Results

The Helping Your Users Refine Their Searches page showed you how you can create refinement labels that helps your users get more targeted results. This page will show you how to change or respond to your users' queries to deliver results that are more relevant.

Contents

This page includes the following sections:

Overview

If you know your audience well, you can roughly predict the kinds of things they might search for. You can anticipate their queries and help them find more relevant results.

Custom Search enables you append search terms to your users' queries, redirect users to another website or search engine, and create synonyms of your users' queries. The first two features are implemented through refinements, which your users can apply or ignore; while the synonym features act on your users' queries without requiring any user action.

Appending Search Queries with Refinement Labels

If you want to help your users by providing refinement links that add helpful search terms to their queries, you can use the Rewrite element in your refinements. The element appends the search terms to your users' queries when they click a refinement link. The Rewrite element can have up to 100 characters, all of which should be lowercase, except for uppercase search operators such as OR. To learn more about search operators, see the Advanced Search Made Easy page. To learn more about refinements, see Helping Your Users Refine Their Searches.

The following example shows you how you can use Rewrite.

<CustomSearchEngine>
   <Title>Universities</Title>

   <Context>

     <Facet>
        <FacetItem title="Homework">
          <Label name="assignments" mode="BOOST">
            <Rewrite>homework OR assignment</Rewrite>
         </Label>
       </FacetItem>
     </Facet>
   </Context>

</CustomSearchEngine>

The example shows how to help users who click the refinement link called "Homework". It appends additional search terms, "homework" and "assignment", to the search query that your users typed.

A refinements with the Rewrite element has the following structure:

  • Facet
    • FacetItem(up to four)
      • Label name
        • Rewrite

Back to top

Redirecting Search Queries with Refinement Labels

If you want to redirect your users to a different website when they click on a refinement link, you can use the Redirect element's url attribute, as in the following example.

<CustomSearchEngine>
   <Title>Universities</Title>
   <Context>
     <Facet>
      <FacetItem title="Papers">
        <Label name="papers" mode="FILTER"/>
        <Redirect url="http://scholar.google.com/scholar?q=$q"/>     
      </FacetItem>
     </Facet>

   </Context>

</CustomSearchEngine>

In the example, users are redirected to another search engine, http://scholar.google.com/scholar. The latter part of the URL, ?q=, is the parameter for entering queries for Google Scholar. The parameter value in last part, $q echoes your users' queries.

If your URL has CGI arguments, use &amp; instead of &.

A refinements with the Redirect element has the following structure:

  • Facet
    • FacetItem (up to four)
      • Label name
      • Redirect

Note: Redirect is a child element of FacetItem, not Label.

Back to top

Expanding Search Queries with Synonyms

You can expand your users' search queries by using synonyms, which are variants of a search term. For example, the finance-related search query,"interest", could have the following equivalent alternatives: "yield", "dividend", "coupon", and so on. If you create synonyms for "interest" in your financial search engine, your users will not need to type multiple variants to find information they are seeking. The custom search engine will automatically search for all sites that are relevant to "interest", "yield", "dividend","coupon", and other related terms.

Popular query terms, common initialisms (such as "CD" for "certificate of deposit"), and familiar abbreviations (such as "munis" for "municipal bonds") that are idiosyncratic to your specialized field or interest are great candidates for having synonyms. If your search engine is popular enough and receives many searches for the same queries, you can get data about your most popular queries from the statistics page. Go to My Search Engine and click the statistics link for the search engine. Popular queries are listed at the bottom of the page.

Don't bother creating synonyms for query terms that are common to the general public. For example, the synonymous terms "UK", "Britain", "United Kingdom", "United Kingdom of Great Britain" are fairly well-known variants to most web users. Google already has a large body of synonyms for such terms, and since Custom Search lets you harness many of the search features of Google search, you shouldn't bother replicating the work.

Instead, create synonyms for common terms that are specific to the interests of the users of your search engine. For example, in the financial search engine, "bond" would be a great candidate. Unlike you, Google search might not know the context under which your users are searching. They could be looking for "James Bond", "chemical bond", "adhesive bond", "emotional bond", or whatnot. You, on the other hand, know that they are looking for a financial instrument and can easily come up with synonyms such as "fixed-income security" and "issue".

If you cannot discern whether a term is common or idiosyncratic, you can test the term and its variants on Google search. Type the query term (such as "san francisco") on Google search and then open a new browser window. In the Google search box, type the query term, the search operator OR, and the variant of the query term (for example, "san francisco OR sf"). Compare the two results pages. If they are exactly the same, then Google has the synonymous terms covered.

The thesaurus of synonyms is defined in the context file. The following is an example:

<CustomSearchEngine ...>
   
<!--For brevity, other elements have been excluded...-->

  <Context>
  
   <BackgroundLabels>...</BackgroundLabels>

   <Synonyms>
     <SynonymEntry word="stock">
        <Synonym>equity</Synonym>
        <Synonym>share</Synonym>
     </SynonymEntry>

     <SynonymEntry word="bond">
        <Synonym>fixed-income security</Synonym>
        <Synonym>issue</Synonym>
        <Synonym>high yield debt</Synonym>
     </SynonymEntry>
   </Synonyms>

  </Context>

</CustomSearchEngine>

Synonyms is a child element of Context and has the following structure:

  • Context
    • BackgroundLabels
    • Synonyms (1 only)
      • SynonymEntry
        • Synonym (up to 10 for each SynonymEntry)

Note: The parent element Synonyms is in plural form, while its grandchild element, Synonym, is in singular form.

Each query term (SynonymEntry element) can have with up to ten variants (Synonym elements). The variants could be single words or phrases. You can define multiple query terms, so long as you not exceed a total of 500 variants.

Back to top

Taking the Next Step

If you want to promote certain webpages or directly answer questions of your users, you can create special results. But if you are done creating tools for your search engine, you can start designing its look and feel.

< Back to Helping Your Users Refine Their Searches | Forward to Creating Special Results >