在知識圖譜中搜尋符合限制條件的實體。
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 關鍵字
如果是 @context、@vocab、@type 或 @id 等 JSON-LD 關鍵字,請參閱 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
description -> http://schema.org/description
定義為 Google 結構定義擴充功能的類型和屬性,可透過 http://schema.googleapis.com 展開。例如:
- EntitySearchResult -> http://schema.googleapis.com/EntitySearchResult
- detailDescription -> http://schema.googleapis.com/detailedDescription
您可從對應的 URI 取得各類型和屬性的說明文件。
結構定義擴充功能清單
此 API 中使用的結構定義擴充功能會以 http://schema.googleapis.com 的形式代管,做為外部擴充功能。
Schema.org 的 type 副檔名為:
Schema.org 的 property 副檔名為:
- 詳細資料說明
- 結果分數