背景資訊:定義程式化搜尋引擎
本頁說明如何使用內容檔案定義搜尋引擎規格。
- 總覽
- 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 |
必填 |
包含搜尋引擎的所有相關資訊。具備下列屬性:
keywords 。指定與搜尋引擎相關聯的清單 (最長 100 個半形字元)。如未指定,程式化搜尋引擎會使用空白值。
language 。指定在使用者介面中顯示的支援語言。指定語言可增加該語言的搜尋結果,但不會篩除其他語言的結果。如未指定,程式化搜尋引擎會使用 en (英文)。如果值為空值,程式化搜尋引擎會使用使用者的語言代碼。
autocompletions 。指出程式化搜尋引擎是否應為您的搜尋引擎產生 GLOSSARY 自動完成建議。允許的值為 true 或 false 。如果設為 true ,則請注意,系統可能需要數小時才能產生自動完成建議。設定這個值後,您必須修改搜尋框程式碼,才能要求自動完成建議。您可以在控制台的 [取得程式碼] 分頁中取得更新的程式碼。只有搜尋引擎包含網站的搜尋引擎 (預先決定的網站集合) 才能提供自動完成查詢。
|
Title |
必填 |
搜尋引擎的名稱。內容會顯示在您的程式化搜尋引擎首頁和結果頁面上。
|
Description |
必填 |
搜尋引擎總覽網頁中顯示的說明文字。
|
Context |
必填 |
保留標籤相關資訊。包含子元素 BackgroundLabels 和 Facet 。 |
BackgroundLabels |
選用 |
用來宣傳、納入或排除網站和網頁的標籤容器。包含一或多個子項 Label 元素。 |
Label |
選用 |
用來宣傳網站或確定包含/排除網站的標籤。具備下列屬性:
name 。標籤名稱。
mode 。FILTER (宣傳或只顯示首選網站) 或 ELIMINATE (不含網站)。您也可以視需要自訂這些標籤。
|
LookAndFeel |
必填 |
控制搜尋引擎的外觀和風格。其中含有多項屬性和子元素,詳細說明請參閱「外觀與風格」頁面。
|
ImageSearchSettings |
選用 |
指定是否啟用「圖片搜尋」。具備下列屬性:
enable 。指定是否要為這個搜尋引擎啟用圖片搜尋功能。允許的值為 true 或 false 。
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-09-12 (世界標準時間)。
[null,null,["上次更新時間: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."]]],[]]