如果線上商店使用 Bigtable 線上服務,您可以直接更新特徵檢視區塊中的特徵值,不必即時更新特徵資料來源。你可以更新現有 ID 的特徵值,或新增實體 ID 和對應的特徵值。在下列情況下使用這項功能:
您希望將特徵寫入線上商店的速度比批次同步處理更快,同時將資料新鮮度維持在 100 毫秒以下。
您想擷取功能寫入線上商店時的時間戳記。
Vertex AI 特徵儲存庫不會根據直接寫入特徵檢視區塊例項的特徵資料,更新 BigQuery 中的特徵資料來源。資料同步處理期間,Vertex AI 特徵儲存庫會使用時間戳記最新的特徵值更新特徵檢視畫面。舉例來說,如果您直接在特徵檢視區塊中更新特徵值,隨後又在 BigQuery 來源中更新相同特徵,則 Vertex AI 特徵儲存庫會在下次資料同步時,使用 BigQuery 中最近更新的特徵值更新特徵檢視區塊。
POST https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME:directWrite
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Update features in a feature view\n\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nIf your online store uses Bigtable online serving, you can directly update\nfeature values in a feature view without updating the feature data source\nin real-time. You can either update the feature values for an existing ID, or\nadd a new entity ID along with the corresponding feature values. Use this\ncapability in the following scenarios:\n\n- You want to write features to an online store faster than batch sync, while\n maintaining data freshness at 100ms or less.\n\n- You want to retrieve the timestamp when the\n feature is written to the online store.\n\nVertex AI Feature Store doesn't update the feature data source in BigQuery\nbased on the feature data that written directly to a feature view instance.\nDuring data sync, Vertex AI Feature Store updates the feature view\nwith the feature value having the most recent timestamp. For example, if you update\na feature value directly in a feature view, and subsequently update the same\nfeature in the BigQuery source, then\nVertex AI Feature Store updates the feature view with the most\nrecently updated feature value from BigQuery during the next\ndata sync.\n\nIf you want to add or update feature values for a feature column that's used in\nmultiple feature views, then you must make the same updates to each feature view\nseparately.\n\nIf an online store instance is configured for Optimized online serving,\nyou can't write features directly to a feature view within that online store.\n\nNote that this capability doesn't let you add or remove feature columns in a\nfeature view. Also, you can't delete existing feature values or entity IDs.\n\nBefore you begin\n----------------\n\n\nto\nVertex AI, unless you've done so already.\n\n\nTo use the REST API samples on this page in a local development environment, you use the\ncredentials you provide to the gcloud CLI.\n\n1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n```bash\ngcloud init\n```\n2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\nFor more information, see\n[Authenticate for using REST](/docs/authentication/rest)\nin the Google Cloud authentication documentation.\n\nUpdate features directly in a feature view\n------------------------------------------\n\nUse the following sample to write features to an entity within a feature view. \n\n### REST\n\n\nTo write features values directly to a\n[`FeatureView`](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews#resource:-featureView)\ninstance, send a `POST` request by using the\n[`featureViews.directWrite`](/vertex-ai/docs/reference/rest/v1/projects.locations.featureOnlineStores.featureViews/directWrite)\nmethod.\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003eLOCATION_ID\u003c/var\u003e: Region for the feature view where you want to write the features, such as `us-central1`.\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your project ID.\n- \u003cvar translate=\"no\"\u003eFEATUREONLINESTORE_NAME\u003c/var\u003e: The name of the online store instance containing the feature view.\n- \u003cvar translate=\"no\"\u003eFEATUREVIEW_NAME\u003c/var\u003e: The name of the new feature view instance where you want to write the features.\n- \u003cvar translate=\"no\"\u003eENTITY_ID\u003c/var\u003e: The entity ID for which you want to add feature values.\n- \u003cvar translate=\"no\"\u003eFEATURE_1\u003c/var\u003e and \u003cvar translate=\"no\"\u003eFEATURE_2\u003c/var\u003e: The features you want to add.\n- \u003cvar translate=\"no\"\u003eFEATURE_1_VALUE\u003c/var\u003e and \u003cvar translate=\"no\"\u003eFEATURE_2_VALUE\u003c/var\u003e: The feature values for \u003cvar translate=\"no\"\u003eFEATURE_1\u003c/var\u003e and \u003cvar translate=\"no\"\u003eFEATURE_2\u003c/var\u003e, respectively.\n\n\nHTTP method and URL:\n\n```\nPOST https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME:directWrite\n```\n\n\nRequest JSON body:\n\n```\n[\n {\n \"feature_view\": \"LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME\",\n \"data_key_and_feature_values\": {\n \"data_key\": {\n \"key\": \"ENTITY_ID\"\n },\n \"features\": [{\n \"name\": \"FEATURE_1\",\n \"value_and_timestamp\": {\n \"value\": {\n \"string_value\": \"FEATURE_1_VALUE\"\n }\n }\n },\n {\n \"name\": \"FEATURE_2\",\n \"value_and_timestamp\": {\n \"value\": {\n \"string_value\": \"FEATURE_2_VALUE\"\n }\n }\n }\n ]\n }\n }\n]\n\n```\n\nTo send your request, choose one of these options: \n\n#### curl\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\ncurl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @request.json \\\n \"https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME:directWrite\"\n```\n\n#### PowerShell\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\" }\n\nInvoke-WebRequest `\n -Method POST `\n -Headers $headers `\n -ContentType: \"application/json; charset=utf-8\" `\n -InFile request.json `\n -Uri \"https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME:directWrite\" | Select-Object -Expand Content\n```\n\nYou should receive a JSON response similar to the following:\n\n```\n{\n \"status\": {},\n \"writeResponses\": [\n {\n \"dataKey\": {\n \"key\": \"ENTITY_ID\"\n },\n \"onlineStoreWriteTime\": \"2025-04-01T01:30:09.525061Z\"\n }\n ]\n}\n```\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n- Learn how to [manually start a data sync](/vertex-ai/docs/featurestore/latest/sync-data).\n\n- Learn how to [update a feature view](/vertex-ai/docs/featurestore/latest/update-featureview)."]]