### Lookup Cloud Knowledge Graph Entities using curl Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api This example shows how to look up entities by MID using a curl command. It assumes you are authenticated with the gcloud CLI. The command constructs a GET request to the Knowledge Graph API, including an authorization token and the entity IDs for lookup. ```bash 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" ``` -------------------------------- ### Install Enterprise Knowledge Graph Client Library for Python Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/libraries Installs or upgrades the Google Cloud Enterprise Knowledge Graph client library for Python using pip. This is the first step to using the library in your Python projects. ```bash pip install --upgrade google-cloud-enterpriseknowledgegraph ``` -------------------------------- ### v1.projects.locations.entityReconciliationJobs Get Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest_hl=zh-tw Gets a EntityReconciliationJob. ```APIDOC ## GET /v1/{name} ### Description Gets a EntityReconciliationJob. ### Method GET ### Endpoint /v1/{name} ### Parameters #### Path Parameters - **name** (string) - Required - ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **example** (object) - Description of the response body #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Initialize Google Cloud CLI Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/libraries Initializes the Google Cloud CLI, a tool for managing Google Cloud resources. This command is part of the authentication setup for local development environments. ```bash gcloud init ``` -------------------------------- ### POST /v1/{parent}/entityReconciliationJobs Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.entityReconciliationJobs/create_hl=es-419 Creates an EntityReconciliationJob. Once created, the job will immediately attempt to start. ```APIDOC ## POST /v1/{parent}/entityReconciliationJobs ### Description Creates an EntityReconciliationJob. A EntityReconciliationJob once created will right away be attempted to start. ### Method POST ### Endpoint `https://enterpriseknowledgegraph.googleapis.com/v1/{parent}/entityReconciliationJobs` ### Parameters #### Path Parameters - **parent** (string) - Required - The resource name of the Location to create the EntityReconciliationJob in. Format: `projects/{project}/locations/{location}`. It takes the form `projects/{project}/locations/{location}`. #### Request Body The request body contains an instance of `EntityReconciliationJob`. ### Response #### Success Response (200) If successful, the response body contains a newly created instance of `EntityReconciliationJob`. ### Authorization Scopes Requires the following OAuth scope: * `https://www.googleapis.com/auth/cloud-platform` ### IAM Permissions Requires the following IAM permission on the `parent` resource: * `enterpriseknowledgegraph.entityReconciliationJobs.create` ``` -------------------------------- ### Map Organization Schema with Static Source Name Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/entity-reconciliation-console This example demonstrates mapping an 'organization' entity where the source name is a static string ('org') instead of a dynamic value from the source table. It maps to a BigQuery source and includes standard schema.org and EKG recon properties. ```yaml prefixes: ekg: http://cloud.google.com/ekg/0.0.1# schema: https://schema.org/ mappings: organization: sources: - [ekg-api-test:demo.organization~bigquery] s: ekg:company_$(source_key) po: - [a, schema:Organization] - [schema:name, $(source_name)] - [schema:streetAddress, $(street)] - [schema:postalCode, $(postal_code)] - [schema:addressCountry, $(country)] - [schema:addressLocality, $(city)] - [schema:addressRegion, $(state)] - [ekg:recon.source_name, (org)] - [ekg:recon.source_key, $(primary_key)] ``` -------------------------------- ### Lookup Cloud Knowledge Graph Entities using PowerShell Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api This PowerShell script demonstrates how to look up entities by MID. It retrieves an access token using gcloud and then makes a GET request to the Knowledge Graph API with the necessary headers and URI, expanding the content of the response. ```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 ``` -------------------------------- ### GET /v1/{name} Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.entityReconciliationJobs/get_hl=es Retrieves a specific EntityReconciliationJob resource by its unique name. ```APIDOC ## GET /v1/{name} ### Description Gets a specific EntityReconciliationJob resource. ### Method GET ### Endpoint `https://enterpriseknowledgegraph.googleapis.com/v1/{name}` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the EntityReconciliationJob resource. Format: `projects/{project}/locations/{location}/entityReconciliationJobs/{entityReconciliationJob}` #### Query Parameters None #### Request Body The request body must be empty. ### Request Example (No request body for this GET request) ### Response #### Success Response (200) - **EntityReconciliationJob** (object) - An instance of the EntityReconciliationJob resource. #### Response Example ```json { "name": "projects/your-project/locations/your-location/entityReconciliationJobs/your-job-id", "state": "SUCCEEDED", "createTime": "2023-10-27T10:00:00Z", "updateTime": "2023-10-27T11:00:00Z" } ``` ### Authorization Scopes - `https://www.googleapis.com/auth/cloud-platform` ### IAM Permissions - `enterpriseknowledgegraph.entityReconciliationJobs.get` on the `name` resource. ``` -------------------------------- ### Search Cloud Knowledge Graph Entities using PowerShell Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api This snippet demonstrates searching the Cloud Knowledge Graph with PowerShell. It retrieves an access token using `gcloud auth print-access-token` and constructs a GET request with appropriate headers and URI, including project, location, and query parameters. ```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 ``` -------------------------------- ### REST API: Search Enterprise Knowledge Graph (PowerShell) Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api This PowerShell script demonstrates how to search the Enterprise Knowledge Graph using the REST API. It retrieves an access token using `gcloud auth print-access-token` and constructs a GET request with the necessary headers and URI, including project ID, location, search query, and optional 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 ``` -------------------------------- ### REST API: Lookup Entities with PowerShell Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api This PowerShell script demonstrates how to look up entities using the Enterprise Knowledge Graph REST API. It retrieves an authentication token using `gcloud auth print-access-token` and constructs an HTTP GET request. The response, containing entity information in JSON-LD format, is then displayed. ```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 ``` -------------------------------- ### Handle Google Maps Platform License for Name Field Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/ckg-policies This example shows how to check for license information attached to the 'name' field via 'additionalProperty'. If the license points to Google Maps Platform terms, it signifies that Google Places API terms of service and data restrictions must be followed. ```json { "additionalProperty": { "@type": "PropertyValue", "name": "nameLicense", "value": "https://cloud.google.com/maps-platform/terms" } } ``` -------------------------------- ### Initialize Enterprise Knowledge Graph Client (Python) Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api_hl=it Demonstrates how to initialize the Enterprise Knowledge Graph client for Python. This involves importing the necessary library and setting up the client object, typically requiring project and location details. ```python 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' client = ekg.EnterpriseKnowledgeGraphServiceClient() ``` -------------------------------- ### Python Client for Cloud Knowledge Graph Entity Lookup Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api This Python snippet initializes the Enterprise Knowledge Graph client library. It sets up the necessary variables for project ID and location, which are required for subsequent API calls to look up entities. Ensure Application Default Credentials are set up for authentication. ```python 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' ``` -------------------------------- ### Get Entity Reconciliation Job using REST API (curl) Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/entity-reconciliation-api This example shows how to retrieve the status of an entity reconciliation job using a curl command. It requires the Google Cloud project ID, the knowledge graph location (e.g., 'global'), and the specific job ID. The command uses `gcloud auth print-access-token` to obtain authentication credentials. ```bash curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://enterpriseknowledgegraph.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/entityReconciliationJobs/JOB_ID" ``` -------------------------------- ### HTTP GET Request for Searching KG Entities Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.cloudKnowledgeGraphEntities/search_hl=es-419 Demonstrates the structure of an HTTP GET request to search for entities in the Enterprise Knowledge Graph. It includes the base URL and the required `parent` path parameter. ```HTTP GET https://enterpriseknowledgegraph.googleapis.com/v1/{parent}/cloudKnowledgeGraphEntities:Search ``` -------------------------------- ### Python: Lookup Entities by ID Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api This Python function demonstrates how to use the Enterprise Knowledge Graph client library to look up entities by their IDs. It requires the `google-cloud-enterpriseknowledgegraph` library and takes project ID, location, and a list of entity IDs as input. The response is printed, including extracted details like name, description, types, and identifiers. ```python from typing import Sequence import google.cloud.enterpriseknowledgegraph_v1 as ekg 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") ``` -------------------------------- ### HTTP GET Request for Entity Lookup Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.cloudKnowledgeGraphEntities/lookup_hl=fr Demonstrates how to construct an HTTP GET request to the Enterprise Knowledge Graph API to look up entities by their IDs. This method requires specifying the parent resource and a list of entity IDs. ```HTTP GET https://enterpriseknowledgegraph.googleapis.com/v1/{parent}/cloudKnowledgeGraphEntities:Lookup?ids={entity_id_1}&ids={entity_id_2}&languages={language_code} ``` -------------------------------- ### HTTP GET Request to Search Public KG Entities Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.publicKnowledgeGraphEntities/search_hl=it This snippet demonstrates the structure of an HTTP GET request to search for public Knowledge Graph entities. It includes the base URL and the required path parameters. ```HTTP GET https://enterpriseknowledgegraph.googleapis.com/v1/{parent}/publicKnowledgeGraphEntities:Search ``` -------------------------------- ### Set GOOGLE_APPLICATION_CREDENTIALS Environment Variable (Windows Command Prompt) Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/setup This snippet provides the command to set the GOOGLE_APPLICATION_CREDENTIALS environment variable in the Windows Command Prompt. This variable is essential for authenticating your application with Google Cloud services. Remember to substitute 'KEY_PATH' with the actual path to your service account's JSON key file. ```cmd set GOOGLE_APPLICATION_CREDENTIALS=KEY_PATH # Example: # set GOOGLE_APPLICATION_CREDENTIALS=C:\Users\username\Downloads\service-account-file.json ``` -------------------------------- ### v1.projects.locations.entityReconciliationJobs Create Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest_hl=zh-tw Creates a EntityReconciliationJob. ```APIDOC ## POST /v1/{parent}/entityReconciliationJobs ### Description Creates a EntityReconciliationJob. ### Method POST ### Endpoint /v1/{parent}/entityReconciliationJobs ### Parameters #### Path Parameters - **parent** (string) - Required - ### Request Body - **field1** (type) - Required/Optional - Description ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Python: Search Enterprise Knowledge Graph Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api This Python function demonstrates how to search the Enterprise Knowledge Graph using the client library. It takes project ID, location, search query, and optional parameters like languages, types, and limit. The function returns and prints search results, including entity names, descriptions, types, detailed descriptions, and identifiers. ```Python import google.cloud.enterpriseknowledgegraph_v1 as ekg from typing import Sequence 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") ``` -------------------------------- ### Get Entity Reconciliation Job Details using PowerShell Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/entity-reconciliation-api Retrieves the details of a specific entity reconciliation job from the Enterprise Knowledge Graph API using PowerShell. It requires authentication via `gcloud` CLI and constructs an HTTP GET request with appropriate headers and URI. ```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/entityReconciliationJobs/JOB_ID" | Select-Object -Expand Content ``` -------------------------------- ### Map Person Schema to BigQuery Source Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/entity-reconciliation-console This snippet illustrates mapping for the 'Person' entity. It targets a BigQuery source and maps personal attributes like name, birth date, gender, and address, including the essential EKG recon predicates. ```yaml prefixes: ekg: http://cloud.google.com/ekg/0.0.1# schema: https://schema.org/ mappings: Person: sources: - [example_project:example_dataset.example_table~bigquery] s: ekg:person_$(record_id) po: - [a, schema:Person] - [schema:postalCode, $(ZIP)] - [schema:birthDate, $(BIRTHDATE)] - [schema:name, $(NAME)] - [schema:gender, $(GENDER)] - [schema:streetAddress, $(ADDRESS)] - [ekg:recon.source_name, (Patients)] - [ekg:recon.source_key, $(source_key)] ``` -------------------------------- ### GET projects.locations.entityReconciliationJobs.get Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.entityReconciliationJobs/get_hl=fr Retrieves a specific EntityReconciliationJob resource by its name. This is useful for checking the status or details of a reconciliation job. ```APIDOC ## GET /v1/{name} ### Description Gets an EntityReconciliationJob. ### Method GET ### Endpoint `https://enterpriseknowledgegraph.googleapis.com/v1/{name}` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the EntityReconciliationJob resource. Format: `projects/{project}/locations/{location}/entityReconciliationJobs/{entityReconciliationJob}` #### Query Parameters None #### Request Body The request body must be empty. ### Request Example (No request body for this GET request) ### Response #### Success Response (200) - **EntityReconciliationJob** (object) - An instance of `EntityReconciliationJob` containing the details of the requested job. #### Response Example (Example response body would be an instance of `EntityReconciliationJob`) ``` -------------------------------- ### Entity Reconciliation Jobs API Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest_hl=id Endpoints for managing entity reconciliation jobs, including creating, canceling, deleting, getting, and listing jobs. ```APIDOC ## POST /v1/{name}:cancel ### Description Cancels a EntityReconciliationJob. ### Method POST ### Endpoint `/v1/{name}:cancel` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the EntityReconciliationJob to cancel. Format: `projects/{project}/locations/{location}/entityReconciliationJobs/{entityReconciliationJob}`. ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the job was canceled. #### Response Example ```json { "message": "EntityReconciliationJob canceled successfully." } ``` ``` ```APIDOC ## POST /v1/{parent}/entityReconciliationJobs ### Description Creates a EntityReconciliationJob. ### Method POST ### Endpoint `/v1/{parent}/entityReconciliationJobs` ### Parameters #### Path Parameters - **parent** (string) - Required - The parent resource name. Format: `projects/{project}/locations/{location}`. #### Request Body - **entityReconciliationJob** (object) - Required - The EntityReconciliationJob to create. - **displayName** (string) - Optional - A user-friendly name for the job. - **inputConfig** (object) - Required - Configuration for the input data. - **outputConfig** (object) - Required - Configuration for the output data. ### Request Example ```json { "entityReconciliationJob": { "displayName": "My Reconciliation Job", "inputConfig": { "bigQuerySource": { "uri": "bq://project.dataset.table" } }, "outputConfig": { "bigQueryDestination": { "uri": "bq://project.dataset.output_table" } } } } ``` ### Response #### Success Response (200) - **name** (string) - The resource name of the created EntityReconciliationJob. - **state** (string) - The current state of the job. #### Response Example ```json { "name": "projects/my-project/locations/us-central1/entityReconciliationJobs/12345", "state": "RUNNING" } ``` ``` ```APIDOC ## DELETE /v1/{name} ### Description Deletes a EntityReconciliationJob. ### Method DELETE ### Endpoint `/v1/{name}` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the EntityReconciliationJob to delete. Format: `projects/{project}/locations/{location}/entityReconciliationJobs/{entityReconciliationJob}`. ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the job was deleted. #### Response Example ```json { "message": "EntityReconciliationJob deleted successfully." } ``` ``` ```APIDOC ## GET /v1/{name} ### Description Gets a EntityReconciliationJob. ### Method GET ### Endpoint `/v1/{name}` ### Parameters #### Path Parameters - **name** (string) - Required - The name of the EntityReconciliationJob to retrieve. Format: `projects/{project}/locations/{location}/entityReconciliationJobs/{entityReconciliationJob}`. ### Response #### Success Response (200) - **entityReconciliationJob** (object) - The details of the EntityReconciliationJob. #### Response Example ```json { "entityReconciliationJob": { "name": "projects/my-project/locations/us-central1/entityReconciliationJobs/12345", "displayName": "My Reconciliation Job", "state": "SUCCEEDED" } } ``` ``` ```APIDOC ## GET /v1/{parent}/entityReconciliationJobs ### Description Lists Entity Reconciliation Jobs. ### Method GET ### Endpoint `/v1/{parent}/entityReconciliationJobs` ### Parameters #### Path Parameters - **parent** (string) - Required - The parent resource name. Format: `projects/{project}/locations/{location}`. #### Query Parameters - **filter** (string) - Optional - A filter for the jobs to return. - **pageSize** (integer) - Optional - The maximum number of jobs to return. - **pageToken** (string) - Optional - A page token, received from a previous `List` call. ### Response #### Success Response (200) - **entityReconciliationJobs** (array) - A list of EntityReconciliationJobs. - **nextPageToken** (string) - A token to retrieve the next page of results. #### Response Example ```json { "entityReconciliationJobs": [ { "name": "projects/my-project/locations/us-central1/entityReconciliationJobs/12345", "displayName": "My Reconciliation Job", "state": "SUCCEEDED" }, { "name": "projects/my-project/locations/us-central1/entityReconciliationJobs/67890", "displayName": "Another Job", "state": "RUNNING" } ], "nextPageToken": "some_token" } ``` ``` -------------------------------- ### GET /v1/projects/{PROJECT_ID}/locations/{LOCATION}/publicKnowledgeGraphEntities:Search Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/search-api Searches the Enterprise Knowledge Graph for entities. You can filter results by query, language, type, and limit the number of returned entities. ```APIDOC ## GET /v1/projects/{PROJECT_ID}/locations/{LOCATION}/publicKnowledgeGraphEntities:Search ### Description Searches the Enterprise Knowledge Graph for entities based on a query. This endpoint allows for filtering by language, entity type, and limiting the number of results. ### Method GET ### Endpoint `https://enterpriseknowledgegraph.googleapis.com/v1/projects/{PROJECT_ID}/locations/{LOCATION}/publicKnowledgeGraphEntities:Search` ### Parameters #### Path Parameters - **PROJECT_ID** (string) - Required - Your Google Cloud project ID. - **LOCATION** (string) - Required - Knowledge Graph location. Use `global` for the Global Endpoint. #### Query Parameters - **query** (string) - Required - The literal query string for search. - **limit** (integer) - Optional - Limits the number of entities to be returned. Defaults to 20. - **languages** (array of strings) - Optional - A list of language codes (ISO 639) to run the query with. Defaults to `en`. - **types** (array of strings) - Optional - Restricts returned entities with these types, as defined by `https://schema.org`. If multiple types are specified, returned entities will contain one or more of these types. Defaults to empty (no type restrictions). ### Request Example ```bash GET https://enterpriseknowledgegraph.googleapis.com/v1/projects/YOUR_PROJECT_ID/locations/global/publicKnowledgeGraphEntities:Search?query=Stanford%20University&limit=10&languages=en&types=Organization ``` ### Response #### Success Response (200) - **itemListElement** (array) - A list of entities found, presented in JSON-LD format compatible with schema.org. - Each element contains a `result` object with details like `name`, `description`, `detailedDescription`, `@id`, and `identifier`. #### Response Example ```json { "@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" }, "@type": [ "Organization", "EducationalOrganization" ], "identifier": [ { "name": "google_knowledge_graph_mid", "value": "/m/02z51" } ] } } ] } ``` ``` -------------------------------- ### GET /v1/{parent}/publicKnowledgeGraphEntities:Search Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.publicKnowledgeGraphEntities/search_hl=es Searches the public KG entities using the entity name. This endpoint allows filtering by language, entity type, and limiting the number of results. ```APIDOC ## GET /v1/{parent}/publicKnowledgeGraphEntities:Search ### Description Searches the public KG entities with entity name. This endpoint allows filtering by language, entity type, and limiting the number of results. ### Method GET ### Endpoint `https://enterpriseknowledgegraph.googleapis.com/v1/{parent}/publicKnowledgeGraphEntities:Search` ### Parameters #### Path Parameters - **parent** (string) - Required - The name of the Entity's parent resource. Format: `projects/{project}/locations/{location}`. #### Query Parameters - **query** (string) - Required - The literal query string for search. - **languages[]** (string) - Optional - The list of language codes (defined in ISO 693) to run the query with, e.g. 'en'. - **types[]** (string) - Optional - Restricts returned entities with these types, e.g. Person (as defined in `https://schema.org/Person`). If multiple types are specified, returned entities will contain one or more of these types. - **limit** (integer) - Optional - Limits the number of entities to be returned. ### Request Body The request body must be empty. ### Response #### Success Response (200) - **@context** (value) - The local context applicable for the response. See more details at https://www.w3.org/TR/json-ld/#context-definitions. - **@type** (value) - The schema type of top-level JSON-LD object, e.g. ItemList. - **itemListElement** (array) - The item list of search results. #### Response Example ```json { "@context": "value", "@type": "value", "itemListElement": [ // ... search results ] } ``` ### Authorization Scopes - `https://www.googleapis.com/auth/cloud-platform` ### IAM Permissions - `enterpriseknowledgegraph.publicKnowledgeGraphEntities.search` on the `parent` resource. ``` -------------------------------- ### GET /v1/{parent}/publicKnowledgeGraphEntities:Search Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.publicKnowledgeGraphEntities/search Searches the public KG entities with the provided entity name. This endpoint allows filtering by language, entity types, and limiting the number of results. ```APIDOC ## GET /v1/{parent}/publicKnowledgeGraphEntities:Search ### Description Searches the public KG entities with entity name. This endpoint allows filtering by language, entity types, and limiting the number of results. ### Method GET ### Endpoint `https://enterpriseknowledgegraph.googleapis.com/v1/{parent}/publicKnowledgeGraphEntities:Search` ### Parameters #### Path Parameters - **parent** (string) - Required - The name of the Entity's parent resource. Format: `projects/{project}/locations/{location}`. #### Query Parameters - **query** (string) - Required - The literal query string for search. - **languages[]** (string) - Optional - The list of language codes (defined in ISO 693) to run the query with, e.g. 'en'. - **types[]** (string) - Optional - Restricts returned entities with these types, e.g. Person (as defined in `https://schema.org/Person`). If multiple types are specified, returned entities will contain one or more of these types. - **limit** (integer) - Optional - Limits the number of entities to be returned. ### Request Body The request body must be empty. ### Response #### Success Response (200) - **@context** (value) - The local context applicable for the response. See more details at https://www.w3.org/TR/json-ld/#context-definitions. - **@type** (value) - The schema type of top-level JSON-LD object, e.g. ItemList. - **itemListElement** (array) - The item list of search results. #### Response Example ```json { "@context": "value", "@type": "value", "itemListElement": [ // ... search results ... ] } ``` ### Authorization Scopes Requires the following OAuth scope: - `https://www.googleapis.com/auth/cloud-platform` ### IAM Permissions Requires the following IAM permission on the `parent` resource: - `enterpriseknowledgegraph.publicKnowledgeGraphEntities.search` ``` -------------------------------- ### Map Organization Schema to BigQuery Source Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/entity-reconciliation-console This snippet defines a mapping for the 'Organization' entity. It specifies the BigQuery source table and maps various schema.org properties (name, address, country, etc.) and EKG-specific recon properties from source columns. ```yaml prefixes: ekg: http://cloud.google.com/ekg/0.0.1# schema: https://schema.org/ mappings: Organization: sources: - [example_project:example_dataset.example_table~bigquery] s: ekg:company_$(record_id) po: - [a, schema:Organization] - [schema:name, $(company_name_in_source)] - [schema:streetAddress, $(street)] - [schema:postalCode, $(postal_code)] - [schema:addressCountry, $(country)] - [schema:addressLocality, $(city)] - [schema:addressRegion, $(state)] - [ekg:recon.source_name, $(source_system)] - [ekg:recon.source_key, $(source_key)] ``` -------------------------------- ### Set GOOGLE_APPLICATION_CREDENTIALS Environment Variable (Linux/macOS) Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/setup This snippet demonstrates how to set the GOOGLE_APPLICATION_CREDENTIALS environment variable in Linux or macOS shells. This variable points to the downloaded JSON key file, enabling your application to authenticate with Google Cloud services. Replace 'KEY_PATH' with the actual path to your service account key file. ```bash export GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH" # Example: # export GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/service-account-file.json" ``` -------------------------------- ### GET /v1/{parent}/cloudKnowledgeGraphEntities:Search Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.cloudKnowledgeGraphEntities/search_hl=id Searches the Cloud KG entities with the provided query string. You can filter results by language, entity type, and limit the number of returned entities. ```APIDOC ## GET /v1/{parent}/cloudKnowledgeGraphEntities:Search ### Description Searches the Cloud KG entities with the provided query string. You can filter results by language, entity type, and limit the number of returned entities. ### Method GET ### Endpoint `https://enterpriseknowledgegraph.googleapis.com/v1/{parent}/cloudKnowledgeGraphEntities:Search` ### Parameters #### Path Parameters - **parent** (string) - Required - The name of the Entity's parent resource. Format: `projects/{project}/locations/{location}`. #### Query Parameters - **query** (string) - Required - The literal query string for search. - **languages[]** (string) - Optional - The list of language codes (defined in ISO 693) to run the query with, e.g. 'en'. - **types[]** (string) - Optional - Restricts returned entities with these types, e.g. Person (as defined in `https://schema.org/Person`). If multiple types are specified, returned entities will contain one or more of these types. - **limit** (integer) - Optional - Limits the number of entities to be returned. ### Request Body The request body must be empty. ### Response #### Success Response (200) - **@context** (Value) - The local context applicable for the response. - **@type** (Value) - The schema type of top-level JSON-LD object, e.g. ItemList. - **itemListElement** (array of Value) - The item list of search results. #### Response Example ```json { "@context": "value", "@type": "value", "itemListElement": [ "value" ] } ``` ### Authorization Scopes - `https://www.googleapis.com/auth/cloud-platform` ### IAM Permissions - `enterpriseknowledgegraph.cloudKnowledgeGraphEntities.search` on the `parent` resource. ``` -------------------------------- ### GET /v1/{parent}/publicKnowledgeGraphEntities:Search Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.publicKnowledgeGraphEntities/search_hl=es-419 Searches the public KG entities with entity name. This endpoint allows you to find public entities based on a query string and filter by language and entity types. ```APIDOC ## GET /v1/{parent}/publicKnowledgeGraphEntities:Search ### Description Searches the public KG entities with entity name. This endpoint allows you to find public entities based on a query string and filter by language and entity types. ### Method GET ### Endpoint `https://enterpriseknowledgegraph.googleapis.com/v1/{parent}/publicKnowledgeGraphEntities:Search` ### Parameters #### Path Parameters - **parent** (string) - Required - The name of the Entity's parent resource. Format: `projects/{project}/locations/{location}`. #### Query Parameters - **query** (string) - Required - The literal query string for search. - **languages[]** (string) - Optional - The list of language codes (defined in ISO 693) to run the query with, e.g. 'en'. - **types[]** (string) - Optional - Restricts returned entities with these types, e.g. Person (as defined in `https://schema.org/Person`). If multiple types are specified, returned entities will contain one or more of these types. - **limit** (integer) - Optional - Limits the number of entities to be returned. ### Request Body The request body must be empty. ### Response #### Success Response (200) - **@context** (value) - The local context applicable for the response. See more details at https://www.w3.org/TR/json-ld/#context-definitions. - **@type** (value) - The schema type of top-level JSON-LD object, e.g. ItemList. - **itemListElement** (array) - The item list of search results. #### Response Example ```json { "@context": "value", "@type": "value", "itemListElement": [ // ... search results ... ] } ``` ### Authorization Scopes Requires the following OAuth scope: * `https://www.googleapis.com/auth/cloud-platform` ### IAM Permissions Requires the following IAM permission on the `parent` resource: * `enterpriseknowledgegraph.publicKnowledgeGraphEntities.search` ``` -------------------------------- ### Enterprise Knowledge Graph Methods Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations_hl=es-419 This section details the available methods for interacting with the Enterprise Knowledge Graph, including lookup and search functionalities. ```APIDOC ## REST Resource: projects.locations.publicKnowledgeGraphEntities ### Description This resource allows for querying the public knowledge graph entities. ### Methods #### `lookup` ##### Description Finds the public KG entities with public KG ID(s). ##### Method GET (Assumed based on 'lookup' functionality) ##### Endpoint `/websites/cloud_google_enterprise-knowledge-graph/lookup` (Assumed endpoint structure) ##### Parameters ###### Query Parameters - **publicKGEtityIds** (string) - Required - Comma-separated list of public KG entity IDs to look up. ###### Request Body None ##### Request Example ``` GET /websites/cloud_google_enterprise-knowledge-graph/lookup?publicKGEtityIds=entity1,entity2 ``` ##### Response ###### Success Response (200) - **entities** (array) - A list of found public KG entities. - **entityId** (string) - The ID of the entity. - **entityName** (string) - The name of the entity. ###### Response Example ```json { "entities": [ { "entityId": "entity1", "entityName": "Example Entity 1" }, { "entityId": "entity2", "entityName": "Example Entity 2" } ] } ``` #### `search` ##### Description Searches the public KG entities with entity name. ##### Method GET (Assumed based on 'search' functionality) ##### Endpoint `/websites/cloud_google_enterprise-knowledge-graph/search` (Assumed endpoint structure) ##### Parameters ###### Query Parameters - **entityName** (string) - Required - The name of the entity to search for. - **limit** (integer) - Optional - The maximum number of results to return. ###### Request Body None ##### Request Example ``` GET /websites/cloud_google_enterprise-knowledge-graph/search?entityName=Example&limit=10 ``` ##### Response ###### Success Response (200) - **results** (array) - A list of search results. - **entityId** (string) - The ID of the entity. - **entityName** (string) - The name of the entity. ###### Response Example ```json { "results": [ { "entityId": "entity3", "entityName": "Another Example Entity" }, { "entityId": "entity4", "entityName": "Example Company" } ] } ``` ``` -------------------------------- ### GET /v1/{parent}/publicKnowledgeGraphEntities:Search Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations.publicKnowledgeGraphEntities/search_hl=fr Searches the public KG entities using the provided query string. Results can be filtered by language, entity type, and a limit can be set for the number of returned entities. ```APIDOC ## GET /v1/{parent}/publicKnowledgeGraphEntities:Search ### Description Searches the public KG entities with entity name. ### Method GET ### Endpoint `https://enterpriseknowledgegraph.googleapis.com/v1/{parent}/publicKnowledgeGraphEntities:Search` ### Parameters #### Path Parameters - **parent** (string) - Required - The name of the Entity's parent resource. Format: `projects/{project}/locations/{location}`. #### Query Parameters - **query** (string) - Required - The literal query string for search. - **languages[]** (string) - Optional - The list of language codes (defined in ISO 693) to run the query with, e.g. 'en'. - **types[]** (string) - Optional - Restricts returned entities with these types, e.g. Person (as defined in `https://schema.org/Person`). If multiple types are specified, returned entities will contain one or more of these types. - **limit** (integer) - Optional - Limits the number of entities to be returned. ### Request Body The request body must be empty. ### Response #### Success Response (200) - **@context** (value) - The local context applicable for the response. See more details at https://www.w3.org/TR/json-ld/#context-definitions. - **@type** (value) - The schema type of top-level JSON-LD object, e.g. ItemList. - **itemListElement** (array) - The item list of search results. #### Response Example ```json { "@context": "value", "@type": "value", "itemListElement": [ "item1", "item2" ] } ``` ### Authorization Scopes Requires the following OAuth scope: * `https://www.googleapis.com/auth/cloud-platform` ### IAM Permissions Requires the following IAM permission on the `parent` resource: * `enterpriseknowledgegraph.publicKnowledgeGraphEntities.search` ``` -------------------------------- ### Enterprise Knowledge Graph Methods Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations_hl=ko This section details the available methods for interacting with the Enterprise Knowledge Graph. ```APIDOC ## REST Resource: projects.locations.publicKnowledgeGraphEntities ### Description This resource allows you to access and query public knowledge graph entities. ### Methods #### `lookup` ##### Description Finds the public KG entities with public KG ID(s). ##### Method POST ##### Endpoint `/v1/projects/{projectId}/locations/{locationId}/publicKnowledgeGraphEntities:lookup` ##### Parameters ###### Query Parameters - **entityIds** (array of strings) - Required - A list of public KG entity IDs to look up. ###### Request Body ```json { "entityIds": ["entity_id_1", "entity_id_2"] } ``` #### `search` ##### Description Searches the public KG entities with entity name. ##### Method POST ##### Endpoint `/v1/projects/{projectId}/locations/{locationId}/publicKnowledgeGraphEntities:search` ##### Parameters ###### Query Parameters - **entityName** (string) - Required - The name of the entity to search for. - **pageSize** (integer) - Optional - The maximum number of results to return. - **pageToken** (string) - Optional - A page token, received from a previous `search` call. ###### Request Body ```json { "entityName": "example entity name", "pageSize": 10, "pageToken": "next_page_token" } ``` ### Response #### Success Response (200) - **entities** (array of objects) - A list of matching public KG entities. - **entityId** (string) - The unique identifier for the entity. - **name** (string) - The name of the entity. - **description** (string) - A description of the entity. #### Response Example ```json { "entities": [ { "entityId": "kgmid:0123456789abcdef", "name": "Example Entity", "description": "This is an example entity in the knowledge graph." } ] } ``` ``` -------------------------------- ### Enterprise Knowledge Graph Methods Source: https://docs.cloud.google.com/enterprise-knowledge-graph/docs/reference/rest/v1/projects.locations_hl=fr This section details the available methods for interacting with the Enterprise Knowledge Graph. ```APIDOC ## GET projects.locations.publicKnowledgeGraphEntities.lookup ### Description Finds the public KG entities with public KG ID(s). ### Method GET ### Endpoint `/websites/cloud_google_enterprise-knowledge-graph/locations/publicKnowledgeGraphEntities:lookup` ### Parameters #### Query Parameters - **publicKnowledgeGraphIds** (string) - Required - The public KG ID(s) to look up. ### Response #### Success Response (200) - **entities** (array) - A list of matching public KG entities. #### Response Example ```json { "entities": [ { "name": "Example Entity", "id": "example-id" } ] } ``` --- ## GET projects.locations.publicKnowledgeGraphEntities.search ### Description Searches the public KG entities with entity name. ### Method GET ### Endpoint `/websites/cloud_google_enterprise-knowledge-graph/locations/publicKnowledgeGraphEntities:search` ### Parameters #### Query Parameters - **entityName** (string) - Required - The name of the entity to search for. ### Response #### Success Response (200) - **entities** (array) - A list of matching public KG entities. #### Response Example ```json { "entities": [ { "name": "Example Entity", "id": "example-id" } ] } ``` ```