透過知識圖譜搜尋符合限制的實體。
HTTP 要求
GET https://kgsearch.googleapis.com/v1/entities:search
查詢參數
參數名稱 | 類型 | 說明 |
---|---|---|
query |
string |
要在知識圖譜中搜尋的常值字串。 |
ids |
string |
要在知識圖譜中搜尋的實體 ID 清單。如要在 HTTP 要求中指定多個 ID,請在網址中重複參數,如 ...?ids=A&ids=B。 |
languages |
string |
用來執行查詢的語言代碼清單 (以 ISO 639 定義),例如「en」。 |
types |
string |
限制系統只傳回指定類型的實體。例如,您可以指定「Person」(如 http://schema.org/Person 所定義) 將結果限制在代表人員的實體。如果指定多種類型,傳回的實體會包含一或多個這些類型。 |
indent |
boolean |
啟用 JSON 結果縮排。 |
prefix |
boolean |
啟用前置字串 (初始子字串) 比對實體名稱和別名。舉例來說,前置字串「Jung」會比對實體和別名,例如「Jung」、「Jungle」和「Jung-ho Kang」。 |
limit |
number |
限制要傳回的實體數量。上限為 500。預設值為 20。高限制的要求較有可能逾時。 |
要求主體
要求主體必須為空白。
回應主體
回應訊息會包含以 JSON-LD 格式呈現的實體清單,並與 schema.org 結構定義相容 (具有有限的外部擴充功能)。
以下 JSON-LD 範例說明回應主體的結構:
{
"@context": {
"@vocab": "http://schema.org/",
"goog": "http://schema.googleapis.com/",
"resultScore": "goog:resultScore",
"detailedDescription": "goog:detailedDescription",
"EntitySearchResult": "goog:EntitySearchResult",
"kg": "http://g.co/kg"
},
"@type": "ItemList",
"itemListElement": [
{
"@type": "EntitySearchResult",
"result": {
"@id": "kg:/m/0dl567",
"name": "Taylor Swift",
"@type": [
"Thing",
"Person"
],
"description": "Singer-songwriter",
"image": {
"contentUrl": "https://t1.gstatic.com/images?q=tbn:ANd9GcQmVDAhjhWnN2OWys2ZMO3PGAhupp5tN2LwF_BJmiHgi19hf8Ku",
"url": "https://en.wikipedia.org/wiki/Taylor_Swift",
"license": "http://creativecommons.org/licenses/by-sa/2.0"
},
"detailedDescription": {
"articleBody": "Taylor Alison Swift is an American singer-songwriter and actress. Raised in Wyomissing, Pennsylvania, she moved to Nashville, Tennessee, at the age of 14 to pursue a career in country music. ",
"url": "http://en.wikipedia.org/wiki/Taylor_Swift",
"license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
},
"url": "http://taylorswift.com/"
},
"resultScore": 4850
}
]
}
回覆欄位
欄位名稱 | 類型 | 說明 |
---|---|---|
@id |
string |
實體的標準 URI。 |
name |
string |
實體的名稱。 |
@type |
array |
列出與實體相符的支援 schema.org 類型清單。 |
description |
string |
實體的簡短說明。 |
image |
URL |
有助於識別實體的圖片。 |
detailedDescription |
string |
實體的詳細說明。 |
url |
URL |
實體的官方網站網址 (如果有的話)。 |
resultScore |
number |
顯示實體與要求限制條件的相符程度的指標。 |
JSON-LD 關鍵字
JSON-LD 關鍵字 (例如 @context、@vocab、@type 或 @id),請參閱 JSON-LD 規格。
schema.org 相容性
回應使用在 schema.org 託管的詞彙,具有與 schema.org 詞彙相容的有限副檔名 (例如 resultScore
)。如要進一步瞭解這些擴充功能,請參閱結構定義擴充功能清單。
每個 Schema.org 類型 (例如 Person
) 和屬性 (例如 name
) 都有對應的完整 URI,如以下範例所示:
- 人員 -> http://schema.org/Person
內容 -> http://schema.org/Thing
名稱 -> http://schema.org/name
說明 -> http://schema.org/description
定義為 Google 結構定義擴充功能的類型和屬性,可以使用 http://schema.googleapis.com 加以擴充。例如:
- EntitySearchResult -> http://schema.googleapis.com/EntitySearchResult
- 如需詳細說明 -> http://schema.googleapis.com/detailedDescription
每種類型和屬性的說明文件均位於對應的 URI。
結構定義擴充功能清單
這個 API 中使用的結構定義擴充功能是以外部擴充功能的形式託管在 http://schema.googleapis.com。
Schema.org 的 type 副檔名如下:
Schema.org 的 property 擴充功能為: