A context file (cse.xml), specifies the global settings of the search engine, such as whether Image Search or promotions are enabled - developers.google.com ![]()
In the Control Panel, these settings are defined in the Basics, Refinements, Look and feel, Admin accounts, and Make money tabs.
A context file describes the structure of your search engine and defines its behavior - developers.google.com ![]()
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 Search 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> <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>
# Longer Example
As the following example shows, refinement labels are defined using Facet elements within the Context section.
<CustomSearchEngine> <Title>Universities</Title> <Context> <Facet> <FacetItem title="Lectures"> <Label name="lectures" mode="BOOST" weight="0.8"> <Rewrite>lecture OR lectures</Rewrite> </Label> </FacetItem> </Facet> <Facet> <FacetItem title="Assignments"> <Label name="assignments" mode="BOOST" weight="0.8"> <Rewrite>homework OR assignment OR assignments</Rewrite> </Label> </FacetItem> </Facet> <Facet> <FacetItem title="Reference"> <Label name="reference" mode="FILTER"> <IgnoreBackgroundLabels>true</IgnoreBackgroundLabels> </Label> </FacetItem> </Facet> <Facet> <FacetItem title="Papers"> <Label name="papers" mode="FILTER"/> <Redirect url="http://scholar.google.com/scholar?q=$q"/> </FacetItem> </Facet> <BackgroundLabels> <Label name="_cse_omuauf_lfve" mode="FILTER"/> <Label name="_cse_exclude_omuauf_lfve" mode="ELIMINATE"/> </BackgroundLabels> </Context> </CustomSearchEngine>