Google Knowledge Graph Search API

このクイックスタートでは、Google Knowledge Graph Search API について説明します。このクイックスタートでは、API を使用して Google ナレッジグラフでエンティティを検索またはルックアップします。

新しいプロジェクトを計画している場合は、Cloud Knowledge Graph Advanced エディションでアプリケーションをビルドして、新しい機能と改善されたサービスを利用してください。Basic エディションは引き続き利用できますが、新機能、高い QPS、追加のセキュリティとコンプライアンス基準はサポートされません。

Cloud Knowledge Graph エンティティを検索する

次のサンプルは、ナレッジグラフに対してエンティティを検索する方法を示しています。

詳細

REST

Advanced エディションのナレッジグラフを検索するには、projects.locations.cloudKnowledgeGraphEntities.search メソッドを呼び出します。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_ID: 実際の Google Cloud プロジェクト ID。
  • LOCATION: ナレッジグラフのロケーション。
    • オプション: global - グローバル エンドポイント
  • SEARCH_QUERY: 検索用のリテラル クエリ文字列。
  • LANGUAGES: (省略可)クエリの実行に使用する言語コード(ISO 693 で定義)のリスト。指定しない場合、デフォルト値は en です。
  • TYPES:(省略可)`https://schema.org` で定義されているこれらのタイプで、返されるエンティティを制限します。複数のタイプが指定されている場合、返されるエンティティにはこれらのタイプの 1 つ以上が含まれます。デフォルト値は空で、型制限のないエンティティが返されます。サポートされているタイプについては、Schema.org の完全な階層をご覧ください。
  • LIMIT:(省略可)返されるエンティティの数を制限します。デフォルトは 20 です。

HTTP メソッドと URL:

GET https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/cloudKnowledgeGraphEntities:Search?query=SEARCH_QUERY&limit=LIMIT

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

次のコマンドを実行します。

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/cloudKnowledgeGraphEntities:Search?query=SEARCH_QUERY&limit=LIMIT"

PowerShell

次のコマンドを実行します。

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/cloudKnowledgeGraphEntities:Search?query=SEARCH_QUERY&limit=LIMIT" | Select-Object -Expand Content

レスポンスには、JSON-LD 形式で表され、外部拡張機能が制限された schema.org スキーマと互換性があるエンティティのリストが含まれます。

レスポンス構造の詳細については、エンティティ レスポンス構造をご覧ください。

次の JSON-LD の例は、レスポンス本文の構造を示しています。

{
  "@context": {
    "@vocab": "http://schema.org/"
  },
  "@type": "ItemList",
  "itemListElement": [
    {
      "result": {
        "@id": "c-07xuup16g",
        "name": "Stanford University",
        "description": "Private university in Stanford, California",
        "detailedDescription": {
          "articleBody": "Stanford University, officially Leland Stanford Junior University, is a private research university in Stanford, California. The campus occupies 8,180 acres, among the largest in the United States, and enrolls over 17,000 students. ",
          "url": "https://en.wikipedia.org/wiki/Stanford_University",
          "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
        },
        "url": "http://www.stanford.edu/",
        "image": {
          "contentUrl": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTfPPf-ker0y_892m1wu8-U89furQgQ67foDFncY3r9sREpeWxV",
          "url": "https://es.wikipedia.org/wiki/Archivo:Logo_of_Stanford_University.png"
        },
        "identifier": [
          {
            "@type": "PropertyValue",
            "propertyID": "googleKgMID",
            "value": "/m/06pwq"
          },
          {
            "@type": "PropertyValue",
            "propertyID": "googlePlaceID",
            "value": "ChIJneqLZyq7j4ARf2j8RBrwzSk"
          },
          {
            "@type": "PropertyValue",
            "propertyID": "wikidataQID",
            "value": "Q41506"
          }
        ],
        "@type": [
          "Place",
          "Organization",
          "MovieTheater",
          "Corporation",
          "EducationalOrganization",
          "Thing",
          "CollegeOrUniversity"
        ]
      }
    }
  ]
}

Python

詳細については、Enterprise Knowledge Graph Python API リファレンス ドキュメントをご覧ください。

Enterprise Knowledge Graph に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。


from __future__ import annotations

from collections.abc import Sequence

from google.cloud import enterpriseknowledgegraph as ekg

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
# location = 'YOUR_GRAPH_LOCATION'      # Values: 'global'
# search_query = 'YOUR_SEARCH_QUERY'
# languages = ['en']                    # Optional: List of ISO 639-1 Codes
# types = ['']                          # Optional: List of schema.org types to return
# limit = 20                            # Optional: Number of entities to return


def search_sample(
    project_id: str,
    location: str,
    search_query: str,
    languages: Sequence[str] = None,
    types: Sequence[str] = None,
    limit: int = 20,
):
    # Create a client
    client = ekg.EnterpriseKnowledgeGraphServiceClient()

    # The full resource name of the location
    # e.g. projects/{project_id}/locations/{location}
    parent = client.common_location_path(project=project_id, location=location)

    # Initialize request argument(s)
    request = ekg.SearchRequest(
        parent=parent,
        query=search_query,
        languages=languages,
        types=types,
        limit=limit,
    )

    # Make the request
    response = client.search(request=request)

    print(f"Search Query: {search_query}\n")

    # Extract and print date from response
    for item in response.item_list_element:
        result = item.get("result")

        print(f"Name: {result.get('name')}")
        print(f"- Description: {result.get('description')}")
        print(f"- Types: {result.get('@type')}\n")

        detailed_description = result.get("detailedDescription")

        if detailed_description:
            print("- Detailed Description:")
            print(f"\t- Article Body: {detailed_description.get('articleBody')}")
            print(f"\t- URL: {detailed_description.get('url')}")
            print(f"\t- License: {detailed_description.get('license')}\n")

        print(f"- Cloud MID: {result.get('@id')}")
        for identifier in result.get("identifier"):
            print(f"\t- {identifier.get('name')}: {identifier.get('value')}")

        print("\n")

基本

REST

Basic エディションのナレッジグラフを検索するには、projects.locations.publicKnowledgeGraphEntities.search メソッドを呼び出します。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_ID: 実際の Google Cloud プロジェクト ID。
  • LOCATION: ナレッジグラフのロケーション。
    • オプション: global - グローバル エンドポイント
  • SEARCH_QUERY: 検索用のリテラル クエリ文字列。
  • LANGUAGES: (省略可)クエリの実行に使用する言語コード(ISO 693 で定義)のリスト。指定しない場合、デフォルト値は en です。
  • TYPES:(省略可)`https://schema.org` で定義されているこれらのタイプで、返されるエンティティを制限します。複数のタイプが指定されている場合、返されるエンティティにはこれらのタイプの 1 つ以上が含まれます。デフォルト値は空で、型制限のないエンティティが返されます。サポートされているタイプについては、Schema.org の完全な階層をご覧ください。
  • LIMIT:(省略可)返されるエンティティの数を制限します。デフォルトは 20 です。

HTTP メソッドと URL:

GET https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publicKnowledgeGraphEntities:Search?query=SEARCH_QUERY&limit=LIMIT

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

次のコマンドを実行します。

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publicKnowledgeGraphEntities:Search?query=SEARCH_QUERY&limit=LIMIT"

PowerShell

次のコマンドを実行します。

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publicKnowledgeGraphEntities:Search?query=SEARCH_QUERY&limit=LIMIT" | Select-Object -Expand Content

レスポンスには、JSON-LD 形式で表され、外部拡張機能が制限された schema.org スキーマと互換性があるエンティティのリストが含まれます。

レスポンス構造の詳細については、エンティティ レスポンス構造をご覧ください。

次の JSON-LD の例は、レスポンス本文の構造を示しています。

{
  "@context": {
    "@vocab": "http://schema.org/"
  },
  "@type": "ItemList",
  "itemListElement": [
    {
      "result": {
        "@id": "c-07xuup16g",
        "name": "Stanford University",
        "description": "Private university in Stanford, California",
        "detailedDescription": {
          "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License",
          "url": "https://en.wikipedia.org/wiki/Stanford_University",
          "articleBody": "Stanford University, officially Leland Stanford Junior University, is a private research university in Stanford, California. The campus occupies 8,180 acres, among the largest in the United States, and enrolls over 17,000 students. "
        },
        "url": "http://www.stanford.edu/",
        "identifier": [
          {
            "@type": "PropertyValue",
            "propertyID": "googleKgMID",
            "value": "/m/06pwq"
          }
        ],
        "image": {
          "contentUrl": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTfPPf-ker0y_892m1wu8-U89furQgQ67foDFncY3r9sREpeWxV",
          "url": "https://es.wikipedia.org/wiki/Archivo:Logo_of_Stanford_University.png"
        },
        "@type": [
          "EducationalOrganization",
          "CollegeOrUniversity",
          "Thing",
          "Place",
          "Corporation",
          "MovieTheater",
          "Organization"
        ]
      }
    }
  ]
}

Python

詳細については、Enterprise Knowledge Graph Python API リファレンス ドキュメントをご覧ください。

Enterprise Knowledge Graph に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。


from __future__ import annotations

from collections.abc import Sequence

from google.cloud import enterpriseknowledgegraph as ekg

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
# location = 'YOUR_GRAPH_LOCATION'      # Values: 'global'
# search_query = 'YOUR_SEARCH_QUERY'
# languages = ['en']                    # Optional: List of ISO 639-1 Codes
# types = ['']                          # Optional: List of schema.org types to return
# limit = 20                            # Optional: Number of entities to return


def search_public_kg_sample(
    project_id: str,
    location: str,
    search_query: str,
    languages: Sequence[str] = None,
    types: Sequence[str] = None,
    limit: int = 20,
):
    # Create a client
    client = ekg.EnterpriseKnowledgeGraphServiceClient()

    # The full resource name of the location
    # e.g. projects/{project_id}/locations/{location}
    parent = client.common_location_path(project=project_id, location=location)

    # Initialize request argument(s)
    request = ekg.SearchPublicKgRequest(
        parent=parent,
        query=search_query,
        languages=languages,
        types=types,
        limit=limit,
    )

    # Make the request
    response = client.search_public_kg(request=request)

    print(f"Search Query: {search_query}\n")

    # Extract and print date from response
    for item in response.item_list_element:
        result = item.get("result")

        print(f"Name: {result.get('name')}")
        print(f"- Description: {result.get('description')}")
        print(f"- Types: {result.get('@type')}\n")

        detailed_description = result.get("detailedDescription")

        if detailed_description:
            print("- Detailed Description:")
            print(f"\t- Article Body: {detailed_description.get('articleBody')}")
            print(f"\t- URL: {detailed_description.get('url')}")
            print(f"\t- License: {detailed_description.get('license')}\n")

        print(f"- Cloud MID: {result.get('@id')}")
        for identifier in result.get("identifier"):
            print(f"\t- {identifier.get('name')}: {identifier.get('value')}")

        print("\n")

Cloud Knowledge Graph MID からエンティティを検索する

Google Knowledge Graph Search API に、プロダクトやアプリケーションの統合を容易にする新しいマシン ID(MID)形式が導入されました。lookup API は、新しい Cloud Knowledge Graph MID(c- で始まる)と Google Knowledge Graph MID(/m で始まる)の両方で機能します。

詳細

REST

Advanced エディションで MID でエンティティを検索するには、projects.locations.cloudKnowledgeGraphEntities.lookup メソッドを呼び出します。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_ID: 実際の Google Cloud プロジェクト ID。
  • LOCATION: ナレッジグラフのロケーション。
    • オプション: global - グローバル エンドポイント
  • LOOKUP_IDS: ルックアップに使用するエンティティ ID のリスト。
    • 例: /m/0dl567
  • LANGUAGES: (省略可)クエリの実行に使用する言語コード(ISO 693 で定義)のリスト。指定しない場合、デフォルト値は en です。

HTTP メソッドと URL:

GET https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/cloudKnowledgeGraphEntities:Lookup?ids=LOOKUP_IDS

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

次のコマンドを実行します。

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/cloudKnowledgeGraphEntities:Lookup?ids=LOOKUP_IDS"

PowerShell

次のコマンドを実行します。

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/cloudKnowledgeGraphEntities:Lookup?ids=LOOKUP_IDS" | Select-Object -Expand Content

レスポンスには、JSON-LD 形式で表され、外部拡張機能が制限された schema.org スキーマと互換性があるエンティティのリストが含まれます。

レスポンス構造の詳細については、エンティティ レスポンス構造をご覧ください。

次の JSON-LD の例は、レスポンス本文の構造を示しています。

{
  "@context": {
    "@vocab": "http://schema.org/"
  },
  "@type": "ItemList",
  "itemListElement": [
    {
      "result": {
        "description": "American singer-songwriter",
        "@type": [
          "Person",
          "Thing"
        ],
        "name": "Taylor Swift",
        "@id": "c-0260160kc",
        "url": "http://www.taylorswift.com/",
        "identifier": [
          {
            "@type": "PropertyValue",
            "propertyID": "googleKgMID",
            "value": "/m/0dl567"
          },
          {
            "@type": "PropertyValue",
            "propertyID": "wikidataQID",
            "value": "Q26876"
          }
        ],
        "detailedDescription": {
          "articleBody": "Taylor Alison Swift is an American singer-songwriter. Her discography spans multiple genres and her narrative songwriting—often inspired by her personal life—has received critical praise and widespread media coverage. ",
          "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License",
          "url": "https://en.wikipedia.org/wiki/Taylor_Swift"
        },
        "image": {
          "contentUrl": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSnsjOArwgD-bhyRslj_Qa7Z2tIPLRFU3VnEuLr1ybcyned49Pt",
          "url": "https://pt.wikipedia.org/wiki/Ficheiro:191125_Taylor_Swift_at_the_2019_American_Music_Awards_(cropped).png"
        }
      }
    }
  ]
}
Cloud Knowledge Graph から複数のエンティティを検索するには、複数の ID を指定します。URL は次のようになります。
https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/cloudKnowledgeGraphEntities:Lookup?ids=LOOKUP_IDS&ids=LOOKUP_IDS

Python

詳細については、Enterprise Knowledge Graph Python API リファレンス ドキュメントをご覧ください。

Enterprise Knowledge Graph に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。


from __future__ import annotations

from collections.abc import Sequence

from google.cloud import enterpriseknowledgegraph as ekg

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
# location = 'YOUR_GRAPH_LOCATION'      # Values: 'global'
# ids = ['YOUR_LOOKUP_MID']             # https://cloud.google.com/enterprise-knowledge-graph/docs/mid
# languages = ['en']                    # Optional: List of ISO 639-1 Codes


def lookup_sample(
    project_id: str,
    location: str,
    ids: Sequence[str],
    languages: Sequence[str] = None,
):
    # Create a client
    client = ekg.EnterpriseKnowledgeGraphServiceClient()

    # The full resource name of the location
    # e.g. projects/{project_id}/locations/{location}
    parent = client.common_location_path(project=project_id, location=location)

    # Initialize request argument(s)
    request = ekg.LookupRequest(
        parent=parent,
        ids=ids,
        languages=languages,
    )

    # Make the request
    response = client.lookup(request=request)

    print(f"Lookup IDs: {ids}\n")

    print(response)

    # Extract and print date from response
    for item in response.item_list_element:
        result = item.get("result")

        print(f"Name: {result.get('name')}")
        print(f"- Description: {result.get('description')}")
        print(f"- Types: {result.get('@type')}\n")

        detailed_description = result.get("detailedDescription")

        if detailed_description:
            print("- Detailed Description:")
            print(f"\t- Article Body: {detailed_description.get('articleBody')}")
            print(f"\t- URL: {detailed_description.get('url')}")
            print(f"\t- License: {detailed_description.get('license')}\n")

        print(f"- Cloud MID: {result.get('@id')}")
        for identifier in result.get("identifier"):
            print(f"\t- {identifier.get('name')}: {identifier.get('value')}")

        print("\n")

基本

REST

Basic エディションで MID でエンティティを検索するには、projects.locations.publicKnowledgeGraphEntities.lookup メソッドを呼び出します。

リクエストのデータを使用する前に、次のように置き換えます。

  • PROJECT_ID: 実際の Google Cloud プロジェクト ID。
  • LOCATION: ナレッジグラフのロケーション。
    • オプション: global - グローバル エンドポイント
  • LOOKUP_IDS: ルックアップに使用するエンティティ ID のリスト。
    • 例: /m/0dl567
  • LANGUAGES: (省略可)クエリの実行に使用する言語コード(ISO 693 で定義)のリスト。指定しない場合、デフォルト値は en です。

HTTP メソッドと URL:

GET https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publicKnowledgeGraphEntities:Lookup?ids=LOOKUP_IDS

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

次のコマンドを実行します。

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publicKnowledgeGraphEntities:Lookup?ids=LOOKUP_IDS"

PowerShell

次のコマンドを実行します。

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publicKnowledgeGraphEntities:Lookup?ids=LOOKUP_IDS" | Select-Object -Expand Content

レスポンスには、JSON-LD 形式で表され、外部拡張機能が制限された schema.org スキーマと互換性があるエンティティのリストが含まれます。

レスポンス構造の詳細については、エンティティ レスポンス構造をご覧ください。

次の JSON-LD の例は、レスポンス本文の構造を示しています。

{
  "@context": {
    "@vocab": "http://schema.org/"
  },
  "@type": "ItemList",
  "itemListElement": [
    {
      "result": {
        "description": "American singer-songwriter",
        "@type": [
          "Person",
          "Thing"
        ],
        "name": "Taylor Swift",
        "@id": "c-0260160kc",
        "url": "http://www.taylorswift.com/",
        "identifier": [
          {
            "@type": "PropertyValue",
            "propertyID": "googleKgMID",
            "value": "/m/0dl567"
          }
        ],
        "detailedDescription": {
          "articleBody": "Taylor Alison Swift is an American singer-songwriter. Her discography spans multiple genres and her narrative songwriting—often inspired by her personal life—has received critical praise and widespread media coverage. ",
          "license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License",
          "url": "https://en.wikipedia.org/wiki/Taylor_Swift"
        },
        "image": {
          "contentUrl": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSnsjOArwgD-bhyRslj_Qa7Z2tIPLRFU3VnEuLr1ybcyned49Pt",
          "url": "https://pt.wikipedia.org/wiki/Ficheiro:191125_Taylor_Swift_at_the_2019_American_Music_Awards_(cropped).png"
        }
      }
    }
  ]
}
Cloud Knowledge Graph から複数のエンティティを検索するには、複数の ID を指定します。URL は次のようになります。
https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publicKnowledgeGraphEntities:Lookup?ids=LOOKUP_IDS&ids=LOOKUP_IDS

Python

詳細については、Enterprise Knowledge Graph Python API リファレンス ドキュメントをご覧ください。

Enterprise Knowledge Graph に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。


from __future__ import annotations

from collections.abc import Sequence

from google.cloud import enterpriseknowledgegraph as ekg

# TODO(developer): Uncomment these variables before running the sample.
# project_id = 'YOUR_PROJECT_ID'
# location = 'YOUR_GRAPH_LOCATION'      # Values: 'global'
# ids = ['YOUR_LOOKUP_MID']             # https://cloud.google.com/enterprise-knowledge-graph/docs/mid
# languages = ['en']                    # Optional: List of ISO 639-1 Codes


def lookup_public_kg_sample(
    project_id: str,
    location: str,
    ids: Sequence[str],
    languages: Sequence[str] = None,
):
    # Create a client
    client = ekg.EnterpriseKnowledgeGraphServiceClient()

    # The full resource name of the location
    # e.g. projects/{project_id}/locations/{location}
    parent = client.common_location_path(project=project_id, location=location)

    # Initialize request argument(s)
    request = ekg.LookupPublicKgRequest(
        parent=parent,
        ids=ids,
        languages=languages,
    )

    # Make the request
    response = client.lookup_public_kg(request=request)

    print(f"Lookup IDs: {ids}\n")

    print(response)

    # Extract and print date from response
    for item in response.item_list_element:
        result = item.get("result")

        print(f"Name: {result.get('name')}")
        print(f"- Description: {result.get('description')}")
        print(f"- Types: {result.get('@type')}\n")

        detailed_description = result.get("detailedDescription")

        if detailed_description:
            print("- Detailed Description:")
            print(f"\t- Article Body: {detailed_description.get('articleBody')}")
            print(f"\t- URL: {detailed_description.get('url')}")
            print(f"\t- License: {detailed_description.get('license')}\n")

        print(f"- Cloud MID: {result.get('@id')}")
        for identifier in result.get("identifier"):
            print(f"\t- {identifier.get('name')}: {identifier.get('value')}")

        print("\n")

エンティティの構造

フィールド名 タイプ 説明
@id string エンティティの正規 URI。
name string エンティティの名前。
@type array エンティティに一致する、サポートされている schema.org タイプのリスト。
description string エンティティの簡単な説明。
image URL エンティティの識別に役立つ画像。
detailedDescription string エンティティの詳細な説明。
url URL エンティティの公式ウェブサイトの URL(ある場合)。
identifier array 他のリンクされた ID のリスト(例: WikidataQID)。

JSON-LD のキーワード

次のような JSON-LD キーワードについては、JSON-LD 仕様を参照してください。

Schema.org の互換性

Schema.org の各タイプ(Person など)とプロパティ(name など)には、次の例のように対応する完全な URI があります。

クラス 名前 URI
type Person https://schema.org/Person
type Thing https://schema.org/Thing
プロパティ name https://schema.org/name
プロパティ description https://schema.org/description

スキーマの拡張

この API で使用される型とプロパティは、https://schema.googleapis.com外部拡張機能としてホストされています。

各タイプとプロパティのドキュメントは、対応する URI で確認できます。

クラス 名前 URI
type EntitySearchResult https://schema.googleapis.com/EntitySearchResult
プロパティ detailedDescription https://schema.googleapis.com/detailedDescription

ナレッジグラフ エンティティ

ナレッジグラフには、人、場所、ものなどの現実世界のエンティティを表す数百万のエントリがあります。こうしたエンティティはグラフのノードを形成しています。

Cloud Knowledge Graph に存在する一般的なエンティティ タイプの一部を次に示します。