Update a schema

You can update the schema for any data containing data that supports a schema,such asstructured data,website data with structured data, or otherunstructured data withmetadata.

You can update the schema in the Google Cloud console or byusing theschemas.patch API method.Updating the schema for a website is supported only over the REST API.

To update the schema, you can add new fields, change indexable, searchable, andretrievable annotations for a field, or mark a field as a key property, such astitle,uri anddescription.

Before you begin

Before you update your schema understand the key concepts explained in thissection.

Importance of key properties

Here are a few reasons why you need to map your schema fields to key properties:

  • Google strongly recommends that you update your schema with keyproperty mappings especially fortitle. This ensures that your results aredisplayed correctly and helps Vertex AI Search identify importantinformation that allows it to generate better results.

  • In structured data stores, to obtain thekeywordSimilarityScore signal inyour search response, you mustupdate your schema to do thefollowing:

    • Map the text fields essential for keyword matching to the key propertiestitle anddescription
    • Update the annotation for the text fields asSearchable

Requirements

When updating a schema, ensure that the new schema is backwardcompatible with the schema you are updating. To update a schemawith a new schema that is not backward compatible, you need to delete allthe documents in the data store, delete the schema, and create a new schema.

Updating a schema triggers re-indexing of all documents. This can take time andincur additional costs:

  • Time. Reindexing a large data store can take hours or days.

  • Expense. Reindexing can incur costs, depending on the parser. For example,reindexing data stores that use the OCR parser or the layout parser both incurcosts. For more information, seeDocument AI featurepricing.

  • Service impact. Reindexing might lead to slow or unavailable services,especially for large data stores. Google recommends that you plan schemaupdates accordingly—considering potential downtime for critical applications.

Schema updates don't support the following:

  • Changing a field type. A schema update doesn't support changing the typeof the field. For example, a field mapped tointeger can't be changed tostring.
  • Removing a field. After it's defined, a field can't be removed. You cancontinue adding new fields but you can't remove an existing field.

Update your schema

You can update your schema in the Google Cloud console or using the API.

Note: Editing the schema indexes your data store again.For large data stores, indexing can take several hours.

Console

To update a schema in the Google Cloud console, follow these steps:

  1. Review theRequirements and limitations section to checkthat your schema update is valid.

  2. If you are updating field annotations (setting fields as indexable,retrievable, dynamic facetable, searchable, or completable), reviewConfigure field settings for thelimitations and requirements of each annotation type.

  3. Check that you have completed data ingestion. Otherwise, the schema might notbe available to edit yet.

  4. In the Google Cloud console, go to theAI Applications page.

    AI Applications

  5. In the navigation menu, clickData Stores.

  6. In theName column, click the data store with the schema that you want toupdate.

  7. Click theSchema tab to view the schema for your data.

    This tab might be empty if this is the first time you're editing the fields.

  8. Click theEdit button.

  9. Update your schema:

    • Map key properties: In theKey properties column of your schema,select a key property to map a field to. For example, if a field calleddetails always contains the description of a document, map that fieldto the key propertyDescription.

    • Update number of dimensions (Advanced): You can update thissetting if you are using custom vector embeddings withVertex AI Search. SeeAdvanced: Use custom embeddings.

    • Update field annotations: To update annotations for a field, selector deselect a field's annotation setting. Available annotations areRetrievable,Indexable,Dynamic Facetable,Searchable, andCompletable. Some field settings have limitations. SeeConfigure field settings for descriptionsand requirements for each annotation type.

    • Add a new field: Adding new fields to your schema before importing newdocuments with those fields can shorten the time it takesVertex AI Search to reindex your data after import.

      1. ClickAdd new fields to expand that section.

      2. Clickadd_boxAdd node andspecify settings for the new field.

        To indicate an array, setArray toYes. For example, to addan array of strings, settype tostring andArray toYes.

        For a website data store index, all fields that you add are arrays bydefault.

  10. ClickSave to apply your schema changes.

    Changing the schema triggers reindexing. For large data stores,reindexing can take hours.

REST

To use the API to update your schema, follow these steps:

  1. Review theRequirements and limitations and theLimitationexamples (REST only) sections to check that your schema changesare valid.

    To update the schema for data stores with websites or unstructured data withmetadata, skip to Step 5 to call theschema.patch method.

  2. If you are updating field annotations (setting fields as indexable,retrievable, dynamic facetable, or searchable), reviewConfigure field settings for thelimitations and requirements of each annotation type.

  3. If you are editing an auto-detected schema, make sure that you havecompleted data ingestion. Otherwise, the schema might not be available toedit yet.

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

    1. In the Google Cloud console, go to theAI Applications page andin the navigation menu, clickData Stores.

      Go to the Data Stores page

    2. Click the name of your data store.

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

  5. Use theschemas.patchAPI method to provide your new JSON schema as a JSON object.

    curl-XPATCH\-H"Authorization: Bearer$(gcloudauthprint-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"\-d'{  "structSchema":JSON_SCHEMA_OBJECT}'

    Replace the following:

    • PROJECT_ID: the ID of your Google Cloud project.
    • DATA_STORE_ID: the ID of the Vertex AI Search data store.
    • JSON_SCHEMA_OBJECT: your new JSON schema as aJSON object. For example:

      {"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"title":{"type":"string","keyPropertyMapping":"title"},"categories":{"type":"array","items":{"type":"string","keyPropertyMapping":"category"}},"uri":{"type":"string","keyPropertyMapping":"uri"}}}

      Example command and result

      curl -X PATCH -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" "https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/collections/default_collection/dataStores/my-data-store/schemas/default_schema" -d '{"structSchema": {"$schema": "https://json-schema.org/draft/2020-12/schema","type": "object","properties": {"title": {"type": "string","keyPropertyMapping": "title"},"categories": {"type": "array","items": {"type": "string","keyPropertyMapping": "category"}},"uri": {"type": "string","keyPropertyMapping": "uri"}}}}'
      {"name": "projects/123456/locations/global/collections/default_collection/dataStores/my-data-store/schemas/default_schema/operations/update-schema-10569824819404198922","metadata": {"@type": "type.googleapis.com/google.cloud.discoveryengine.v1.UpdateSchemaMetadata"}}
  6. Optional: Review the schema by following the procedureView a schema definition.

C#

For more information, see theVertex AI SearchC# API reference documentation.

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

usingGoogle.Cloud.DiscoveryEngine.V1;usingGoogle.LongRunning;publicsealedpartialclassGeneratedSchemaServiceClientSnippets{/// <summary>Snippet for UpdateSchema</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>publicvoidUpdateSchemaRequestObject(){// Create clientSchemaServiceClientschemaServiceClient=SchemaServiceClient.Create();// Initialize request argument(s)UpdateSchemaRequestrequest=newUpdateSchemaRequest{Schema=newSchema(),AllowMissing=false,};// Make the requestOperation<Schema,UpdateSchemaMetadata>response=schemaServiceClient.UpdateSchema(request);// Poll until the returned long-running operation is completeOperation<Schema,UpdateSchemaMetadata>completedResponse=response.PollUntilCompleted();// Retrieve the operation resultSchemaresult=completedResponse.Result;// Or get the name of the operationstringoperationName=response.Name;// This name can be stored, then the long-running operation retrieved later by nameOperation<Schema,UpdateSchemaMetadata>retrievedResponse=schemaServiceClient.PollOnceUpdateSchema(operationName);// Check if the retrieved long-running operation has completedif(retrievedResponse.IsCompleted){// If it has completed, then access the resultSchemaretrievedResult=retrievedResponse.Result;}}}

Go

For more information, see theVertex AI SearchGo API reference documentation.

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

packagemainimport("context"discoveryengine"cloud.google.com/go/discoveryengine/apiv1"discoveryenginepb"cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb")funcmain(){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_Optionsc,err:=discoveryengine.NewSchemaClient(ctx)iferr!=nil{// TODO: Handle error.}deferc.Close()req:=&discoveryenginepb.UpdateSchemaRequest{// TODO: Fill request struct fields.// See https://pkg.go.dev/cloud.google.com/go/discoveryengine/apiv1/discoveryenginepb#UpdateSchemaRequest.}op,err:=c.UpdateSchema(ctx,req)iferr!=nil{// TODO: Handle error.}resp,err:=op.Wait(ctx)iferr!=nil{// TODO: Handle error.}// TODO: Use resp._=resp}

Java

For more information, see theVertex AI SearchJava API reference documentation.

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

importcom.google.cloud.discoveryengine.v1.Schema;importcom.google.cloud.discoveryengine.v1.SchemaServiceClient;importcom.google.cloud.discoveryengine.v1.UpdateSchemaRequest;publicclassSyncUpdateSchema{publicstaticvoidmain(String[]args)throwsException{syncUpdateSchema();}publicstaticvoidsyncUpdateSchema()throwsException{// 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_librarytry(SchemaServiceClientschemaServiceClient=SchemaServiceClient.create()){UpdateSchemaRequestrequest=UpdateSchemaRequest.newBuilder().setSchema(Schema.newBuilder().build()).setAllowMissing(true).build();Schemaresponse=schemaServiceClient.updateSchemaAsync(request).get();}}}

Python

For more information, see theVertex AI SearchPython API reference documentation.

To authenticate to Vertex AI Search, set up Application Default Credentials. For more information, seeSet 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.htmlfromgoogle.cloudimportdiscoveryengine_v1defsample_update_schema():# Create a clientclient=discoveryengine_v1.SchemaServiceClient()# Initialize request argument(s)request=discoveryengine_v1.UpdateSchemaRequest()# Make the requestoperation=client.update_schema(request=request)print("Waiting for operation to complete...")response=operation.result()# Handle the responseprint(response)

Ruby

For more information, see theVertex AI SearchRuby API reference documentation.

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

require"google/cloud/discovery_engine/v1"### Snippet for the update_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#update_schema.#defupdate_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::UpdateSchemaRequest.new# Call the update_schema method.result=client.update_schemarequest# The returned object is of type Gapic::Operation. You can use it to# check the status of an operation, cancel it, or wait for results.# Here is how to wait for a response.result.wait_until_done!timeout:60ifresult.response?presult.responseelseputs"No response received."endend

Limitation examples (REST only)

This section shows examples of valid and invalid types of schema updates. Theseexamples use the following example JSON schema:

{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"title":{"type":"string"},"description":{"type":"string","keyPropertyMapping":"description"},"categories":{"type":"array","items":{"type":"string","keyPropertyMapping":"category"}}}}

Examples of supported updates

The following updates to the example schema are supported.

  • Adding a field. In this example, the fieldproperties.uri has beenadded to the schema.

    {"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"title":{"type":"string"},"description":{"type":"string","keyPropertyMapping":"description"},"uri":{// Added field. This is supported."type":"string","keyPropertyMapping":"uri"},"categories":{"type":"array","items":{"type":"string","keyPropertyMapping":"category"}}}}
  • Adding or removing key property annotations fortitle,descriptionoruri. In this example,keyPropertyMapping has been added to thetitle field.

    {"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"title":{"type":"string","keyPropertyMapping":"title"// Added "keyPropertyMapping". This is supported.},"description":{"type":"string","keyPropertyMapping":"description"},"categories":{"type":"array","items":{"type":"string","keyPropertyMapping":"category"}}}}

Examples of invalid schema updates

The following updates to the example schema aren't supported.

  • Changing a field type. In this example, thetitle field's type has been changed from string to number. This is not supported.

    {"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"title":{"type":"number"// Changed from string. Not allowed.},"description":{"type":"string","keyPropertyMapping":"description"},"categories":{"type":"array","items":{"type":"string","keyPropertyMapping":"category"}}}}
  • Removing a field. In this example, thetitle field has been removed.This is not supported.

    {"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{// "title" is removed. Not allowed."description":{"type":"string","keyPropertyMapping":"description"},"uri":{"type":"string","keyPropertyMapping":"uri"},"categories":{"type":"array","items":{"type":"string","keyPropertyMapping":"category"}}}}

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.