This page describes how to define your search engine specifications using a context file.
Overview
A context file describes the structure of your search engine and defines its behavior. The best way to start learning about context files is by viewing a simple example. As you build your confidence, you might want to start experimenting with various elements and attributes. You can play with the settings in the Control Panel, and then view the generated XML version in the Advanced tab.
The following code describes a search engine for climate change. Note that this search engine has image search enabled.
<CustomSearchEngine keywords="climate "global warming" "greenhouse gases"" language="en" encoding="UTF-8"> <Title>RealClimate</Title> <Description>Science behind global warming and climate change.</Description> <Context> <BackgroundLabels> <Label name="_cse_hwbuiarvsbo" mode="FILTER"/> <Label name="_cse_exclude_hwbuiarvsbo" mode="ELIMINATE"/> </BackgroundLabels> </Context> <LookAndFeel nonprofit="false"/> <ImageSearchSettings enable="true" layout="1" /> </CustomSearchEngine>
CustomSearchEngine elements
A basic context file includes the following main elements and child elements.
Element | Required | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
CustomSearchEngine |
Required | Encloses all information about the search engine. Has the following attributes:
|
||||||||
Title |
Required | The name of your search engine. It appears on your Programmable Search Engine homepage and the result pages. | ||||||||
Description |
Required | The descriptive text that appears in your search engine homepage. | ||||||||
Context |
Required | Holds information about labels. Includes the child elements BackgroundLabels and Facet . |
||||||||
BackgroundLabels |
Optional | Container for labels used to promote, include, or excludes sites and pages. Includes one or more child Label elements. |
||||||||
Label |
Optional | Label used to promote sites or determine inclusion/exclusion of sites. Has the following attributes:
|
||||||||
LookAndFeel |
Required | Determines whether your search results show ads and controls the look and feel of your search engine. It has multiple attributes and child elements that are described in detail in the Look and Feel page.
Only qualifying non-profit organizations, educational institutions, or government agencies may use a free Programmable Search Engine without ads. The element has one attribute,
|
||||||||
AdSense |
Optional | Associates the search engine with your AdSense account. Make money with your Programmable Search Engine by connecting it with your Google AdSense account. When users click on an ad in your search results, you get a share of the ad revenue. If you already have an existing AdSense account, do not create a new one, even if you create multiple search engines. Google automatically associates your search engines with the same AdSense account. Creating another AdSense account might result in the termination of your AdSense account. | ||||||||
ImageSearchSettings |
Optional | Specifies if Image Search is enabled. Has the following attributes:
|