This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Working with Search in Google Custom Search
The search
operation retrieves the details for your search query.
<googlecustomsearch.search> <query>{$ctx:query}</query> <searchType>{$ctx:searchType}</searchType> <exactTerms>{$ctx:exactTerms}</exactTerms> <dateRestrict>{$ctx:dateRestrict}</dateRestrict> <excludeTerms>{$ctx:excludeTerms}</excludeTerms> <filter>{$ctx:filter}</filter> <countryCode>{$ctx:countryCode}</countryCode> <interfaceLanguage>{$ctx:interfaceLanguage}</interfaceLanguage> <appendsQuery>{$ctx:appendsQuery}</appendsQuery> <imgColorType>{$ctx:imgColorType}</imgColorType> <imgDominantColor>{$ctx:imgDominantColor}</imgDominantColor> <imgSize>{$ctx:imgSize}</imgSize> <imgType>{$ctx:imgType}</imgType> <start>{$ctx:start}</start> <sort>{$ctx:sort}</sort> <safe>{$ctx:safe}</safe> <num>{$ctx:num}</num> <languageRestrict>{$ctx:languageRestrict}</languageRestrict> <lowRange>{$ctx:lowRange}</lowRange> <siteSearchFilter>{$ctx:siteSearchFilter}</siteSearchFilter> <relatedSite>{$ctx:relatedSite}</relatedSite> <linkSite>{$ctx:linkSite}</linkSite> <alt>{$ctx:alt}</alt> <countryRestrict>{$ctx:countryRestrict}</countryRestrict> <orTerms>{$ctx:orTerms}</orTerms> <rights>{$ctx:rights}</rights> <fields>{$ctx:fields}</fields> </googlecustomsearch.search>
Properties
- searchType:Â Specifies the search type.
- exactTerms:Â Identifies a phrase that all documents in the search results must contain.
- excludeTerms:Â Identifies a word or phrase that should not appear in any documents in the search results.
dateRestrict: Restricts results to URLs based on date.
filter: Controls turning on or off the duplicate content filter.
countryCode: Geolocation of end user.
interfaceLanguage: Sets the user interface language.
appendsQuery: Appends the specified query terms to the query, as if they were combined with a logical AND operator.
imgColorType: Returns black and white, grayscale, or color images.
imgDominantColor: Returns images of a specific dominant color.
imgSize: Returns images of a specified size.
imgType: Returns images of a type.
start: The index of the first result to return.
sort: The sort expression to apply to the results.
safe: Search safety level.
num: Number of search results to return.
languageRestrict: Restricts the search to documents written in a particular language.
lowRange: Specifies the starting value for a search range.
siteSearchFilter: Controls whether to include or exclude results from the site named in the siteSearch parameter.
relatedSite: Specifies that all search results should be pages that are related to the specified URL.
linkSite: Specifies that all search results should contain a link to a particular URL.
alt: Data format for the response.
countryRestrict: Restricts search results to documents originating in a particular country.
orTerms: Provides additional search terms to check for in a document.
rights: Filters based on licensing.
fields: search only relevant fields.
Sample request
Following is a sample REST/JSON request that can be handled by the search
operation.
{ "query":"annual", "apiKey":"AIzaSyBrMXXXXXmmHUCmjHp", "cseID":"014869045608377880101:18XXXXXrwls", "url":"https://www.googleapis.com/customsearch/v1", "alt":"atom" }
Related Google Custom Search documentation
https://developers.google.com/custom-search/json-api/v1/using_rest
Sample Configuration
Following is a sample proxy service that illustrates how to connect to Google Custom Search with the init
 operation and use the search
operation. The sample request for this proxy can be found in search sample request. You can use this sample as a template for using search operations.
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="googlecustomsearch" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <property name="apiKey" expression="json-eval($.apiKey)"/> <property name="cseID" expression="json-eval($.cseID)"/> <property name="cref" expression="json-eval($.cref)"/> <property name="query" expression="json-eval($.query)"/> <property name="url" expression="json-eval($.url)"/> <property name="searchType" expression="json-eval($.searchType)"/> <property name="exactTerms" expression="json-eval($.exactTerms)"/> <property name="dateRestrict" expression="json-eval($.dateRestrict)"/> <property name="excludeTerms" expression="json-eval($.excludeTerms)"/> <property name="filter" expression="json-eval($.filter)"/> <property name="countryCode" expression="json-eval($.countryCode)"/> <property name="interfaceLanguage" expression="json-eval($.interfaceLanguage)"/> <property name="appendsQuery" expression="json-eval($.appendsQuery)"/> <property name="imgColorType" expression="json-eval($.imgColorType)"/> <property name="imgDominantColor" expression="json-eval($.imgDominantColor)"/> <property name="imgSize" expression="json-eval($.imgSize)"/> <property name="imgType" expression="json-eval($.imgType)"/> <property name="start" expression="json-eval($.start)"/> <property name="sort" expression="json-eval($.sort)"/> <property name="safe" expression="json-eval($.safe)"/> <property name="num" expression="json-eval($.num)"/> <property name="languageRestrict" expression="json-eval($.languageRestrict)"/> <property name="lowRange" expression="json-eval($.lowRange)"/> <property name="siteSearchFilter" expression="json-eval($.siteSearchFilter)"/> <property name="relatedSite" expression="json-eval($.relatedSite)"/> <property name="linkSite" expression="json-eval($.linkSite)"/> <property name="alt" expression="json-eval($.alt)"/> <property name="countryRestrict" expression="json-eval($.countryRestrict)"/> <property name="orTerms" expression="json-eval($.orTerms)"/> <property name="rights" expression="json-eval($.rights)"/> <property name="fields" expression="json-eval($.fields)"/> <googlecustomsearch.init> <apiKey>{$ctx:apiKey}</apiKey> <cref>{$ctx:cref}</cref> <cseID>{$ctx:cseID}</cseID> <url>{$ctx:url}</url> </googlecustomsearch.init> <googlecustomsearch.search> <query>{$ctx:query}</query> <searchType>{$ctx:searchType}</searchType> <exactTerms>{$ctx:exactTerms}</exactTerms> <dateRestrict>{$ctx:dateRestrict}</dateRestrict> <excludeTerms>{$ctx:excludeTerms}</excludeTerms> <filter>{$ctx:filter}</filter> <countryCode>{$ctx:countryCode}</countryCode> <interfaceLanguage>{$ctx:interfaceLanguage}</interfaceLanguage> <appendsQuery>{$ctx:appendsQuery}</appendsQuery> <imgColorType>{$ctx:imgColorType}</imgColorType> <imgDominantColor>{$ctx:imgDominantColor}</imgDominantColor> <imgSize>{$ctx:imgSize}</imgSize> <imgType>{$ctx:imgType}</imgType> <start>{$ctx:start}</start> <sort>{$ctx:sort}</sort> <safe>{$ctx:safe}</safe> <num>{$ctx:num}</num> <languageRestrict>{$ctx:languageRestrict}</languageRestrict> <lowRange>{$ctx:lowRange}</lowRange> <siteSearchFilter>{$ctx:siteSearchFilter}</siteSearchFilter> <relatedSite>{$ctx:relatedSite}</relatedSite> <linkSite>{$ctx:linkSite}</linkSite> <alt>{$ctx:alt}</alt> <countryRestrict>{$ctx:countryRestrict}</countryRestrict> <orTerms>{$ctx:orTerms}</orTerms> <rights>{$ctx:rights}</rights> <fields>{$ctx:fields}</fields> </googlecustomsearch.search> <respond/> </inSequence> <outSequence> <log/> <send/> </outSequence> </target> <description/> </proxy>