上下文:定义可编程搜索引擎
本页介绍了如何使用上下文文件定义搜索引擎规范。
- 概览
- CustomSearchEngine 元素
概览
上下文文件描述搜索引擎的结构并定义其行为。若要开始了解上下文文件,最好的方法是查看一个简单的示例。建立自信后,您可能希望开始尝试各种元素和属性。您可以调整控制台中的设置,然后查看从概览页下载的生成的 XML 版本。
以下代码描述了一个用于查找气候变化的搜索引擎。请注意,此搜索引擎已启用图片搜索。
<CustomSearchEngine keywords="climate "global warming" "greenhouse gases""
language="en">
<Title>RealClimate</Title>
<Description>Science behind global warming and climate change.</Description>
<Context>
<BackgroundLabels>
<Label name="_include_" mode="FILTER"/>
<Label name="_exclude_" mode="ELIMINATE"/>
</BackgroundLabels>
</Context>
<LookAndFeel/>
<ImageSearchSettings enable="true"/>
</CustomSearchEngine>
CustomSearchEngine 元素
基本上下文文件包含以下主要元素和子元素。
元素 |
必填 |
说明 |
CustomSearchEngine |
必填 |
包含相应搜索引擎的所有相关信息。具有以下属性:
<ph type="x-smartling-placeholder"></ph>
keywords 。指定与搜索引擎相关联的一系列以空格分隔的关键字(最多 100 个字符)。如果未指定,可编程搜索引擎将使用空值。
language 。指定要在界面中显示的支持的语言之一。指定某种语言会提升该语言的结果,但不会过滤掉其他语言的结果。如果未指定,可编程搜索引擎将使用 en (英语)。如果值为 null,可编程搜索引擎将使用您用户的语言区域的语言。
autocompletions 。指示可编程搜索引擎是否应为您的搜索引擎生成词汇表自动补全项。允许的值为 true 或 false 。如果为 true ,则请注意,生成自动补全内容可能需要几个小时的时间。设置此值后,您必须修改搜索框代码才能请求自动补全。您可以从控制台的获取代码标签页中获取更新后的代码。只有搜索包含的网站(预先确定的网站集合)的搜索引擎才能使用自动补全的查询。
|
Title |
必填 |
您的搜索引擎的名称。它会显示在您的可编程搜索引擎首页和结果页中。
|
Description |
必填 |
显示在搜索引擎概览页中的描述性文字。
|
Context |
必填 |
存放有关标签的信息。包含子元素 BackgroundLabels 和 Facet 。 |
BackgroundLabels |
可选 |
用于存储用于宣传、包含或排除网站和网页的标签的容器。包含一个或多个 Label 子元素。 |
Label |
可选 |
用于宣传网站或决定包含/排除网站的标签。具有以下属性:
<ph type="x-smartling-placeholder"></ph>
name 。标签名称。
mode 。FILTER (宣传或仅显示首选网站)或 ELIMINATE (排除网站)。您可以根据需要自定义这些标签。
|
LookAndFeel |
必填 |
控制搜索引擎的外观和风格。它包含多个属性和子元素,外观和风格页面中将详细介绍这些元素和子元素。
|
ImageSearchSettings |
可选 |
指定是否启用图片搜索。具有以下属性:
enable 。指定是否为此搜索引擎启用图片搜索。允许的值为 true 或 false 。
|
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-09-12。
[null,null,["最后更新时间 (UTC):2024-09-12。"],[[["Custom Search Ads are customized using parameters categorized by their scope: Page Level, Configuration Settings, and Unit Level."],["Page Level parameters, such as `pubId` and `query`, manage ad behavior across the entire page while Unit Level parameters control individual ad units using attributes like `container` and `width`."],["Configuration settings provide control over aspects like ad filtering (`adsafe`), testing (`adtest`), and language targeting (`hl`)."],["Optional parameters offer further customization, such as defining ad click behavior (`linkTarget`), handling ad loading events (`adLoadedCallback`), and specifying the number of ads to display (`number`)."],["Parameters like `relatedSearchTargeting` and `terms` enable the implementation of related searches, enhancing the user experience by providing relevant content suggestions."]]],[]]