View a schema definition

You can view the schema for any data store that supports a schema, such as structured data, websites with metadata, or unstructured data with metadata.

You can view the schema in the Google Cloud console or by using the dataStores.schemas.get API method. Viewing the schema for a website is supported only over the REST API.

Console

To view a schema in the Google Cloud console, follow these steps.

  1. If you are viewing an auto-generated schema, make sure that you have completed data ingestion. Otherwise, the schema might not be available yet.

  2. In the Google Cloud console, go to the Agent Builder page.

    Agent Builder

  3. In the navigation menu, click Data stores.

  4. In the Name column, click the data store with the schema that you want to view.

  5. Click the Schema tab to view the schema for your data.

REST

To use the API to get the definition for your schema, follow these steps:

  1. If you are viewing an auto-generated schema, make sure that you have completed data ingestion. Otherwise, the schema might not be available yet.

    To view the schema for data stores with websites or unstructured data with metadata, skip to Step 3 to call the schema.get method.

  2. Find your data store ID. If you already have your data store ID, skip to the next step.

    1. In the Google Cloud console, go to the Agent Builder page and in the navigation menu, click Data stores.

      Go to the Data stores page

    2. Click the name of your data store.

    3. On the Data page for your data store, get the data store ID.

  3. Use the schemas.get API method to get your schema definition.

    curl -X GET \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    "https://discoveryengine.googleapis.com/v1beta/projects/PROJECT_ID/locations/global/collections/default_collection/dataStores/DATA_STORE_ID/schemas/default_schema"
    
    • PROJECT_ID: The ID of your project.
    • DATA_STORE_ID: The ID of your data store.

C#

For more information, see the Vertex AI Search and Conversation C# API reference documentation.

To authenticate to Vertex AI Search and Conversation, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

For more information, see the Vertex AI Search and Conversation Go API reference documentation.

To authenticate to Vertex AI Search and Conversation, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


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

For more information, see the Vertex AI Search and Conversation Java API reference documentation.

To authenticate to Vertex AI Search and Conversation, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

For more information, see the Vertex AI Search and Conversation Python API reference documentation.

To authenticate to Vertex AI Search and Conversation, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

# 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

For more information, see the Vertex AI Search and Conversation Ruby API reference documentation.

To authenticate to Vertex AI Search and Conversation, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

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

What's next