查看結構定義

如果資料儲存庫含有支援結構定義的資料,例如結構化資料、含有結構化資料的網站資料,或含有結構化資料的非結構化資料,您就能查看該資料儲存庫的結構定義。

您可以在 Google Cloud 控制台中查看結構定義,或使用 dataStores.schemas.get API 方法。查看網站結構定義的功能僅支援 REST API。

控制台

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

  1. 如果您查看的是自動生成的結構定義,請確認資料擷取作業已完成。否則,結構定義可能尚未推出。

  2. 前往 Google Cloud 控制台的「AI Applications」頁面。

    AI 應用程式

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

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

  5. 點選「結構定義」分頁標籤,查看資料的結構定義。

REST

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

  1. 如果您查看的是自動生成的結構定義,請確認資料擷取作業已完成。否則,結構定義可能尚未推出。

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

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

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

      前往「Data Stores」(資料儲存庫) 頁面

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

    3. 在資料儲存庫的「Data」(資料) 頁面,取得資料儲存庫 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#

詳情請參閱 Agent Search C# API 參考文件。

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

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

詳情請參閱 Agent Search Go API 參考文件。

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


//go:build examples

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

詳情請參閱 Agent Search Java API 參考文件。

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

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

詳情請參閱 Agent Search Python API 參考文件。

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

# 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

詳情請參閱 Agent Search Ruby API 參考文件。

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

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

後續步驟