View a schema definition

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

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 Agentspacepage.

    Agentspace

  3. In the navigation menu, click Data Stores.

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

  5. Click the Schematab 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 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 Agentspacepage 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 Datapage 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/v1/projects/ PROJECT_ID 
    /locations/global/collections/default_collection/dataStores/ DATA_STORE_ID 
    /schemas/default_schema" 
     
    

    Replace the following:

    • PROJECT_ID : the ID of your project.
    • DATA_STORE_ID : the ID of your data store.

C#

Before trying this sample, follow the C# setup instructions in the Agentspace quickstart using client libraries . For more information, see the Agentspace C# API reference documentation .

To authenticate to Agentspace, 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

Before trying this sample, follow the Go setup instructions in the Agentspace quickstart using client libraries . For more information, see the Agentspace Go API reference documentation .

To authenticate to Agentspace, 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

Before trying this sample, follow the Java setup instructions in the Agentspace quickstart using client libraries . For more information, see the Agentspace Java API reference documentation .

To authenticate to Agentspace, 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

Before trying this sample, follow the Python setup instructions in the Agentspace quickstart using client libraries . For more information, see the Agentspace Python API reference documentation .

To authenticate to Agentspace, 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

Before trying this sample, follow the Ruby setup instructions in the Agentspace quickstart using client libraries . For more information, see the Agentspace Ruby API reference documentation .

To authenticate to Agentspace, 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

Design a Mobile Site
View Site in Mobile | Classic
Share by: