在知识图谱中搜索与限制条件匹配的实体。
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 -
例如 resultScore)。
有关这些扩展程序的更多详情,请参阅
架构扩展列表。
对于每种 Schema.org 类型(如 Person)和属性(如
name)具有相应的完整 URI,如以下示例所示:
- 用户 ->http://schema.org/Person
 Thing ->http://schema.org/Thing
名称 ->http://schema.org/name
说明 ->http://schema.org/description
定义为 Google 架构扩展的类型和属性可以 用 http://schema.googleapis.com 扩展。 例如:
- 实体搜索结果 ->http://schema.googleapis.com/EntitySearchResult
 - 详细说明 ->http://schema.googleapis.com/detailedDescription
 
有关每种类型和属性的文档,请访问 相应的 URI。
架构扩展列表
此 API 中使用的架构扩展托管在以下位置: http://schema.googleapis.com 作为外部扩展程序。
Schema.org 的 type 扩展名为:
Schema.org 的 property 扩展包括: