查看結構定義

您可以查看任何資料儲存庫的結構定義,前提是該儲存庫包含支援結構定義的資料,例如結構化資料含有結構化資料的非結構化資料

您可以在 Google Cloud 控制台中查看結構定義,也可以使用 dataStores.schemas.get API 方法查看。只有透過 REST API,才能查看網站的結構定義。

控制台

如要在 Google Cloud 控制台中查看結構定義,請按照下列步驟操作。

  1. 如果查看的是自動產生的結構定義,請務必完成資料擷取。否則,結構定義可能尚未推出。

  2. 前往 Google Cloud 控制台的「Gemini Enterprise」頁面。

    Gemini Enterprise

  3. 點按導覽選單中的「Data Stores」(資料儲存庫)

  4. 在「名稱」欄中,按一下要查看結構定義的資料儲存庫。

  5. 按一下「結構定義」分頁標籤,查看資料的結構定義。

REST

如要使用 API 取得結構定義的定義,請按照下列步驟操作:

  1. 如果查看的是自動產生的結構定義,請務必完成資料擷取。否則,結構定義可能尚未推出。

    如要查看含中繼資料的非結構化資料儲存庫結構定義,請跳至步驟 3,呼叫 schema.get 方法。

  2. 找出資料儲存庫 ID。如果已有資料商店 ID,請跳到下一個步驟。

    1. 前往 Google Cloud 控制台的「Gemini Enterprise」頁面,然後點按導覽選單中的「Data Stores」(資料儲存庫)

      前往「資料儲存庫」頁面

    2. 點按資料儲存庫的名稱。

    3. 在資料儲存庫的「資料」頁面中,取得資料儲存庫 ID。

  3. 使用 schemas.get API 方法取得結構定義。

    curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    "https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/schemas/default_schema"
    

    更改下列內容:

    • PROJECT_ID:專案 ID。
    • DATA_STORE_ID:資料儲存庫的 ID。

C#

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

如要驗證 Gemini Enterprise,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

using Google.Cloud.DiscoveryEngine.V1;

public sealed partial class GeneratedSchemaServiceClientSnippets
{
    /// <summary>Snippet for GetSchema</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 GetSchemaRequestObject()
    {
        // Create client
        SchemaServiceClient schemaServiceClient = SchemaServiceClient.Create();
        // Initialize request argument(s)
        GetSchemaRequest request = new GetSchemaRequest
        {
            SchemaName = SchemaName.FromProjectLocationDataStoreSchema("[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SCHEMA]"),
        };
        // Make the request
        Schema response = schemaServiceClient.GetSchema(request);
    }
}

Go

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

如要驗證 Gemini Enterprise,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


package main

import (
	"context"

	discoveryengine "cloud.google.com/go/discoveryengine/apiv1"
	discoveryenginepb "cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb"
)

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

	req := &discoveryenginepb.GetSchemaRequest{
		// TODO: Fill request struct fields.
		// See https://pkg.go.dev/cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb#GetSchemaRequest.
	}
	resp, err := c.GetSchema(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

Java

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

如要驗證 Gemini Enterprise,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

import com.google.cloud.discoveryengine.v1.GetSchemaRequest;
import com.google.cloud.discoveryengine.v1.Schema;
import com.google.cloud.discoveryengine.v1.SchemaName;
import com.google.cloud.discoveryengine.v1.SchemaServiceClient;

public class SyncGetSchema {

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

  public static void syncGetSchema() 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 (SchemaServiceClient schemaServiceClient = SchemaServiceClient.create()) {
      GetSchemaRequest request =
          GetSchemaRequest.newBuilder()
              .setName(
                  SchemaName.ofProjectLocationDataStoreSchemaName(
                          "[PROJECT]", "[LOCATION]", "[DATA_STORE]", "[SCHEMA]")
                      .toString())
              .build();
      Schema response = schemaServiceClient.getSchema(request);
    }
  }
}

Python

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

如要驗證 Gemini Enterprise,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

# 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 discoveryengine_v1


def sample_get_schema():
    # Create a client
    client = discoveryengine_v1.SchemaServiceClient()

    # Initialize request argument(s)
    request = discoveryengine_v1.GetSchemaRequest(
        name="name_value",
    )

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

    # Handle the response
    print(response)

Ruby

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

如要驗證 Gemini Enterprise,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

require "google/cloud/discovery_engine/v1"

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

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

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

  # The returned object is of type Google::Cloud::DiscoveryEngine::V1::Schema.
  p result
end

後續步驟