Custom Google Appliance Search - Documentation topics on: custom google appliance search,googleminiapi,google mini search,macros,.

Custom Google Appliance Search

Use this macro to pull search results from a custom Google search. Returns a specific GoogleMiniSearch object, but requires some specific configuration (see Usage, below).

Macro Overview:


$googleapi.searchGoogleCustom(client, query, start, num, autoFilter)


  • client (string/non required)
    This is the frontend client name, as its setup in the google custom search. Null can be used if you want to use the default value 'GOOGLE_CUSTOM_SEARCH_CSEID' configured in ''.
  • query (string/non required)
    The user query to narrow the results.
  • start (number)
    Index where to start the search. Starting on 0.
  • num (number)
    Number of results to retrieve, -1 to retrieve all results. (Maximum value is 20. If you request more than 20 results, only 20 results will be returned)
  • autoFilter (boolean true/false)
    Activates or deactivates automatic results filtering performed by Google search.
    Currently, Google search uses two techniques for automatic filtering of results:
    Duplicate Snippet Filter - If multiple documents contain the same information in their snippets in response to a query, then only the most relevant document of that set will be displayed in the results.
    Duplicate Directory Filter - If there are many results in a single web directory, then only the two most relevant results for that directory will be returned in the results. An output flag indicates that more results are available from that directory.

Optional Parameters:


To use this api you must set the variables GOOGLE_CUSTOM_SEARCH_URL and GOOGLE_CUSTOM_SEARCH_CSEID in the file to point to the google custom search url. Example:

The api returns a GoogleMiniSearch object that contains all the variables necessary to display the retrieved results.

GoogleMiniSearch Object - Attributes

  • searchTime - The time taken by the appliance to retrieve the results
  • query - The request query
  • params - Hashmap with param names and values;
  • contextTitle - String with the context title;
  • fromIndex - The start index of results
  • toIndex - The end index of retrieved results
  • estimatedTotal - The estimated total of result based on the given query
  • searchResults - The list of results, this is a list of GoogleMiniSearchResult objects
  • hasNextPage() - Method that returns true if results has a next page to display
  • hasPreviousPage() - Method that returns true if results has a previous page to display

GoogleMiniSearchResult - Attributes

  • identationLevel - Level of indentation used for inner results
  • mimeType - Mime type of the result
  • resultURL - The url to the result
  • title - The title
  • generalRatingRelevance - Relevance of the document in google mini
  • additionalSearchDetails - More details about the retrived document
  • snippet - Result snippet
  • metaTagsFields - A map of metatags associated to the result
  • language - Language associated to the result
  • label - Label associated to the result
  • documentCacheSize - Document Cache Size associated to the result
  • documentCacheId - Document Cache Id associated to the result

Example 1: A simple example using the required fields

#set($searchObj = $googleapi.searchGoogleCustom("", "Knight", 0, 100, false))
<b>Search Summary</b><br/>
<b>Total Search time:</b> $searchObj.searchTime<br/>
<b>Query:</b> $searchObj.query<br/>

#foreach($param in $searchObj.params)
 <b>Param Name:</b> $param.key<br/>
 #foreach($paramValue in $param.value)
  <b>$paramValue.key:</b> $paramValue.value<br/>


<b>From Index:</b> $searchObj.fromIndex<br/>
<b>To Index:</b> $searchObj.toIndex<br/>

<b>Estimated Total:</b> $searchObj.estimatedTotal<br/>
<b>Has Next Results Page:</b> $searchObj.hasNextPage()<br/>
<b>Has Previous Results Page:</b> $searchObj.hasPreviousPage()<br/>

<b>Estimated Total of Results:</b> $searchObj.estimatedTotal<br/>

#foreach($result in $searchObj.searchResults)
 <b>Result Index:</b> $result.resultIndex<br/>

 <b>Identation Level:</b> $result.identationLevel<br/>
 <b>Title:</b> $result.title<br/>
 <b>Snippet:</b> $result.snippet<br/>

 <b>Result URL:</b> <a href="$result.resultURL">$result.resultURL</a><br/>
 <b>General Rating Relevance:</b> $result.generalRatingRelevance<br/>

 <b>Mime Type:</b> $result.mimeType<br/>
 <b>Additional Search Details:</b> $result.additionalSearchDetails<br/>
 <b>Meta Tags Fields:</b> $result.metaTagsFields<br/>