管理商務詞彙表

本文說明如何在 Knowledge Catalog (舊稱 Dataplex Universal Catalog) 中建立及管理商務詞彙表。使用業務詞彙表為資料資產建立標準化詞彙,減少模糊不清之處,並提升整個機構的資料探索和治理成效。

Knowledge Catalog 組織詞彙應用實例

使用 Knowledge Catalog 組織詞彙建立資料通用語言,可達成下列目標:

  • 定義清楚的業務類別和字詞階層。
  • 使用同義字連結概念,並顯示字詞之間的關係。
  • 根據業務概念 (而非僅根據技術名稱) 搜尋資料資源。

Knowledge Catalog 的組織詞彙有助於簡化資料探索作業並減少模糊不清之處,進而提升管理成效、提高分析準確度,以及加快取得洞察資料的速度。

組織詞彙的要素

本節說明可用於建構業務字彙表的關鍵要素。

詞彙

字彙表具有下列屬性:

  • 總覽。說明組織詞彙的用途和內容。你可以新增圖片、連結和表格。雖然不支援 HTML 格式,但您可以加入格式為程式碼的 HTML 程式碼,或新增 HTML 網頁的連結。你也可以使用 RTF 格式選項,例如粗體、斜體、底線、項目符號清單、段落、標題和程式碼區塊。大小上限為 120 KB。

  • 說明。描述詞彙表。系統會為這個欄位的文字建立索引,方便搜尋。支援的大小上限為 1 KB。

  • 區域。指定詞彙表所在的區域

類別

您可以使用「類別」整理及建構各種類別和字詞。 類別是在組織詞彙中定義,類別最多可建立三層巢狀結構。

類別具有術語表的屬性,以及下列屬性:

  • 聯絡人。指定負責維護類別的人員。 這項屬性是說明性質,不會影響類別的權限。
  • 上層。指定用於建立目前類別父項的關係。最多可建立三層巢狀類別。

類別的區域與包含該類別的字彙表區域相同。

字詞

字詞 (「詞彙表字詞」的簡稱) 是指公司特定業務分支中使用的概念。舉例來說,某公司的行銷部門可能會建立描述單次點擊出價的字詞。詞彙定義於組織詞彙,可直接在詞彙表或詞彙表中的任何類別中找到。

字詞具有類別的屬性,以及下列屬性:

  • 同義字:指定同義字詞之間的連結。 請參閱同義字
  • 相關條款。指定概念相關但意義不同的字詞之間的連結。請參閱相關條款
  • 相關項目。指定字詞與資料資產之間的連結,或字詞與資料資產內資料欄之間的連結。
  • 資料品質規則。指定字詞的資料品質規定。 詳情請參閱「重複使用資料品質規則」。
  • 聯絡人。指定負責維護字詞的人員。字詞不會沿用類別中定義的聯絡人。

詞彙的區域與包含該詞彙的詞彙表區域相同。

同義詞

同義詞是一種關係,表示兩個不同字詞之間的等價關係。如果不同團隊在不同詞彙表中定義了兩個意義相同的字詞,請使用同義詞。舉例來說,您可以建立同義字,連結「利潤」和「收益」這兩個字詞。

相關字詞是指兩個字詞之間存在關聯,但意義不同。舉例來說,您可以建立相關字詞,連結「收益」和「利潤」這兩個字詞。

限制

  • 業務詞彙表位於專案和位置中,專案和位置的限制也適用於詞彙表。

必要的角色

如要取得建立及管理字彙表所需的權限,請要求管理員授予您專案的下列 IAM 角色:

  • 資料管理員可取得詞彙表、類別、字詞、同義字和相關字詞的完整存取權,並設定 IAM 政策: Dataplex Catalog 管理員 (roles/dataplex.catalogAdmin)
  • 資料管理員或資料擁有者可透過 Dataplex Catalog 編輯器 (roles/dataplex.catalogEditor) 建立、編輯或刪除詞彙表、類別、字詞、字詞間的連結、字詞與資料資產間的連結,以及進行搜尋:
  • 資料分析師或資料消費者可取得詞彙表、類別、字詞、字詞之間和字詞與資料資產之間的連結,以及搜尋功能的唯讀權限: Dataplex Catalog 檢視者 (roles/dataplex.catalogViewer)

如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

這些預先定義的角色具備建立及管理詞彙表所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:

所需權限

如要建立及管理字彙表,必須具備下列權限:

  • 在專案中建立、讀取、更新及刪除商務詞彙表、類別和字詞:
    • dataplex.glossaries.list
    • dataplex.glossaries.create
    • dataplex.glossaries.get
    • dataplex.glossaries.update
    • dataplex.glossaries.delete
    • dataplex.glossaryCategories.create
    • dataplex.glossaryCategories.list
    • dataplex.glossaryCategories.get
    • dataplex.glossaryCategories.update
    • dataplex.glossaryCategories.delete
    • dataplex.glossaryTerms.create
    • dataplex.glossaryTerms.list
    • dataplex.glossaryTerms.get
    • dataplex.glossaryTerms.update
    • dataplex.glossaryTerms.delete
  • 在專案中建立、查詢及刪除同義字詞連結:
    • dataplex.entryLinks.create 在專案的 Knowledge Catalog 項目群組中,其中一個術語存在於該專案中。連結會建立在已授予權限的項目群組中。
    • 在專案的 Knowledge Catalog 項目群組中,對其中一個詞彙表字詞使用 dataplex.entryGroups.useSynonymEntryLink。連結會建立在已授予權限的項目群組中。
    • dataplex.glossaryTerms.use ,適用於需要建立關聯的詞彙表字詞。
    • dataplex.glossaryTerms.get on the term whose synonym links you are looking up. 如果缺少這些字詞的 dataplex.glossaryTerms.get 權限,Knowledge Catalog 會在回應中隱藏同義字詞。
    • 在連結所在的專案中,對 Knowledge Catalog 項目群組執行 dataplex.entryLinks.delete。
  • 在專案中建立、查詢及刪除相關的字詞對應連結:
    • dataplex.entryLinks.create 在專案的 Knowledge Catalog 項目群組中,其中一個術語存在於該專案中。連結會建立在已授予權限的項目群組中。
    • 在專案中,如果詞彙表字詞存在於 Knowledge Catalog 項目群組,則該項目群組的 dataplex.entryGroups.useRelatedEntryLink 權限必須設為 true。連結會建立在已授予權限的項目群組中。
    • 在含有對應詞彙表字詞項目的專案中,對 Knowledge Catalog 項目群組執行 dataplex.entries.link。
    • dataplex.glossaryTerms.get on the term whose related links you are looking up. 如果您沒有這些字詞的 dataplex.glossaryTerms.get 權限,Knowledge Catalog 會在回覆中隱藏相關字詞。
    • 在連結所在的專案中,對 Knowledge Catalog 項目群組執行 dataplex.entryLinks.delete。
  • 在專案中建立、查詢及刪除字詞與資料資產或資料欄之間的連結:
    • dataplex.entryLinks.create on the system entry group corresponding to data assets or columns in the project. 連結會在授予權限的專案中建立。
    • dataplex.entryGroups.useDefinitionEntryLink 在專案中對應於資料資產或資料欄的系統項目群組上。連結會在獲得授權的專案中建立。
    • 專案中資料資產或資料欄對應的系統項目群組。連結會在授予權限的專案中建立。
    • 詞彙表 (需要與字詞建立關聯)。
    • 您要查詢連結的項目,必須具備來源系統的讀取權限 (例如 bigquery.tables.getdataplex.glossaryTerms.get)。如果您沒有這些資產的來源系統讀取權限,Knowledge Catalog 會在回應中遮蓋資料資產。
    • dataplex.entryLinks.delete 在連結所在的系統項目群組中。

您或許還可透過自訂角色或其他預先定義的角色取得這些權限。

詳情請參閱「Knowledge Catalog IAM 角色」。

建立及管理商務詞彙表

下列各節將說明如何建立、查看、編輯及刪除商家字彙表。

建立組織詞彙

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 按一下「建立組織詞彙」

  3. 在「建立組織詞彙」頁面中,指定組織詞彙的名稱和位置。建立字彙表後,您就無法變更位置。

  4. 點選「建立」。詞彙表會在目前的專案下建立。

  5. 選用:在「說明」Description中新增簡短說明 (最多 1,024 個字元), 或在「總覽」Overview中新增詳細說明 (最多 120 KB)。

C#

C#

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 C# 設定說明操作。詳情請參閱 Knowledge Catalog C# API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

using Google.Api.Gax.ResourceNames;
using Google.Cloud.Dataplex.V1;
using Google.LongRunning;

public sealed partial class GeneratedBusinessGlossaryServiceClientSnippets
{
    /// <summary>Snippet for CreateGlossary</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void CreateGlossaryRequestObject()
    {
        // Create client
        BusinessGlossaryServiceClient businessGlossaryServiceClient = BusinessGlossaryServiceClient.Create();
        // Initialize request argument(s)
        CreateGlossaryRequest request = new CreateGlossaryRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            GlossaryId = "",
            Glossary = new Glossary(),
            ValidateOnly = false,
        };
        // Make the request
        Operation<Glossary, OperationMetadata> response = businessGlossaryServiceClient.CreateGlossary(request);

        // Poll until the returned long-running operation is complete
        Operation<Glossary, OperationMetadata> completedResponse = response.PollUntilCompleted();
        // Retrieve the operation result
        Glossary result = completedResponse.Result;

        // Or get the name of the operation
        string operationName = response.Name;
        // This name can be stored, then the long-running operation retrieved later by name
        Operation<Glossary, OperationMetadata> retrievedResponse = businessGlossaryServiceClient.PollOnceCreateGlossary(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            Glossary retrievedResult = retrievedResponse.Result;
        }
    }
}

Go

Go

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Go 設定說明操作。詳情請參閱 Knowledge Catalog Go API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。


//go:build examples

package main

import (
	"context"

	dataplex "cloud.google.com/go/dataplex/apiv1"
	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataplex.NewBusinessGlossaryClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.CreateGlossaryRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#CreateGlossaryRequest.
	}
	op, err := c.CreateGlossary(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	resp, err := op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

Java

Java

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Java 設定說明操作。詳情請參閱 Knowledge Catalog Java API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

import com.google.cloud.dataplex.v1.BusinessGlossaryServiceClient;
import com.google.cloud.dataplex.v1.CreateGlossaryRequest;
import com.google.cloud.dataplex.v1.Glossary;
import com.google.cloud.dataplex.v1.LocationName;

public class SyncCreateGlossary {

  public static void main(String[] args) throws Exception {
    syncCreateGlossary();
  }

  public static void syncCreateGlossary() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (BusinessGlossaryServiceClient businessGlossaryServiceClient =
        BusinessGlossaryServiceClient.create()) {
      CreateGlossaryRequest request =
          CreateGlossaryRequest.newBuilder()
              .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .setGlossaryId("glossaryId1849967577")
              .setGlossary(Glossary.newBuilder().build())
              .setValidateOnly(true)
              .build();
      Glossary response = businessGlossaryServiceClient.createGlossaryAsync(request).get();
    }
  }
}

Node.js

Node.js

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Node.js 設定說明操作。詳情請參閱 Knowledge Catalog Node.js API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The parent resource where this Glossary will be created.
 *  Format: projects/{project_id_or_number}/locations/{location_id}
 *  where `location_id` refers to a Google Cloud region.
 */
// const parent = 'abc123'
/**
 *  Required. Glossary ID: Glossary identifier.
 */
// const glossaryId = 'abc123'
/**
 *  Required. The Glossary to create.
 */
// const glossary = {}
/**
 *  Optional. Validates the request without actually creating the Glossary.
 *  Default: false.
 */
// const validateOnly = true

// Imports the Dataplex library
const {BusinessGlossaryServiceClient} = require('@google-cloud/dataplex').v1;

// Instantiates a client
const dataplexClient = new BusinessGlossaryServiceClient();

async function callCreateGlossary() {
  // Construct request
  const request = {
    parent,
    glossaryId,
    glossary,
  };

  // Run request
  const [operation] = await dataplexClient.createGlossary(request);
  const [response] = await operation.promise();
  console.log(response);
}

callCreateGlossary();

Python

Python

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Python 設定說明操作。詳情請參閱 Knowledge Catalog Python API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dataplex_v1


def sample_create_glossary():
    # Create a client
    client = dataplex_v1.BusinessGlossaryServiceClient()

    # Initialize request argument(s)
    request = dataplex_v1.CreateGlossaryRequest(
        parent="parent_value",
        glossary_id="glossary_id_value",
    )

    # Make the request
    operation = client.create_glossary(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

Ruby

Ruby

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Ruby 設定說明操作。詳情請參閱 Knowledge Catalog Ruby API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

require "google/cloud/dataplex/v1"

##
# Snippet for the create_glossary call in the BusinessGlossaryService service
#
# This snippet has been automatically generated and should be regarded as a code
# template only. It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in https://cloud.google.com/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::BusinessGlossaryService::Client#create_glossary.
#
def create_glossary
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::BusinessGlossaryService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::CreateGlossaryRequest.new

  # Call the create_glossary method.
  result = client.create_glossary request

  # The returned object is of type Gapic::Operation. You can use it to
  # check the status of an operation, cancel it, or wait for results.
  # Here is how to wait for a response.
  result.wait_until_done! timeout: 60
  if result.response?
    p result.response
  else
    puts "No response received."
  end
end

REST

建立詞彙表時,Knowledge Catalog 會建立項目來代表詞彙表。

  1. 建立詞彙表。

    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
    
    gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries?glossary_id=GLOSSARY_ID --data @- << EOF
    {
    "displayName": "DISPLAY_NAME",
    "description": "DESCRIPTION"
    }
    EOF

    更改下列內容:

    • PROJECT_ID:您要在當中建立詞彙表的專案 ID
    • LOCATION_ID:要建立詞彙表的位置 ID
    • GLOSSARY_ID:詞彙表 ID
    • DISPLAY_NAME:詞彙表的顯示名稱
    • DESCRIPTION:詞彙表說明,最多 1024 個字元
  2. 選用:在詞彙表中新增總覽。

    1. 查詢 Look 圖表項目:

      gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID
      :lookupEntry\
      ?entry=projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID
      \
      \&view=ALL

      PROJECT_NUMBER 替換為建立字彙表的專案編號。

    2. 在詞彙表中新增總覽:

      gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID\
      ?update_mask=aspects\
      \&deleteMissingAspects=false\
      \&aspect_keys=projects/dataplex-types/locations/global/aspectTypes/overview \
      --data @- << EOF
      {
      "aspects": {
         "dataplex-types.global.overview": {
            "aspect_type": "projects/dataplex-types/locations/global/aspectTypes/overview",
            "data": {
            "content": "OVERVIEW",
            "links": []
            },
         }
      }
      }
      EOF

      OVERVIEW 替換為純文字或 HTML,用來描述字彙表類別或字詞。

查看可用的字彙表

控制台

  • 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

    「我的字彙表」窗格會顯示您有權查看的所有機構字彙表,以及這些字彙表的說明和上次修改時間戳記。

C#

C#

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 C# 設定說明操作。詳情請參閱 Knowledge Catalog C# API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

using Google.Api.Gax;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Dataplex.V1;
using System;

public sealed partial class GeneratedBusinessGlossaryServiceClientSnippets
{
    /// <summary>Snippet for ListGlossaries</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void ListGlossariesRequestObject()
    {
        // Create client
        BusinessGlossaryServiceClient businessGlossaryServiceClient = BusinessGlossaryServiceClient.Create();
        // Initialize request argument(s)
        ListGlossariesRequest request = new ListGlossariesRequest
        {
            ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            Filter = "",
            OrderBy = "",
        };
        // Make the request
        PagedEnumerable<ListGlossariesResponse, Glossary> response = businessGlossaryServiceClient.ListGlossaries(request);

        // Iterate over all response items, lazily performing RPCs as required
        foreach (Glossary item in response)
        {
            // Do something with each item
            Console.WriteLine(item);
        }

        // Or iterate over pages (of server-defined size), performing one RPC per page
        foreach (ListGlossariesResponse page in response.AsRawResponses())
        {
            // Do something with each page of items
            Console.WriteLine("A page of results:");
            foreach (Glossary item in page)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
        }

        // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
        int pageSize = 10;
        Page<Glossary> singlePage = response.ReadPage(pageSize);
        // Do something with the page of items
        Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
        foreach (Glossary item in singlePage)
        {
            // Do something with each item
            Console.WriteLine(item);
        }
        // Store the pageToken, for when the next page is required.
        string nextPageToken = singlePage.NextPageToken;
    }
}

Go

Go

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Go 設定說明操作。詳情請參閱 Knowledge Catalog Go API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。


//go:build examples

package main

import (
	"context"

	dataplex "cloud.google.com/go/dataplex/apiv1"
	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
	"google.golang.org/api/iterator"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataplex.NewBusinessGlossaryClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.ListGlossariesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#ListGlossariesRequest.
	}
	it := c.ListGlossaries(ctx, req)
	for {
		resp, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			// TODO: Handle error.
		}
		// TODO: Use resp.
		_ = resp

		// If you need to access the underlying RPC response,
		// you can do so by casting the `Response` as below.
		// Otherwise, remove this line. Only populated after
		// first call to Next(). Not safe for concurrent access.
		_ = it.Response.(*dataplexpb.ListGlossariesResponse)
	}
}

Java

Java

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Java 設定說明操作。詳情請參閱 Knowledge Catalog Java API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

import com.google.cloud.dataplex.v1.BusinessGlossaryServiceClient;
import com.google.cloud.dataplex.v1.Glossary;
import com.google.cloud.dataplex.v1.ListGlossariesRequest;
import com.google.cloud.dataplex.v1.LocationName;

public class SyncListGlossaries {

  public static void main(String[] args) throws Exception {
    syncListGlossaries();
  }

  public static void syncListGlossaries() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (BusinessGlossaryServiceClient businessGlossaryServiceClient =
        BusinessGlossaryServiceClient.create()) {
      ListGlossariesRequest request =
          ListGlossariesRequest.newBuilder()
              .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .setPageSize(883849137)
              .setPageToken("pageToken873572522")
              .setFilter("filter-1274492040")
              .setOrderBy("orderBy-1207110587")
              .build();
      for (Glossary element : businessGlossaryServiceClient.listGlossaries(request).iterateAll()) {
        // doThingsWith(element);
      }
    }
  }
}

Node.js

Node.js

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Node.js 設定說明操作。詳情請參閱 Knowledge Catalog Node.js API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The parent, which has this collection of GlossaryTerms.
 *  Format:
 *  projects/{project_id_or_number}/locations/{location_id}/glossaries/{glossary_id}
 *  where `location_id` refers to a Google Cloud region.
 */
// const parent = 'abc123'
/**
 *  Optional. The maximum number of GlossaryTerms to return. The service may
 *  return fewer than this value. If unspecified, at most 50 GlossaryTerms will
 *  be returned. The maximum value is 1000; values above 1000 will be coerced
 *  to 1000.
 */
// const pageSize = 1234
/**
 *  Optional. A page token, received from a previous `ListGlossaryTerms` call.
 *  Provide this to retrieve the subsequent page.
 *  When paginating, all other parameters provided to `ListGlossaryTerms` must
 *  match the call that provided the page token.
 */
// const pageToken = 'abc123'
/**
 *  Optional. Filter expression that filters GlossaryTerms listed in the
 *  response. Filters are supported on the following fields:
 *    - immediate_parent
 *  Examples of using a filter are:
 *    -
 *    `immediate_parent="projects/{project_id_or_number}/locations/{location_id}/glossaries/{glossary_id}"`
 *    -
 *    `immediate_parent="projects/{project_id_or_number}/locations/{location_id}/glossaries/{glossary_id}/categories/{category_id}"`
 *  This will only return the GlossaryTerms that are directly nested under the
 *  specified parent.
 */
// const filter = 'abc123'
/**
 *  Optional. Order by expression that orders GlossaryTerms listed in the
 *  response. Order by fields are: `name` or `create_time` for the result. If
 *  not specified, the ordering is undefined.
 */
// const orderBy = 'abc123'

// Imports the Dataplex library
const {BusinessGlossaryServiceClient} = require('@google-cloud/dataplex').v1;

// Instantiates a client
const dataplexClient = new BusinessGlossaryServiceClient();

async function callListGlossaryTerms() {
  // Construct request
  const request = {
    parent,
  };

  // Run request
  const iterable = dataplexClient.listGlossaryTermsAsync(request);
  for await (const response of iterable) {
      console.log(response);
  }
}

callListGlossaryTerms();

Python

Python

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Python 設定說明操作。詳情請參閱 Knowledge Catalog Python API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dataplex_v1


def sample_list_glossaries():
    # Create a client
    client = dataplex_v1.BusinessGlossaryServiceClient()

    # Initialize request argument(s)
    request = dataplex_v1.ListGlossariesRequest(
        parent="parent_value",
    )

    # Make the request
    page_result = client.list_glossaries(request=request)

    # Handle the response
    for response in page_result:
        print(response)

Ruby

Ruby

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Ruby 設定說明操作。詳情請參閱 Knowledge Catalog Ruby API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

require "google/cloud/dataplex/v1"

##
# Snippet for the list_glossaries call in the BusinessGlossaryService service
#
# This snippet has been automatically generated and should be regarded as a code
# template only. It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in https://cloud.google.com/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::BusinessGlossaryService::Client#list_glossaries.
#
def list_glossaries
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::BusinessGlossaryService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::ListGlossariesRequest.new

  # Call the list_glossaries method.
  result = client.list_glossaries request

  # The returned object is of type Gapic::PagedEnumerable. You can iterate
  # over elements, and API calls will be issued to fetch pages as needed.
  result.each do |item|
    # Each element is of type ::Google::Cloud::Dataplex::V1::Glossary.
    p item
  end
end

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries

編輯詞彙表

你可以編輯術語表的名稱和說明。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 按一下要編輯的字彙表。

  3. 按一下名稱、說明或總覽旁的「編輯」,然後進行變更。

  4. 按一下 [儲存]

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID?update_mask=displayName,description --data @- << EOF
{
"displayName": "DISPLAY_NAME",
"description": "DESCRIPTION"
}
EOF

刪除詞彙表

如要刪除字彙表,必須先刪除字彙表中的所有類別字詞

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 按一下要刪除的字彙表。

  3. 按一下「Delete」(刪除),然後在系統提示時確認刪除。

C#

C#

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 C# 設定說明操作。詳情請參閱 Knowledge Catalog C# API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

using Google.Cloud.Dataplex.V1;
using Google.LongRunning;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedBusinessGlossaryServiceClientSnippets
{
    /// <summary>Snippet for DeleteGlossary</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void DeleteGlossaryRequestObject()
    {
        // Create client
        BusinessGlossaryServiceClient businessGlossaryServiceClient = BusinessGlossaryServiceClient.Create();
        // Initialize request argument(s)
        DeleteGlossaryRequest request = new DeleteGlossaryRequest
        {
            GlossaryName = GlossaryName.FromProjectLocationGlossary("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
            Etag = "",
        };
        // Make the request
        Operation<Empty, OperationMetadata> response = businessGlossaryServiceClient.DeleteGlossary(request);

        // Poll until the returned long-running operation is complete
        Operation<Empty, OperationMetadata> completedResponse = response.PollUntilCompleted();
        // Retrieve the operation result
        Empty result = completedResponse.Result;

        // Or get the name of the operation
        string operationName = response.Name;
        // This name can be stored, then the long-running operation retrieved later by name
        Operation<Empty, OperationMetadata> retrievedResponse = businessGlossaryServiceClient.PollOnceDeleteGlossary(operationName);
        // Check if the retrieved long-running operation has completed
        if (retrievedResponse.IsCompleted)
        {
            // If it has completed, then access the result
            Empty retrievedResult = retrievedResponse.Result;
        }
    }
}

Go

Go

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Go 設定說明操作。詳情請參閱 Knowledge Catalog Go API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。


//go:build examples

package main

import (
	"context"

	dataplex "cloud.google.com/go/dataplex/apiv1"
	dataplexpb "cloud.google.com/go/dataplex/apiv1/dataplexpb"
)

func main() {
	ctx := context.Background()
	// This snippet has been automatically generated and should be regarded as a code template only.
	// It will require modifications to work:
	// - It may require correct/in-range values for request initialization.
	// - It may require specifying regional endpoints when creating the service client as shown in:
	//   https://pkg.go.dev/cloud.google.com/go#hdr-Client_Options
	c, err := dataplex.NewBusinessGlossaryClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.DeleteGlossaryRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#DeleteGlossaryRequest.
	}
	op, err := c.DeleteGlossary(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}

	err = op.Wait(ctx)
	if err != nil {
		// TODO: Handle error.
	}
}

Java

Java

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Java 設定說明操作。詳情請參閱 Knowledge Catalog Java API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

import com.google.cloud.dataplex.v1.BusinessGlossaryServiceClient;
import com.google.cloud.dataplex.v1.DeleteGlossaryRequest;
import com.google.cloud.dataplex.v1.GlossaryName;
import com.google.protobuf.Empty;

public class SyncDeleteGlossary {

  public static void main(String[] args) throws Exception {
    syncDeleteGlossary();
  }

  public static void syncDeleteGlossary() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (BusinessGlossaryServiceClient businessGlossaryServiceClient =
        BusinessGlossaryServiceClient.create()) {
      DeleteGlossaryRequest request =
          DeleteGlossaryRequest.newBuilder()
              .setName(GlossaryName.of("[PROJECT]", "[LOCATION]", "[GLOSSARY]").toString())
              .setEtag("etag3123477")
              .build();
      businessGlossaryServiceClient.deleteGlossaryAsync(request).get();
    }
  }
}

Node.js

Node.js

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Node.js 設定說明操作。詳情請參閱 Knowledge Catalog Node.js API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

/**
 * This snippet has been automatically generated and should be regarded as a code template only.
 * It will require modifications to work.
 * It may require correct/in-range values for request initialization.
 * TODO(developer): Uncomment these variables before running the sample.
 */
/**
 *  Required. The name of the Glossary to delete.
 *  Format:
 *  projects/{project_id_or_number}/locations/{location_id}/glossaries/{glossary_id}
 */
// const name = 'abc123'
/**
 *  Optional. The etag of the Glossary.
 *  If this is provided, it must match the server's etag.
 *  If the etag is provided and does not match the server-computed etag,
 *  the request must fail with a ABORTED error code.
 */
// const etag = 'abc123'

// Imports the Dataplex library
const {BusinessGlossaryServiceClient} = require('@google-cloud/dataplex').v1;

// Instantiates a client
const dataplexClient = new BusinessGlossaryServiceClient();

async function callDeleteGlossary() {
  // Construct request
  const request = {
    name,
  };

  // Run request
  const [operation] = await dataplexClient.deleteGlossary(request);
  const [response] = await operation.promise();
  console.log(response);
}

callDeleteGlossary();

Python

Python

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Python 設定說明操作。詳情請參閱 Knowledge Catalog Python API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

# This snippet has been automatically generated and should be regarded as a
# code template only.
# It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
#   client as shown in:
#   https://googleapis.dev/python/google-api-core/latest/client_options.html
from google.cloud import dataplex_v1


def sample_delete_glossary():
    # Create a client
    client = dataplex_v1.BusinessGlossaryServiceClient()

    # Initialize request argument(s)
    request = dataplex_v1.DeleteGlossaryRequest(
        name="name_value",
    )

    # Make the request
    operation = client.delete_glossary(request=request)

    print("Waiting for operation to complete...")

    response = operation.result()

    # Handle the response
    print(response)

Ruby

Ruby

在試用這個範例之前,請先按照「使用用戶端程式庫的 Knowledge Catalog 快速入門導覽課程」中的 Ruby 設定說明操作。詳情請參閱 Knowledge Catalog Ruby API 參考文件

如要向 Knowledge Catalog 進行驗證,請設定應用程式預設憑證。詳情請參閱「為本機開發環境設定驗證機制」。

require "google/cloud/dataplex/v1"

##
# Snippet for the delete_glossary call in the BusinessGlossaryService service
#
# This snippet has been automatically generated and should be regarded as a code
# template only. It will require modifications to work:
# - It may require correct/in-range values for request initialization.
# - It may require specifying regional endpoints when creating the service
# client as shown in https://cloud.google.com/ruby/docs/reference.
#
# This is an auto-generated example demonstrating basic usage of
# Google::Cloud::Dataplex::V1::BusinessGlossaryService::Client#delete_glossary.
#
def delete_glossary
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::BusinessGlossaryService::Client.new

  # Create a request. To set request fields, pass in keyword arguments.
  request = Google::Cloud::Dataplex::V1::DeleteGlossaryRequest.new

  # Call the delete_glossary method.
  result = client.delete_glossary request

  # The returned object is of type Gapic::Operation. You can use it to
  # check the status of an operation, cancel it, or wait for results.
  # Here is how to wait for a response.
  result.wait_until_done! timeout: 60
  if result.response?
    p result.response
  else
    puts "No response received."
  end
end

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X DELETE https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID

建立及管理類別

下列各節說明如何建立、查看、更新及刪除類別。

在詞彙表下建立類別

組織詞彙最多可有 200 個類別。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 選取要建立類別的字彙表,然後按一下「建立類別」

  3. 輸入類別名稱。

  4. 點選「建立」

  5. 選用:在「說明」Description中新增簡短說明 (最多 1,024 個字元), 或在「總覽」Overview中新增詳細說明 (最多 120 KB)。

REST

建立類別時,Knowledge Catalog 會建立代表該類別的項目

  1. 建立類別。

    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
    
    gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories?category_id=CATEGORY_ID --data @- << EOF
    {
    "displayName": "CATEGORY_DISPLAY_NAME",
    "description": "CATEGORY_DESCRIPTION",
    "parent": "projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID"
    }
    EOF

    更改下列內容:

    • CATEGORY_ID:類別 ID
    • CATEGORY_DISPLAY_NAME:類別顯示名稱
    • CATEGORY_DESCRIPTION:類別說明
  2. 選用:為類別新增總覽。

    1. 查詢類別的項目:

      gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID
      :lookupEntry\
      ?entry=projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID
      \
      \&view=ALL
    2. 為類別新增總覽:

      gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID\
      ?update_mask=aspects\
      \&deleteMissingAspects=false\
      \&aspect_keys=projects/dataplex-types/locations/global/aspectTypes/overview
      \
      --data @- << EOF
      {
      "aspects": {
      "dataplex-types.global.overview": {
         "aspect_type":"projects/dataplex-types/locations/global/aspectTypes/overview
      ",
         "data": {
         "content": "OVERVIEW",
         "links": []
         },
      }
      }
      }
      EOF

      OVERVIEW 替換為純文字或 HTML,用來描述字彙表類別或字詞。

  3. 選用:新增聯絡人

    1. 查詢類別的項目:

      gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID
      :lookupEntry\
      ?entry=projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID
      \
      \&view=ALL
    2. 更新類別的項目,加入聯絡人:

      gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID\
      ?update_mask=aspects\
      \&deleteMissingAspects=false\
      \&aspect_keys=projects/dataplex-types/locations/global/aspectTypes/contacts \
      --data @- << EOF
      {
      "aspects": {
      "dataplex-types.global.contacts": {
         "aspect_type": "projects/dataplex-types/locations/global/aspectTypes/contacts",
         "data": {
         "identities": [
            {
               "role": "steward",
               "name": "CONTACT_NAME",
               "id": "CONTACT_EMAIL"
            }
         ]
         },
      }
      }
      }
      EOF

建立巢狀類別

組織詞彙最多可有三個巢狀類別層級,根詞彙表層級除外。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 展開要建立類別的字彙表。

  3. 選取要建立其他類別的父類別,然後按一下「建立類別」

  4. 輸入類別名稱。

  5. 點選「建立」

  6. 選用:在「說明」Description中新增簡短說明 (最多 1,024 個字元), 或在「總覽」Overview中新增詳細說明 (最多 120 KB)。

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories?category_id=CATEGORY_ID --data @- << EOF
{
  "displayName": "CATEGORY_DISPLAY_NAME",
  "description": "CATEGORY_DESCRIPTION",
  "parent": "projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/PARENT_CATEGORY_ID"
}
EOF

PARENT_CATEGORY_ID 替換為父類別的 ID。

查看術語表所屬的類別

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 如要查看詞彙表中的類別,請展開詞彙表。

  3. 如要查看類別中的巢狀類別,請展開該類別。

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories

編輯類別

你可以編輯類別的名稱、說明和聯絡人。如果是巢狀類別,你也可以編輯父類別。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 展開字彙表,然後按一下要編輯的類別。

  3. 按一下名稱、說明或總覽旁的「編輯」,然後進行變更。

  4. 按一下 [儲存]

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID?update_mask=displayName,description --data @- << EOF
{
"displayName": "CATEGORY_DISPLAY_NAME",
"description": "DESCRIPTION"
}
EOF

刪除類別

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 展開術語表,然後按一下要刪除的類別。

  3. 按一下「Delete」(刪除),然後在系統提示時確認刪除。

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X DELETE https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID

建立及管理字詞

下列各節說明如何建立、查看、存取、編輯及刪除字詞。

在組織詞彙下建立字詞

組織詞彙最多可包含 5,000 個字詞。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 如要在術語表層級建立術語,請選取要建立術語的術語表,然後按一下「建立術語」

  3. 輸入字詞名稱。

  4. 點選「建立」

  5. 選用:在「說明」Description中新增簡短說明 (最多 1,024 個字元), 或在「總覽」Overview中新增詳細說明 (最多 120 KB)。

  6. 選用:如要新增聯絡人,請按一下「編輯」,然後提供資料管理員、資料擁有者或資料網域擁有者的電子郵件地址清單。 選擇這個選項後,按一下 [儲存]

REST

建立字詞時,Knowledge Catalog 會建立項目來代表該字詞。

  1. 建立字詞。

    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
    
    gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms?term_id=TERM_ID --data @- << EOF
    {
    "displayName": "TERM_DISPLAY_NAME",
    "description": "TERM_DESCRIPTION",
    "parent": "projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID"
    }
    EOF

    更改下列內容:

    • TERM_ID:您要建立的字詞 ID
    • TERM_DISPLAY_NAME:要建立的字詞顯示名稱
    • TERM_DESCRIPTION:您要建立的字詞說明
  2. 選用:為字詞新增總覽。

    1. 查閱 Look 圖表的項目:

      gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID
      :lookupEntry\
      ?entry=projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID
      \
      \&view=ALL
    2. 為字詞新增總覽:

      gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID
      \
      ?update_mask=aspects\
      \&deleteMissingAspects=false\
      \&aspect_keys=projects/dataplex-types/locations/global/aspectTypes/overview
      \
      --data @- << EOF
      {
      "aspects": {
      "dataplex-types.global.overview": {
         "aspect_type":"projects/dataplex-types/locations/global/aspectTypes/overview
      ",
         "data": {
         "content": "OVERVIEW",
         "links": []
         },
      }
      }
      }
      EOF

      OVERVIEW 替換為純文字或 HTML,用來描述字彙表類別或字詞。

  3. 選用:新增聯絡人。

    1. 查閱 Look 圖表的項目:

      gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID
      :lookupEntry\
      ?entry=projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID
      \
      \&view=ALL
    2. 更新學期項目,加入聯絡人:

      gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID
      ?update_mask=aspects\
      \&deleteMissingAspects=false\
      \&aspect_keys=projects/dataplex-types/locations/global/aspectTypes/contacts \
      --data @- << EOF
      {
      "aspects": {
      "dataplex-types.global.contacts": {
         "aspect_type": "projects/dataplex-types/locations/global/aspectTypes/contacts",
         "data": {
         "identities": [
            {
               "role": "steward",
               "name": "CONTACT_NAME",
               "id": "CONTACT_EMAIL"
            }
         ]
         },
      }
      }
      }
      EOF

在類別下建立字詞

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 如要在類別中建立字詞,請選取要建立字詞的類別,然後按一下「新增字詞」

  3. 輸入字詞名稱。

  4. 點選「建立」

  5. 選用:在「說明」Description中新增簡短說明 (最多 1,024 個字元), 或在「總覽」Overview中新增詳細說明 (最多 120 KB)。

  6. 選用:如要新增聯絡人,請按一下「編輯」,然後提供資料管理員、資料擁有者或資料網域擁有者的電子郵件地址清單。 選擇這個選項後,按一下 [儲存]

REST

建立字詞時,Knowledge Catalog 會建立項目來代表該字詞。

  1. 建立字詞。

    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
    
    gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms?term_id=TERM_ID --data @- << EOF
    {
    "displayName": "TERM_DISPLAY_NAME",
    "description": "TERM_DESCRIPTION",
    "parent": "projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/PARENT_CATEGORY_ID"
    }
    EOF

    更改下列內容:

    • TERM_ID:您要建立的字詞 ID
    • TERM_DISPLAY_NAME:要建立的字詞顯示名稱
    • TERM_DESCRIPTION:您要建立的字詞說明
  2. 選用:為字詞新增總覽。

    1. 查閱 Look 圖表的項目:

      gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID
      :lookupEntry\
      ?entry=projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID
      \
      \&view=ALL
    2. 為字詞新增總覽:

      gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID
      \
      ?update_mask=aspects\
      \&deleteMissingAspects=false\
      \&aspect_keys=projects/dataplex-types/locations/global/aspectTypes/overview
      \
      --data @- << EOF
      {
      "aspects": {
      "dataplex-types.global.overview": {
         "aspect_type":"projects/dataplex-types/locations/global/aspectTypes/overview
      ",
         "data": {
         "content": "OVERVIEW",
         "links": []
         },
      }
      }
      }
      EOF

      OVERVIEW 替換為純文字或 HTML,用來描述字彙表類別或字詞。

  3. 選用:新增聯絡人。

    1. 查閱 Look 圖表的項目:

      gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID
      :lookupEntry\
      ?entry=projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID
      \
      \&view=ALL
    2. 更新學期項目,加入聯絡人:

      gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID
      ?update_mask=aspects\
      \&deleteMissingAspects=false\
      \&aspect_keys=projects/dataplex-types/locations/global/aspectTypes/contacts \
      --data @- << EOF
      {
      "aspects": {
      "dataplex-types.global.contacts": {
         "aspect_type": "projects/dataplex-types/locations/global/aspectTypes/contacts",
         "data": {
         "identities": [
            {
               "role": "steward",
               "name": "CONTACT_NAME",
               "id": "CONTACT_EMAIL"
            }
         ]
         },
      }
      }
      }
      EOF

為字詞新增切面

您可以為字詞新增切面,提供額外背景資訊或中繼資料。

控制台

  1. 前往 Google Cloud 控制台的 Knowledge Catalog「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 展開字彙表,然後按一下要新增面向的字詞。

  3. 在「層面」部分中,按一下「新增」

  4. 搜尋該層面,提供該層面的詳細資料,然後按一下「儲存」

REST

詞彙表字詞就是項目。如要附加切面,請修補項目資源。 詞彙表的項目群組為 @dataplex

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID?update_mask=aspects\&aspect_keys=ASPECT_PROJECT_ID.ASPECT_LOCATION_ID.ASPECT_TYPE_ID --data @- << EOF
{
 "aspects": {
   "ASPECT_PROJECT_ID.ASPECT_LOCATION_ID.ASPECT_TYPE_ID": {
     "aspect_type": "projects/ASPECT_PROJECT_ID/locations/ASPECT_LOCATION_ID/aspectTypes/ASPECT_TYPE_ID",
     "data": {
       "sensitivity": "HIGH",
       "data_owner": "achalg@google.com"
     }
   }
 }
}
EOF

更改下列內容:

  • PROJECT_NUMBER:包含詞彙表項目的專案編號。
  • LOCATION_ID:詞彙表字詞的位置。
  • GLOSSARY_ID:包含字詞的詞彙表 ID。
  • TERM_ID:要附加層面的字詞 ID。
  • ASPECT_PROJECT_ID:包含構面類型的專案 ID。
  • ASPECT_LOCATION_ID:構面類型的位置。
  • ASPECT_TYPE_ID:切面類型 ID。

查看詞彙表或類別中的字詞

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 如要查看詞彙中的字詞,請展開詞彙。如要查看本詞彙表中的類別,請展開該類別。如要查看巢狀類別中的字詞,請展開巢狀類別。

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms

查看字詞詳細資料

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 如要查看詞彙表中的字詞清單,請展開詞彙表。

  3. 按一下字詞,「字詞詳細資料」頁面會顯示字詞名稱、說明、相關字詞、同義字和相關項目。

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID

編輯條件

您可以編輯學期的名稱、說明、總覽、聯絡人和上層學期。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 展開字彙表,然後按一下要編輯的字詞。

  3. 按一下 [編輯]

  4. 編輯任何欄位,然後按一下「儲存」

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X PATCH https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID?update_mask=displayName,description --data @- << EOF
{
  "displayName": "TERM_DISPLAY_NAME",
  "description": "TERM_DESCRIPTION"
}
EOF

刪除字詞

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 展開字彙表,然後按一下要刪除的字詞。

  3. 按一下「Delete」(刪除),然後在系統提示時確認刪除。

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X DELETE https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM_ID

您可以將字詞連結為同義字或相關字詞,藉此新增字詞之間的關係。

術語關係是雙向的。舉例來說,如果將 profit 連結為 earnings 的同義字,earnings 也會成為 profit 的同義字。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 展開字彙表,然後按一下要建立連結的字詞。

  3. 按一下「同義字詞」旁的「編輯」

  4. 搜尋並選取要連結的字詞。

    選取字詞後,系統會立即連結。

  5. 按一下 [關閉]

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X POST https://dataplex.googleapis.com/v1/projects/TERM1_PROJECT_ID/locations/TERM1_LOCATION_ID/entryGroups/@dataplex/entryLinks?entry_link_id=ENTRY_LINK_ID -d "$(cat<<EOF
{
  "entry_link_type": "projects/dataplex-types/locations/global/entryLinkTypes/synonym",
"entry_references": [{
     "name": "projects/TERM1_PROJECT_NUMBER/locations/TERM1_LOCATION_ID/entryGroups/@dataplex/entries/projects/TERM1_PROJECT_NUMBER/locations/TERM1_LOCATION_ID/glossaries/TERM1_GLOSSARY_ID/terms/TERM1_ID",
     "type": "UNSPECIFIED"
  }, {
     "name": "projects/TERM2_PROJECT_NUMBER/locations/TERM2_LOCATION_ID/entryGroups/@dataplex/entries/projects/TERM2_PROJECT_NUMBER/locations/TERM2_LOCATION_ID/glossaries/TERM2_GLOSSARY_ID/terms/TERM2_ID",
     "type": "UNSPECIFIED"
  }
  ]

}
EOF
)"

更改下列內容:

  • TERM1_PROJECT_NUMBER:要連結的第一個學期的專案編號。
  • TERM1_LOCATION_ID:包含第一個字詞的詞彙表地區 ID。
  • TERM1_GLOSSARY_ID:包含第一個字詞的詞彙表 ID。
  • TERM1_ID:第一個字詞的 ID。
  • TERM2_PROJECT_NUMBER:要連結為同義字詞的第二個字詞專案編號。如果兩個學期都在同一個專案中,這個值會與第一個學期的專案編號相同。
  • TERM2_LOCATION_ID:包含第二個字詞的詞彙表地區 ID。如果兩個學期都在同一個地點,這個值會與第一個學期的地點 ID 相同。
  • TERM2_GLOSSARY_ID:包含第二個字詞的詞彙表 ID。如果兩個字詞位於同一個字彙表,這個值會與第一個字詞的字彙表 ID 相同。
  • TERM2_ID:第二個字詞的 ID。
  • ENTRY_LINK_ID:兩個字詞之間連結的 ID。每個字詞都以 Knowledge Catalog 項目表示。 項目連結是同義字詞之間的關係。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 展開字彙表,然後按一下要建立連結的字詞。

  3. 按一下「相關字詞」旁的「編輯」

  4. 搜尋並選取要連結的字詞。

    選取字詞後,系統會立即連結。

  5. 按一下 [關閉]

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X POST https://dataplex.googleapis.com/v1/projects/TERM1_PROJECT_ID/locations/TERM1_LOCATION_ID/entryGroups/@dataplex/entryLinks?entry_link_id=ENTRY_LINK_ID -d "$(cat<<EOF
{
  "entry_link_type": "projects/dataplex-types/locations/global/entryLinkTypes/related",
"entry_references": [{
     "name": "projects/TERM1_PROJECT_NUMBER/locations/TERM1_LOCATION_ID/entryGroups/@dataplex/entries/projects/TERM1_PROJECT_NUMBER/locations/TERM1_LOCATION_ID/glossaries/TERM1_GLOSSARY_ID/terms/TERM1_ID",
     "type": "UNSPECIFIED"
  }, {
     "name": "projects/TERM2_PROJECT_NUMBER/locations/TERM2_LOCATION_ID/entryGroups/@dataplex/entries/projects/TERM2_PROJECT_NUMBER/locations/TERM2_LOCATION_ID/glossaries/TERM2_GLOSSARY_ID/terms/TERM2_ID",
     "type": "UNSPECIFIED"
  }
  ]

}
EOF
)"

更改下列內容:

  • TERM1_PROJECT_NUMBER:要連結的第一個字詞的專案編號。
  • TERM1_LOCATION_ID:包含第一個字詞的詞彙表地區 ID。
  • TERM1_GLOSSARY_ID:包含第一個字詞的詞彙表 ID。
  • TERM1_ID:第一個字詞的 ID。
  • TERM2_PROJECT_NUMBER:要連結為相關字詞的第二個字詞專案編號。如果兩個學期都在同一個專案中,這個值會與第一個學期的專案編號相同。
  • TERM2_LOCATION_ID:包含第二個字詞的詞彙表地區 ID。如果兩個學期都在同一個地點,這個值會與第一個學期的地點 ID 相同。
  • TERM2_GLOSSARY_ID:包含第二個字詞的詞彙表 ID。如果兩個字詞位於同一個字彙表,這個值會與第一個字詞的字彙表 ID 相同。
  • TERM2_ID:第二個字詞的 ID。
  • ENTRY_LINK_ID:兩個字詞之間連結的 ID。每個字詞都以 Knowledge Catalog 項目表示。 項目連結是相關字詞之間的關係。

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X POST https://dataplex.googleapis.com/v1/projects/TERM_PROJECT_ID/locations/SYNONYM_LINKS_LOCATION_ID:lookupEntryLinks?entry=projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/entryGroups/@dataplex/entries/projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/glossaries/TERM_GLOSSARY_ID/terms/TERM_ID&entry_link_types=projects/dataplex-types/locations/global/entryLinkTypes/synonym&page_size=10

更改下列內容:

  • TERM_PROJECT_ID:您要查詢同義字連結的字詞專案 ID。
  • TERM_PROJECT_NUMBER:您要查詢同義字連結的字詞專案編號。
  • SYNONYM_LINKS_LOCATION_ID:您要查詢同義字連結的地區 ID。
  • TERM_LOCATION_ID:地區 ID。
  • TERM_GLOSSARY_ID:包含該字詞的詞彙表 ID。
  • TERM_ID:字詞的 ID。

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X POST https://dataplex.googleapis.com/v1/projects/TERM_PROJECT_ID/locations/RELATED_LINKS_LOCATION_ID:lookupEntryLinks?entry=projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/entryGroups/@dataplex/entries/projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/glossaries/TERM_GLOSSARY_ID/terms/TERM_ID&entry_link_types=projects/dataplex-types/locations/global/entryLinkTypes/related&page_size=10

更改下列內容:

  • TERM_PROJECT_ID:您要查詢相關連結的字詞專案 ID。
  • TERM_PROJECT_NUMBER:要查詢相關連結的字詞專案編號。
  • RELATED_LINKS_LOCATION_ID:您要查詢相關連結的地區 ID。
  • TERM_LOCATION_ID:地區 ID。
  • TERM_GLOSSARY_ID:包含該字詞的詞彙表 ID。
  • TERM_ID:字詞的 ID。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 展開詞彙表,然後按一下要移除同義詞或相關字詞的字詞。

  3. 如要刪除相關字詞之間的連結,請按一下「相關字詞」旁邊的「編輯」。 刪除相關字詞,然後按一下「關閉」

  4. 如要刪除同義字之間的連結,請按一下「同義字」旁邊的「編輯」。 刪除同義字,然後按一下「關閉」

REST

  1. 查詢項目連結,找出要刪除的連結項目連結 ID。詳情請參閱「查詢字詞的同義字連結」或「查詢字詞的相關連結」。

  2. 傳送下列 DELETE 要求,刪除連結:

    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
    
    gcurl -X DELETE https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/entryGroups/ENTRY_GROUP_ID/entryLinks/ENTRY_LINK_ID

您可以將字詞附加至資料資產或資料資產欄。舉例來說,您可以將字詞附加至 BigQuery 資料集和 Iceberg REST 目錄資料表。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Search」(搜尋) 頁面。

    前往「搜尋」

  2. 搜尋要連結字詞的資料資產 (例如資料集、檔案或表格),然後按一下該資產。

  3. 在資料資產頁面上,執行下列任一操作:

    • 如要將詞彙連結至資產,請在「詳細資料」分頁的「詞彙」部分中,按一下「新增」。搜尋並選取字詞,然後按一下「關閉」
    • 如果資產有結構定義,您可以將字詞連結至欄。在「結構定義」分頁中,選取要連結字詞的資料欄,然後按一下「新增業務字詞」。搜尋並選取字詞,然後按一下「關閉」

Python

from google.cloud import dataplex_v1

def attach_term_to_asset(
    project_id: str,
    location: str,
    entry_group_id: str,
    entry_link_id: str,
    source_entry_name: str,
    target_term_name: str,
) -> dataplex_v1.EntryLink:
    """Creates an entry link attaching a glossary term to a data asset."""
    client = dataplex_v1.CatalogServiceClient()
    parent_group = (
        f"projects/{project_id}/locations/{location}/"
        f"entryGroups/{entry_group_id}"
    )

    entry_link = dataplex_v1.EntryLink(
        entry_link_type=(
            "projects/dataplex-types/locations/global/"
            "entryLinkTypes/definition"
        ),
        entry_references=[
            dataplex_v1.EntryLink.EntryReference(
                name=source_entry_name, type_="SOURCE"
            ),
            dataplex_v1.EntryLink.EntryReference(
                name=target_term_name, type_="TARGET"
            ),
        ],
    )

    return client.create_entry_link(
        parent=parent_group,
        entry_link_id=entry_link_id,
        entry_link=entry_link,
    )

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/ENTRY_LOCATION_ID/entryGroups/ENTRY_GROUP_ID/entryLinks?entry_link_id=ENTRY_LINK_ID -d "$(cat<<EOF
{
  "entry_link_type": "projects/dataplex-types/locations/global/entryLinkTypes/definition",
  "entry_references": [{
     "name": "projects/PROJECT_NUMBER/locations/ENTRY_LOCATION_ID/entryGroups/ENTRY_GROUP_ID/entries/ENTRY_ID",
     "type": "SOURCE"
  }, {
     "name": "projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/entryGroups/@dataplex/entries/projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/glossaries/TERM_GLOSSARY_ID/terms/TERM_ID",
     "type": "TARGET"
  }
  ]
}
EOF
)"

更改下列內容:

  • PROJECT_NUMBER:要連結的資料資產專案編號
  • ENTRY_LOCATION_ID:要連結的資料資產地區 ID
  • ENTRY_GROUP_ID:要連結的資料資產項目群組
  • ENTRY_LINK_ID:術語與代表資料資產的 Knowledge Catalog 項目之間的連結 ID。
  • TERM_PROJECT_NUMBER:要連結的字詞專案編號。

將字詞附加至項目結構定義中的資料欄

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Search」(搜尋) 頁面。

    前往「搜尋」

  2. 搜尋具有架構的資料資產 (例如資料集、檔案或資料表),該架構包含您要連結字詞的資料欄。按一下資料資產。

  3. 在資料資產頁面上,執行下列任一操作:

    • 如要將字詞連結至資料資產中的資料欄,請在「結構定義」分頁中,選取要附加字詞的資料欄。
    • 按一下「新增企業字詞」。搜尋要附加的字詞,然後按一下該字詞進行附加。

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_NUMBER/locations/ENTRY_LOCATION_ID/entryGroups/ENTRY_GROUP_ID/entryLinks?entry_link_id=ENTRY_LINK_ID -d "$(cat<<EOF
{
 "entry_link_type": "projects/dataplex-types/locations/global/entryLinkTypes/definition",
 "entry_references": [
   {
     "name": "projects/PROJECT_NUMBER/locations/ENTRY_LOCATION_ID/entryGroups/ENTRY_GROUP_ID/entries/ENTRY_ID",
     "path": "Schema.COLUMN_NAME",
     "type": "SOURCE"
   },
   {
     "name": "projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/entryGroups/@dataplex/entries/projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/glossaries/TERM_GLOSSARY_ID/terms/TERM_ID",
     "type": "TARGET"
   }
 ]
}
EOF
)"

更改下列內容:

  • PROJECT_NUMBER:要連結的資料資產專案編號
  • ENTRY_LOCATION_ID:要連結的資料資產地區 ID
  • ENTRY_GROUP_ID:要連結的資料資產項目群組
  • ENTRY_LINK_ID:術語與代表資料資產的 Knowledge Catalog 項目之間的連結 ID
  • TERM_PROJECT_NUMBER:要連結的字詞專案編號
  • COLUMN_NAME:要附加字詞的資料欄

將詞彙附加至多個資料資產或資料欄

您可以同時將單一詞彙附加至多個資料資產或資料欄。單一作業最多可選取 20 個資源或資料欄。

控制台

如要將字詞附加至多項資源,請按照下列步驟操作:

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 在「字彙表」清單中,展開包含要連結字詞的字彙表。

  3. 按一下學期。

  4. 在「相關項目」部分中,按一下 「新增」

  5. 在「Attach related entries」(附加相關項目) 對話方塊中,完成下列步驟:

    1. 找出要連結的資源或資料欄。如要縮小搜尋結果範圍,請使用「篩選器」,依資源名稱、資源類型或資料欄名稱搜尋。

      舉例來說,如要在 ID 為 sample-project 的專案中,尋找名為 sample-table 的 BigQuery 資料表內名為 sample-column 的資料欄,請使用下列查詢:

      project id:sample-project
      Resource Name:sample-table
      Column Name:sample-column
      

      您可以輸入部分字串,找出相符的資產。

    2. 選取要附加的資料資產和資料欄。

    3. 如要在新增前查看所選資源,請按一下「顯示所選資源」切換按鈕。

    4. 按一下「新增」。

  6. 如要驗證新附加的資源和資料欄,請前往詞彙詳細資料頁面的「相關項目」部分。

查詢與字詞連結的資料資產

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X POST https://dataplex.googleapis.com/v1/projects/TERM_PROJECT_ID/locations/DEFINITION_LINKS_LOCATION_ID:lookupEntryLinks?entry=projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/entryGroups/@dataplex/entries/projects/TERM_PROJECT_NUMBER/locations/TERM_LOCATION_ID/glossaries/TERM_GLOSSARY_ID/terms/TERM_ID&entry_link_types=projects/dataplex-types/locations/global/entryLinkTypes/definition&entry_mode=TARGET&page_size=10

更改下列內容:

  • TERM_PROJECT_ID:您要查詢定義連結的字詞專案 ID。
  • TERM_PROJECT_NUMBER:您要查詢定義連結的字詞專案編號。
  • DEFINITION_LINKS_LOCATION_ID:您要查詢定義連結的地區 ID。
  • TERM_LOCATION_ID:地區 ID。
  • TERM_GLOSSARY_ID:包含該字詞的詞彙表 ID。
  • TERM_ID:字詞的 ID。

連結至資料資產的查詢字詞

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/DEFINITION_LINKS_LOCATION_ID:lookupEntryLinks?entry=projects/PROJECT_NUMBER/locations/ENTRY_LOCATION_ID/entryGroups/ENTRY_GROUP_ID/entries/ENTRY_ID&entry_link_types=projects/dataplex-types/locations/global/entryLinkTypes/definition&entry_mode=SOURCE&page_size=10

更改下列內容:

  • PROJECT_ID:您要查詢定義連結的資料資產專案 ID。
  • PROJECT_NUMBER:您要查詢定義連結的資料資產專案編號。
  • DEFINITION_LINKS_LOCATION_ID:您要查詢定義連結的地區 ID。
  • ENTRY_LOCATION_ID:資料資產的位置 ID。
  • ENTRY_GROUP_ID:資料資產的項目群組 ID。
  • ENTRY_ID:資料資產的 ID。

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Search」(搜尋) 頁面。

    前往「搜尋」

  2. 搜尋要移除字詞的資料資產 (例如資料集、檔案或資料表),然後按一下該資產。

  3. 在資料資產頁面上,執行下列任一操作:

    • 如要從資產中移除字詞,請在「詳細資料」分頁的「字彙表字詞」部分中,按一下該字詞。然後按一下
    • 如要從資料欄中移除字詞,請在「結構定義」分頁中,點選該字詞旁的

REST

alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'

gcurl -X DELETE https://dataplex.googleapis.com/v1/projects/ENTRY_PROJECT_ID/locations/ENTRY_LOCATION_ID/entryGroups/ENTRY_GROUP_ID/entryLinks/ENTRY_LINK_ID

尋找詞彙表、字詞和已連結的資料資產

控制台

如要瀏覽組織詞彙內容,請使用「詞彙」頁面上的詞彙和字詞樹狀結構。

  1. 前往 Google Cloud 控制台的 Knowledge Catalog「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 在「字彙表」頁面,使用篩選列尋找類別。可用的篩選器如下:

    • 名稱:傳回名稱包含您提供文字的字彙表、類別和字詞。
    • 父項:傳回父項術語表名稱或說明與您提供的文字相符的術語。舉例來說,如果父項字彙表的名稱或說明包含「Finance」這個詞組,parent:Finance 就會傳回與該字彙表相關聯的字詞。
    • 同義字:傳回同義字清單,其中名稱或 ID 包含您提供的文字。舉例來說,synonym:Profit 會傳回含有同義字詞的字詞,而同義字詞的名稱或 ID 包含「profit」這個片語。
    • 聯絡人:傳回資料監管員列為聯絡人的字詞。舉例來說,contact:alex@example.com 會傳回與資料管理員符合 alex@example.com 的字詞相關聯的項目。

REST

如要使用 REST API 尋找詞彙表、字詞和連結的資料資產,請註冊加入搶先體驗計畫

搜尋與字詞相關聯的資料資產

控制台

  1. 在 Google Cloud 控制台,前往 Knowledge Catalog 的「Glossaries」(詞彙表) 頁面。

    前往「字彙表」

  2. 在「字彙表」頁面,使用篩選列輸入任意文字搜尋查詢。這會傳回字彙表、類別和字詞名稱中相應的相符項目清單。

  3. 按一下相符的字詞。

  4. 在「字詞詳細資料」頁面,查看連結至這個字詞的字詞 (同義字和相關字詞) 和連結項目 (資料資產)。

  5. 如要查看 Knowledge Catalog 中項目的詳細資料,請按一下該項目。

REST

如要使用 REST API 尋找詞彙表、字詞和連結的資料資產,請註冊加入搶先體驗計畫

匯入詞彙表,以及字詞與字詞或資料資產之間的連結

如要從其他編目工具匯入詞彙表和連結,或更新 Knowledge Catalog 中的詞彙表,可以使用 REST API 大量匯入詞彙表、類別、字詞、字詞之間的連結、字詞與資料資產之間的連結,或欄。

  1. 建立目標詞彙表。

    REST

    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
    
    gcurl -X POST https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/glossaries?glossary_id=GLOSSARY_ID -d "$(cat<<EOF
    
    {
     "displayName": "DISPLAY_NAME",
     "description": "DESCRIPTION"
    }
    EOF
    )"

    更改下列內容:

    • PROJECT_ID:您要建立詞彙表的專案 ID
    • LOCATION_ID:要建立詞彙表的位置
    • GLOSSARY_ID:詞彙表 ID
    • DISPLAY_NAME:詞彙表的顯示名稱
    • DESCRIPTION:詞彙表說明
  2. 如要匯入目標詞彙表中的類別、字詞,以及字詞與資料資產之間的連結,請將這些檔案分別上傳至 Cloud Storage bucket。這些檔案的格式如下:

    • 詞彙表中的詞彙和類別範例格式

       {"entry":{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","entryType":"projects/dataplex-types/locations/global/entryTypes/glossary-category","aspects":{"dataplex-types.global.glossary-category-aspect":{"data":{}},"dataplex-types.global.overview":{"data":{"content":"CONTENT"}},"dataplex-types.global.contacts":{"data":{"identities":[{role: "steward", name: "CONTACT_DISPLAY_NAME", id: "CONTACT_EMAIL"}]}}},"parentEntry":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","entrySource":{"resource":"projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","displayName":"CATEGORY_NAME","description":"CATEGORY_DESCRIPTION","ancestors":[{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary"}]}}}
       {"entry":{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM1_ID","entryType":"projects/dataplex-types/locations/global/entryTypes/glossary-term","aspects":{"dataplex-types.global.glossary-term-aspect":{"data":{}},"dataplex-types.global.overview":{"data":{"content":"TERM1_CONTENT"}},"dataplex-types.global.contacts":{"data":{"identities":[{role: "steward", name: "CONTACT_DISPLAY_NAME", id: "CONTACT_EMAIL"}]}}},"parentEntry":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","entrySource":{"resource":"projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM1_ID","displayName":"TERM1_DISPLAY_NAME","description":"TERM1_DESCRIPTION","ancestors":[{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary"},{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary-category"}]}}}
       {"entry":{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM2_ID","entryType":"projects/dataplex-types/locations/global/entryTypes/glossary-term","aspects":{"dataplex-types.global.glossary-term-aspect":{"data":{}},"dataplex-types.global.overview":{"data":{"content":"TERM1_CONTENT"}},"dataplex-types.global.contacts":{"data":{"identities":[{role: "steward", name: "CONTACT_DISPLAY_NAME", id: "CONTACT_EMAIL"}]}}},"parentEntry":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","entrySource":{"resource":"projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/terms/TERM2_ID","displayName":"TERM2_DISPLAY_NAME","description":"TERM2_DESCRIPTION","ancestors":[{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary"},{"name":"projects/PROJECT_NUMBER/locations/LOCATION_ID/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/LOCATION_ID/glossaries/GLOSSARY_ID/categories/CATEGORY_ID","type":"projects/dataplex-types/locations/global/entryTypes/glossary-category"}]}}}
       
    • 字詞之間連結的範例格式

       {"entryLink":{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entryLinks/el-import-0606e3f2-8206-4f3a-aba9-32c6196f6048","entryLinkType":"projects/dataplex-types/locations/global/entryLinkTypes/synonym","entryReferences":[{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1"},{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-2"}]}}
       {"entryLink":{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entryLinks/el-import-2f7408e3-af3d-405d-81bb-861cf9ec5146","entryLinkType":"projects/dataplex-types/locations/global/entryLinkTypes/related","entryReferences":[{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1"},{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-2"}]}}
       
    • 字詞與資料資產連結的範例格式

       projects/PROJECT_NUMBER/locations/us-central1/entryGroups/entry-group-1/entries/entry-1 and term projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1
       {"entryLink":{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entryLinks/el-import-0606e3f2-8206-4f3a-aba9-32c6196f6048","entryLinkType":"projects/dataplex-types/locations/global/entryLinkTypes/definition","entryReferences":[{"name":"projects/PROJECT_NUMBER/locations/global/entryGroups/@dataplex/entries/projects/PROJECT_NUMBER/locations/global/glossaries/import-glossary/terms/term-1"},{"name":"projects/PROJECT_NUMBER/locations/us-central1/entryGroups/entry-group-1/entries/entry-1"}]}}
       
    # Set GCURL alias
    alias gcurl='curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json"'
    
    gcurl https://DATAPLEX_API/metadataJobs?metadata_job_id=JOB_ID -d "$(cat<<EOF
    {
      "type":"IMPORT",
      "import_spec":{
         "log_level":"DEBUG",
         "source_storage_uri":"gs://STORAGE_BUCKET/",
         "entry_sync_mode":"FULL",
         "aspect_sync_mode":"INCREMENTAL",
         "scope":{
            "glossaries": "GLOSSARY_NAME"
         }
      }
    }
    EOF
    )"

    DATAPLEX_API 替換為 Dataplex API 端點,格式為 dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID

  3. 選用:取得作業狀態。

    gcurl https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/operations/operation-OPERATION_ID

    OPERATION_ID 替換為作業 ID。

  4. 選用:取得中繼資料工作的狀態。

    gcurl -X GET https://dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/metadataJobs/JOB_ID
  5. 將字詞之間的連結匯入為同義詞或相關字詞。

    gcurl https://DATAPLEX_API/metadataJobs?metadata_job_id=JOB_ID -d "$(cat<<EOF
    {
      "type":"IMPORT",
      "import_spec":{
         "log_level":"DEBUG",
         "source_storage_uri":"gs://STORAGE_BUCKET/",
         "entry_sync_mode":"FULL",
         "aspect_sync_mode":"INCREMENTAL",
         "scope":{
            "entry_groups":[  "projects/PROJECT_ID/locations/LOCATION_ID/entryGroups/@dataplex"
            ],
            "entry_link_types":[
               "projects/dataplex-types/locations/global/entryLinkTypes/synonym",
               "projects/dataplex-types/locations/global/entryLinkTypes/related"
            ],
            "referenced_entry_scopes":[
               "PROJECT_IDS"
            ]
         }
      }
    }
    EOF
    )"

    DATAPLEX_API 替換為 dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID

  6. 匯入字詞與資料資產或資料欄之間的連結。

    如要建立詞彙表字詞與資料資產之間的連結,請為資料資產所屬的每個項目群組執行匯入作業。所有定義項目連結都會在這個項目群組中建立。

    gcurl https://DATAPLEX_API/metadataJobs?metadata_job_id=JOB_ID -d "$(cat<<EOF
    {
    "type":"IMPORT",
    "import_spec":{
      "log_level":"DEBUG",
      "source_storage_uri":"gs://STORAGE_BUCKET/",
      "entry_sync_mode":"FULL",
      "aspect_sync_mode":"INCREMENTAL",
      "scope":{
         "entry_groups":[  "projects/PROJECT_ID/locations/ENTRY_GROUP_LOCATION_ID/entryGroups/@dataplex"
         ],
         "entry_link_types":[
            "projects/dataplex-types/locations/global/entryLinkTypes/definition"
         ],
         "referenced_entry_scopes":[
            "PROJECT_IDS"
         ]
      }
    }
    }
    EOF
    )"

    DATAPLEX_API 替換為 dataplex.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID

定價

自 2025 年 7 月起,Knowledge Catalog 組織詞彙的計費方式將與中繼資料儲存空間相同。請參閱「Knowledge Catalog 中繼資料儲存空間定價」。

後續步驟