您可以更新特徵檢視,修改與其相關聯的特徵資料來源清單。舉例來說,您可能想進行下列更新:
關聯不同的特徵群組和特徵,或同一特徵群組中的不同特徵集。
指定包含特徵資料的其他 BigQuery 資料表或檢視表。請注意,在這種情況下,您也需要指定更新資料來源中的一或多個實體 ID 資料欄。
從同一個 BigQuery 資料來源指定另一組實體 ID 欄。
建立或更新特徵檢視區塊時,您可以選擇以標籤形式,將使用者定義的中繼資料新增至特徵檢視區塊。如要進一步瞭解如何更新特徵檢視區塊的使用者定義標籤,請參閱「更新特徵檢視區塊的標籤」。
請注意,您無法更新設定為持續資料同步的特徵檢視區塊。
事前準備
向 Gemini Enterprise Agent Platform 驗證,除非您已完成驗證。
如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。
安裝 Google Cloud CLI。
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
詳情請參閱 Google Cloud 驗證說明文件中的「使用 REST 進行驗證」。
根據特徵群組更新特徵檢視
使用下列範例,從現有特徵群組指定特徵,藉此更新特徵檢視區塊。
REST
如要更新 FeatureView 資源,請使用 featureViews.patch 方法傳送 PATCH 要求。
使用任何要求資料之前,請先修改下列項目的值:
- LOCATION_ID:網路商店所在的區域,例如
us-central1。 - PROJECT_ID:專案 ID。
- FEATUREONLINESTORE_NAME:包含特徵檢視區塊的網路商店名稱。
- FEATUREVIEW_NAME:要更新的特徵檢視區塊名稱。
- FEATUREGROUP_NAME:要與特徵檢視區塊建立關聯的特徵群組名稱。
- FEATURE_ID_1 和 FEATURE_ID_2:要從 FEATUREGROUP_NAME 特徵群組新增至特徵檢視畫面的特徵 ID。
HTTP 方法和網址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME
JSON 要求內文:
{
"feature_registry_source":
{ "feature_groups": [
{
"feature_group_id": "FEATUREGROUP_NAME",
"feature_ids": [ "FEATURE_ID_1", "FEATURE_ID_2" ]
}
]
}
}
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME"
PowerShell
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME" | Select-Object -Expand Content
您應該會收到如下的 JSON 回覆:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureViewOperationMetadata",
"genericMetadata": {
"createTime": "2023-09-15T04:53:22.794004Z",
"updateTime": "2023-09-15T04:53:22.794004Z"
}
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.cloud.aiplatform.v1.FeatureView",
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME"
}
}
根據 BigQuery 來源更新特徵檢視區塊
使用下列範例,從 BigQuery 資料表或檢視區塊指定特徵資料欄,藉此更新特徵檢視區塊。
REST
如要根據 BigQuery 資料來源更新 FeatureView 執行個體,請使用 featureViews.patch 方法傳送 PATCH 要求。
使用任何要求資料之前,請先修改下列項目的值:
- LOCATION_ID:網路商店所在的區域,例如
us-central1。 - PROJECT_ID:專案 ID。
- FEATUREONLINESTORE_NAME:包含特徵檢視區塊的網路商店名稱。
- FEATUREVIEW_NAME:要更新的特徵檢視區塊名稱。
- BIGQUERY_SOURCE_URI:包含特徵資料的 BigQuery 資料表或檢視區塊 URI。
- ENTITY_ID_COLUMNS:
- ENTITY_ID_COLUMNS:包含實體 ID 的資料欄名稱。您可以指定單一資料欄或多個資料欄。
- 如要只指定一個實體 ID 欄,請以下列格式指定欄名:
"entity_id_column_name"。 - 如要指定多個實體 ID 資料欄,請採用以下格式指定資料欄名稱:
["entity_id_column_1_name", "entity_id_column_2_name", ...]。
- 如要只指定一個實體 ID 欄,請以下列格式指定欄名:
HTTP 方法和網址:
PATCH https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME
JSON 要求內文:
{
"big_query_source":
{
"uri": "BIGQUERY_SOURCE_URI",
"entity_id_columns": "ENTITY_ID_COLUMNS"
}
}
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME"
PowerShell
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME" | Select-Object -Expand Content
您應該會收到如下的 JSON 回覆:
{
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME/operations/OPERATION_ID",
"metadata": {
"@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeatureViewOperationMetadata",
"genericMetadata": {
"createTime": "2023-09-15T04:53:34.832192Z",
"updateTime": "2023-09-15T04:53:34.832192Z"
}
},
"done": true,
"response": {
"@type": "type.googleapis.com/google.cloud.aiplatform.v1.FeatureView",
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureOnlineStores/FEATUREONLINESTORE_NAME/featureViews/FEATUREVIEW_NAME"
}
}