在 Knowledge Catalog 中搜尋資源

Knowledge Catalog (舊稱 Dataplex Universal Catalog) 提供強大的搜尋結果功能,可讓您透過統一的探索服務,查找及管理組織內的資料資產。Knowledge Catalog 採用 AI 輔助的自然語言搜尋功能,讓您以淺顯的用語提出問題,找出所需資料。

Knowledge Catalog 提供兩種搜尋模式:

  • 關鍵字搜尋功能可讓您使用特定關鍵字、篩選條件和定義的語法尋找資源。
  • 自然語言搜尋會運用 AI 技術,支援語意搜尋查詢。您可以使用日常用語尋找資源,不必再使用複雜的語法。

您可以運用 Knowledge Catalog 探索代理程式,回答複雜的自然語言查詢。詳情請參閱「建立代理程式來探索資料」。

用途

Knowledge Catalog 搜尋功能為各種機構和利害關係人提供下列體驗:

  • 自助式資料探索:讓分析和資料科學團隊能夠快速尋找、瞭解及信任相關資料,用於商業智慧資訊主頁、機器學習模型和生成式 AI 應用程式。舉例來說,零售公司可以快速找出所有與顧客行為相關的資料集,建構推薦引擎。
  • 集中管理及確保法規遵循:資料管理員可集中管理中繼資料、分類機密資料及監控存取權。這有助於金融機構維持風險分析的明確資料沿襲,以符合嚴格的法規報表要求。
  • 企業級資料可視性:無論資料位於 BigQuery、Cloud SQL、Cloud Storage 或地端系統,您都能透過單一目錄存取所有資料,打破資料孤島。醫療機構可藉此建立病患資料的整合式資料檢視,取得更深入的臨床洞察。

運作方式

Knowledge Catalog 會自動為整合式 Google Cloud 資料來源 (例如 BigQuery 和 Cloud SQL) 的中繼資料建立索引,並提供連接器來擷取其他系統的中繼資料,建立涵蓋整個機構的完整目錄。這就像是所有資料的智慧型圖書館目錄:您可以使用豐富的篩選器進行關鍵字搜尋,也可以用自然語言提問 (例如 show me tables with revenue data) 來搜尋資料資產。透過 AI 輔助搜尋功能,瞭解您的意圖,找出最相關的檔案、表格和資料集,簡化資料探索流程。這項功能提供詳盡的技術細節和業務背景資訊,確保您能找到所需內容。

搜尋範圍

Knowledge Catalog 搜尋結果會遵守您在來源系統中對應資源的權限。

舉例來說,如果您有物件的 BigQuery 中繼資料讀取權,該物件就會顯示在 Knowledge Catalog 的搜尋結果中。如果您有權存取 BigQuery 資料表,但無權存取包含該資料表的資料集,該資料表仍會如預期顯示在 Knowledge Catalog 搜尋結果中。

根據預設,搜尋範圍會限定在貴機構。結果只會顯示與您搜尋的專案屬於同一個機構的資源。

搜尋結果只會顯示與執行搜尋的專案位於相同 VPC Service Controls 範圍的資源。使用Google Cloud 控制台時,這是控制台中選取的專案。

如要將搜尋結果範圍擴大到專案的 VPC Service Controls 範圍以外的資源,請使用 VPC Service Controls 輸入和輸出規則。這些規則可讓您在組織內私下有效率地交換資料。您可以使用Google Cloud 控制台,或透過 JSON 或 YAML 檔案設定輸入和輸出規則。請參閱下列 YAML 範例,並參閱 VPC Service Controls 說明文件,根據您的特定需求調整規則。

egressPolicies:
  - egressFrom:
      identityType: ANY_USER_ACCOUNT
    egressTo:
      # Specify which resources should be present in the search results. In this example,
      # BigQuery.
      operations:
      - methodSelectors:
        - method: '*'
        serviceName: bigquery.googleapis.com
      # Specify project ids under which the search is performed.
      resources:
      - projects/SEARCH_PROJECT_ID
ingressPolicies:
  - ingressFrom:
      identityType: ANY_USER_ACCOUNT
      sources:
      - accessLevel: '*'
    ingressTo:
      # Specify which resources should be present in the search results. In this example,
      # BigQuery.
      operations:
      - methodSelectors:
        - method: '*'
        serviceName: bigquery.googleapis.com
      # Specify project ids to expose in search results.
      resources:
      - projects/INGRESS_PROJECT_ID

如要進一步瞭解使用 Knowledge Catalog 搜尋功能時所需的 Identity and Access Management 角色,請參閱「Knowledge Catalog IAM 角色」。

使用 VPC Service Controls 依環境隔離搜尋結果

如要在開發、測試和正式環境等環境之間隔離 Knowledge Catalog 搜尋結果,請為每個環境設定個別的 VPC Service Controls 邊界。將包含資料資產的專案,以及用於執行搜尋的專案,都指派給相應環境的 perimeter。從特定範圍內的專案執行搜尋時,只會傳回位於相同範圍內的資產結果。

搜尋中的回憶集錦限制

Knowledge Catalog 搜尋查詢無法保證完整召回。 系統可能不會傳回與查詢相符的結果。此外,如果重複搜尋查詢,傳回 (和未傳回) 的結果可能會有所不同。

如要查詢所有 Knowledge Catalog 中繼資料,您可以將中繼資料匯出至 Cloud Storage,然後從 BigQuery 查詢。詳情請參閱「匯出中繼資料」。

篩選器

篩選器可縮小搜尋結果範圍。關鍵字和自然語言搜尋都提供篩選器,但可用選項可能因模式而略有不同。

如果您在多個區段中提供篩選器,系統會使用 AND 邏輯運算子評估這些篩選器。搜尋結果會包含符合所選每個部分中至少一項條件的資源。舉例來說,如果您選取 BigQuery 系統和資料集資源類型,搜尋結果會包含 BigQuery 資料集,但不包含 Vertex AI 資料集。

如果您在單一區段中選取多個篩選器,系統會使用 OR 邏輯運算子評估這些篩選器。舉例來說,如果您選取資料集資源類型和資料表資源類型,搜尋結果就會包含資料集和資料表。

關鍵字搜尋篩選器

關鍵字搜尋的篩選條件會歸入下列區段:

  • BigQuery、Cloud SQL 等系統。Knowledge Catalog 系統包含自訂項目。
  • 「切面 (標記)」清單會列出所有可用的切面。
  • 「專案」會列出所有可用的專案。
  • 類型別名會說明資源類型,例如資料庫、資料集、模型、資料表、檢視畫面、服務和自訂類型。
  • 資料集來自 BigQuery。

依切面值篩選

使用「切面」篩選器,即可查詢以特定範本標記的資產。你可以使用「自訂」選單進一步修正結果,並依特定面向值篩選。切面值篩選條件取決於該切面欄位的資料類型。舉例來說,您可以為 datetimenumber 欄位指定特定日期或範圍。

篩選瀏覽權限

系統會根據「搜尋」欄位中的目前查詢,顯示「系統」、「型別別名」、「專案」和「資料集」篩選器。

自然語言搜尋篩選器

自然語言搜尋提供下列篩選器:

  • 範圍:在整個機構 (預設)、目前專案或僅限已加星號的資源中搜尋。詳情請參閱本文的「搜尋範圍」一節。
  • 系統:資源所屬的 Google Cloud 服務,例如 BigQuery。Knowledge Catalog 系統包含項目群組
  • 專案:要搜尋的專案。
  • 類型:資源類型,例如 BigQuery 連線、Cloud Storage 值區或資料庫。視資源類型而定,您也可以依子類型篩選,例如連線類型或 SQL 方言。
  • 選取地點:要搜尋的地點。
  • 選取資料集:搜尋結果僅限於屬於所選 BigQuery 資料集的 BigQuery 資源。在「Type to filter」(輸入篩選條件) 欄位中,輸入資料集名稱。
  • 切面類型:與您要搜尋的資源相關聯的 Knowledge Catalog切面類型。如要依層面值篩選,請按一下「篩選註解值」,然後選取值。

事前準備

執行搜尋前,請確認您已獲授予必要角色,並啟用必要的 API。

必要的角色

本節說明搜尋資源及存取搜尋結果所需的角色和權限。

如要進一步瞭解如何授予角色,請參閱「管理存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

搜尋項目所需的角色

如要在專案搜尋項目,至少須具備該項專案的其中一個 IAM 角色:Dataplex Catalog 管理員、Dataplex Catalog 編輯者或 Dataplex Catalog 檢視者。系統會檢查搜尋結果的權限,與所選專案無關。

存取搜尋結果所需的角色

Knowledge Catalog 中的搜尋結果會根據您的角色設定範圍。如要在 Knowledge Catalog 中搜尋資產,您必須有權存取來源系統中的相應資源。詳情請參閱本文的「搜尋範圍」一節。

舉例來說,如要搜尋 BigQuery 資料集、資料表、檢視區塊和模型,您必須具備這些項目的相應權限。詳情請參閱「BigQuery 權限」一文。

下表列出所需的最低權限:

  • 如要搜尋資料表,您必須具備該資料表的 bigquery.tables.get 權限。
  • 如要搜尋資料集,您必須具備該資料集的 bigquery.datasets.get 權限。
  • 如要搜尋資料集或資料表的中繼資料,您需要 BigQuery 中繼資料檢視者角色 (roles/bigquery.metadataViewer)。

舉例來說,如要搜尋 Cloud SQL 執行個體、資料庫、結構定義、資料表和檢視區塊,您必須具備這些項目的相應權限。詳情請參閱「Cloud SQL 角色和權限」。

如要搜尋自訂項目,您需要 Dataplex Catalog 檢視者角色 (roles/dataplex.catalogViewer)。

啟用 API

啟用 Dataplex API。

啟用 API 時所需的角色

您必須具備 serviceusage.services.enable 權限,才能啟用 API。如果您建立了專案,可能已透過「擁有者」角色 (roles/owner) 取得這項權限。否則,您可以透過「服務使用情形管理員」角色 (roles/serviceusage.serviceUsageAdmin) 取得這項權限。瞭解如何授予角色

啟用 API

搜尋資源

* {Console}

如要搜尋資源,請按照下列步驟操作:

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

    前往「Search」(搜尋) 頁面

  2. 如果搜尋平台設為「Data Catalog」,請在「選擇搜尋平台」選單中選取「Knowledge Catalog」

    選取「Knowledge Catalog」即可搜尋 Knowledge Catalog 中繼資料儲存空間。如果您是現有的 Data Catalog 使用者,選取「Data Catalog」即可搜尋 Data Catalog 存放區。

  3. 如要使用關鍵字搜尋,請按照下列步驟操作:

    1. 在「尋找各項專案的資源」欄位中輸入查詢。

    2. 如要修正搜尋範圍,請使用「篩選器」面板。 如需可用篩選器的清單,請參閱「關鍵字搜尋篩選器」。

      您可以手動新增下列篩選器:

      • 新增專案篩選器:在「專案」中,按一下「新增專案」。搜尋特定專案,選取專案,然後按一下「開啟」
      • 新增切面類型篩選器:在「切面」中,按一下「新增更多切面類型」選單。搜尋特定範本,選取範本,然後按一下「確定」
    3. 選用:除了可用的資產外,您也可以選取「Include public datasets」(納入公開資料集),在 Google Cloud 中搜尋公開資源。

      請參考下列訣竅建構搜尋查詢:

      • 如果搜尋運算式中包含空格,請使用引號將其括住。例如 "search terms"
      • 在關鍵字前面加上 NOT,即可比對 keyword:term 篩選器的邏輯否定。您也可以使用 ANDOR 布林運算子合併搜尋運算式。ANDORNOT 運算子不區分大小寫。

        舉例來說,NOT column:term 會列出所有資料欄,但排除與指定字詞相符的資料欄。如需您可以在 Knowledge Catalog 搜尋運算式中使用的關鍵字與其他字詞的清單,請參閱「搜尋語法」。

  4. 如要使用自然語言搜尋功能,請按照下列步驟操作:

    1. 按一下「試用自然語言搜尋」

    2. 在「以自然語言尋找各項專案的資源」欄位中,以自然語言輸入查詢,然後按下 Enter 鍵。

      以下是一些查詢範例:

      • Show me the datasets that contain taxi information
      • Find data on vaccine distribution across different countries
      • Get tables with historical temperature data for major world cities
      • Search for hurricane tracking and storm activity datasets
      • Population data by country
    3. 如要修正搜尋結果,請按一下「篩選器」。 如需可用篩選器的清單,請參閱自然語言搜尋篩選器

  5. 如要查看搜尋資源的詳細資訊,請在搜尋結果中點選資源名稱。系統隨即會開啟項目詳細資料頁面。

gcloud

如要搜尋資源,請使用 gcloud dataplex entries search 指令

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 GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for SearchEntries</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 SearchEntriesRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        SearchEntriesRequest request = new SearchEntriesRequest
        {
            LocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
            Query = "",
            OrderBy = "",
            Scope = "",
            SemanticSearch = false,
        };
        // Make the request
        PagedEnumerable<SearchEntriesResponse, SearchEntriesResult> response = catalogServiceClient.SearchEntries(request);

        // Iterate over all response items, lazily performing RPCs as required
        foreach (SearchEntriesResult 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 (SearchEntriesResponse page in response.AsRawResponses())
        {
            // Do something with each page of items
            Console.WriteLine("A page of results:");
            foreach (SearchEntriesResult 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<SearchEntriesResult> 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 (SearchEntriesResult 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.NewCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.SearchEntriesRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#SearchEntriesRequest.
	}
	it := c.SearchEntries(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.SearchEntriesResponse)
	}
}

Java

Java

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

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

import com.google.cloud.dataplex.v1.CatalogServiceClient;
import com.google.cloud.dataplex.v1.LocationName;
import com.google.cloud.dataplex.v1.SearchEntriesRequest;
import com.google.cloud.dataplex.v1.SearchEntriesResult;

public class SyncSearchEntries {

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

  public static void syncSearchEntries() 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 (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
      SearchEntriesRequest request =
          SearchEntriesRequest.newBuilder()
              .setName(LocationName.of("[PROJECT]", "[LOCATION]").toString())
              .setQuery("query107944136")
              .setPageSize(883849137)
              .setPageToken("pageToken873572522")
              .setOrderBy("orderBy-1207110587")
              .setScope("scope109264468")
              .setSemanticSearch(true)
              .build();
      for (SearchEntriesResult element : catalogServiceClient.searchEntries(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 project to which the request should be attributed in the
 *  following form: `projects/{project}/locations/global`.
 */
// const name = 'abc123'
/**
 *  Required. The query against which entries in scope should be matched.
 *  The query syntax is defined in Search syntax for Dataplex Universal
 *  Catalog (https://cloud.google.com/dataplex/docs/search-syntax).
 */
// const query = 'abc123'
/**
 *  Optional. Number of results in the search page. If <=0, then defaults
 *  to 10. Max limit for page_size is 1000. Throws an invalid argument for
 *  page_size > 1000.
 */
// const pageSize = 1234
/**
 *  Optional. Page token received from a previous `SearchEntries` call. Provide
 *  this to retrieve the subsequent page.
 */
// const pageToken = 'abc123'
/**
 *  Optional. Specifies the ordering of results.
 *  Supported values are:
 *  * `relevance`
 *  * `last_modified_timestamp`
 *  * `last_modified_timestamp asc`
 */
// const orderBy = 'abc123'
/**
 *  Optional. The scope under which the search should be operating. It must
 *  either be `organizations/<org_id>` or `projects/<project_ref>`. If it is
 *  unspecified, it defaults to the organization where the project provided in
 *  `name` is located.
 */
// const scope = 'abc123'
/**
 *  Optional. Specifies whether the search should understand the meaning and
 *  intent behind the query, rather than just matching keywords.
 */
// const semanticSearch = true

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

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

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

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

callSearchEntries();

PHP

PHP

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

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

use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\Dataplex\V1\Client\CatalogServiceClient;
use Google\Cloud\Dataplex\V1\SearchEntriesRequest;
use Google\Cloud\Dataplex\V1\SearchEntriesResult;

/**
 * Searches for Entries matching the given query and scope.
 *
 * @param string $formattedName The project to which the request should be attributed in the
 *                              following form: `projects/{project}/locations/global`. Please see
 *                              {@see CatalogServiceClient::locationName()} for help formatting this field.
 * @param string $query         The query against which entries in scope should be matched.
 *                              The query syntax is defined in [Search syntax for Dataplex Universal
 *                              Catalog](https://cloud.google.com/dataplex/docs/search-syntax).
 */
function search_entries_sample(string $formattedName, string $query): void
{
    // Create a client.
    $catalogServiceClient = new CatalogServiceClient();

    // Prepare the request message.
    $request = (new SearchEntriesRequest())
        ->setName($formattedName)
        ->setQuery($query);

    // Call the API and handle any network failures.
    try {
        /** @var PagedListResponse $response */
        $response = $catalogServiceClient->searchEntries($request);

        /** @var SearchEntriesResult $element */
        foreach ($response as $element) {
            printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
        }
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $formattedName = CatalogServiceClient::locationName('[PROJECT]', '[LOCATION]');
    $query = '[QUERY]';

    search_entries_sample($formattedName, $query);
}

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_search_entries():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    request = dataplex_v1.SearchEntriesRequest(
        name="name_value",
        query="query_value",
    )

    # Make the request
    page_result = client.search_entries(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 search_entries call in the CatalogService 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::CatalogService::Client#search_entries.
#
def search_entries
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

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

  # Call the search_entries method.
  result = client.search_entries 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::SearchEntriesResult.
    p item
  end
end

REST

如要搜尋資源,請使用 searchEntries 方法

查看項目詳細資料

控制台

使用 Knowledge Catalog 搜尋功能查看項目的詳細資料。

  1. 在 Knowledge Catalog 中搜尋項目

  2. 在搜尋結果中,按一下要查看詳細資料的項目。

    系統會開啟項目詳細資料頁面。這個頁面包含下列章節:

    • 項目詳細資料:包括項目類型、系統、平台、完整名稱、建立時間、上次修改時間、說明和管理員等資訊。
    • 總覽:項目的總覽 (如有)。
    • 切面:為項目定義的必要和選用切面。 詳情請參閱「各類別的面向」。

gcloud

如要查看項目的詳細資料,請使用 gcloud dataplex entries lookup 指令

C#

C#

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

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

using Google.Cloud.Dataplex.V1;

public sealed partial class GeneratedCatalogServiceClientSnippets
{
    /// <summary>Snippet for LookupEntry</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 LookupEntryRequestObject()
    {
        // Create client
        CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
        // Initialize request argument(s)
        LookupEntryRequest request = new LookupEntryRequest
        {
            Name = "",
            View = EntryView.Unspecified,
            AspectTypes = { "", },
            Paths = { "", },
            EntryAsEntryName = EntryName.FromProjectLocationEntryGroupEntry("[PROJECT]", "[LOCATION]", "[ENTRY_GROUP]", "[ENTRY]"),
        };
        // Make the request
        Entry response = catalogServiceClient.LookupEntry(request);
    }
}

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.NewCatalogClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &dataplexpb.LookupEntryRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/dataplex/apiv1/dataplexpb#LookupEntryRequest.
	}
	resp, err := c.LookupEntry(ctx, req)
	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.CatalogServiceClient;
import com.google.cloud.dataplex.v1.Entry;
import com.google.cloud.dataplex.v1.EntryName;
import com.google.cloud.dataplex.v1.EntryView;
import com.google.cloud.dataplex.v1.LookupEntryRequest;
import java.util.ArrayList;

public class SyncLookupEntry {

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

  public static void syncLookupEntry() 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 (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
      LookupEntryRequest request =
          LookupEntryRequest.newBuilder()
              .setName("name3373707")
              .setView(EntryView.forNumber(0))
              .addAllAspectTypes(new ArrayList<String>())
              .addAllPaths(new ArrayList<String>())
              .setEntry(
                  EntryName.of("[PROJECT]", "[LOCATION]", "[ENTRY_GROUP]", "[ENTRY]").toString())
              .build();
      Entry response = catalogServiceClient.lookupEntry(request);
    }
  }
}

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 project to which the request should be attributed in the
 *  following form: `projects/{project}/locations/{location}`.
 */
// const name = 'abc123'
/**
 *  Optional. View to control which parts of an entry the service should
 *  return.
 *  **Please check the limitations on returned aspects in the Entry view
 *  documentation. Amount of returned aspects depends on the selected Entry
 *  View.**
 */
// const view = {}
/**
 *  Optional. Limits the aspects returned to the provided aspect types.
 *  It only works for CUSTOM view.
 */
// const aspectTypes = ['abc','def']
/**
 *  Optional. Limits the aspects returned to those associated with the provided
 *  paths within the Entry. It only works for CUSTOM view.
 */
// const paths = ['abc','def']
/**
 *  Required. The resource name of the Entry:
 *  `projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}`.
 */
// const entry = 'abc123'

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

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

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

  // Run request
  const response = await dataplexClient.lookupEntry(request);
  console.log(response);
}

callLookupEntry();

PHP

PHP

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

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

use Google\ApiCore\ApiException;
use Google\Cloud\Dataplex\V1\Client\CatalogServiceClient;
use Google\Cloud\Dataplex\V1\Entry;
use Google\Cloud\Dataplex\V1\LookupEntryRequest;

/**
 * Looks up an entry by name using the permission on the source system.
 *
 * @param string $name           The project to which the request should be attributed in the
 *                               following form: `projects/{project}/locations/{location}`.
 * @param string $formattedEntry The resource name of the Entry:
 *                               `projects/{project}/locations/{location}/entryGroups/{entry_group}/entries/{entry}`. Please see
 *                               {@see CatalogServiceClient::entryName()} for help formatting this field.
 */
function lookup_entry_sample(string $name, string $formattedEntry): void
{
    // Create a client.
    $catalogServiceClient = new CatalogServiceClient();

    // Prepare the request message.
    $request = (new LookupEntryRequest())
        ->setName($name)
        ->setEntry($formattedEntry);

    // Call the API and handle any network failures.
    try {
        /** @var Entry $response */
        $response = $catalogServiceClient->lookupEntry($request);
        printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
    } catch (ApiException $ex) {
        printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
    }
}

/**
 * Helper to execute the sample.
 *
 * This sample 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,
 *    please see the apiEndpoint client configuration option for more details.
 */
function callSample(): void
{
    $name = '[NAME]';
    $formattedEntry = CatalogServiceClient::entryName(
        '[PROJECT]',
        '[LOCATION]',
        '[ENTRY_GROUP]',
        '[ENTRY]'
    );

    lookup_entry_sample($name, $formattedEntry);
}

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_lookup_entry():
    # Create a client
    client = dataplex_v1.CatalogServiceClient()

    # Initialize request argument(s)
    request = dataplex_v1.LookupEntryRequest(
        name="name_value",
        entry="entry_value",
    )

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

    # Handle the response
    print(response)

Ruby

Ruby

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

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

require "google/cloud/dataplex/v1"

##
# Snippet for the lookup_entry call in the CatalogService 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::CatalogService::Client#lookup_entry.
#
def lookup_entry
  # Create a client object. The client can be reused for multiple calls.
  client = Google::Cloud::Dataplex::V1::CatalogService::Client.new

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

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

  # The returned object is of type Google::Cloud::Dataplex::V1::Entry.
  p result
end

REST

如要查看項目的詳細資料,請使用 lookupEntry 方法

限制

自然語言搜尋有以下限制:

  • 自然語言搜尋功能會傳回一組最相關的結果,因此非常適合用於探索和發掘內容。這項功能可能無法提供所有相符項目的完整清單,因此可能不適合依此執行的工作負載,例如內容策展管道。

  • 自然語言搜尋只會考量資源中繼資料,包括架構、說明和附加至項目的層面。不會回答資料表內資料的問題 (例如「上個月的銷售額是多少?」),也不會對中繼資料執行分析查詢 (例如「資料集 X 中有多少個資料表?」)。

  • 自然語言搜尋功能不支援搜尋公開資源。

  • 附加至項目連結的層面不在自然語言搜尋的範圍內。

後續步驟