更新特徵檢視畫面

您可以更新特徵檢視,修改與之相關聯的特徵資料來源清單。舉例來說,您可能需要進行下列更新:

  • 將不同的特徵群組和特徵建立關聯,或是將同一個特徵群組中的不同特徵建立關聯。

  • 指定另一個包含特徵資料的 BigQuery 資料表或檢視表。請注意,在這種情況下,您還需要從更新的資料來源指定一或多個實體 ID 欄。

  • 指定相同 BigQuery 資料來源的不同實體 ID 欄組。

建立或更新地圖檢視圖層時,您可以選擇以標籤的形式,將使用者定義的中繼資料新增至地圖檢視圖層。如要進一步瞭解如何更新地圖檢視畫面的使用者定義標籤,請參閱「更新地圖檢視畫面的標籤」。

請注意,您無法更新已設定為持續性資料同步處理的功能檢視。

事前準備

驗證 Vertex AI (如果您尚未驗證)。

如要在本機開發環境中使用本頁的 REST API 範例,請使用您提供給 gcloud CLI 的憑證。

    After installing the Google Cloud CLI, initialize it by running the following command:

    gcloud init

    If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

詳情請參閱 Google Cloud 驗證說明文件中的「驗證以使用 REST」。

根據特徵群組更新特徵檢視

使用下列範例,指定現有地圖項目群組中的地圖項目,藉此更新地圖項目檢視畫面。

REST

如要更新 FeatureView 資源,請使用 featureViews.patch 方法傳送 PATCH 要求。

使用任何要求資料之前,請先替換以下項目:

  • LOCATION_ID:線上商店所在的區域,例如 us-central1
  • PROJECT_ID:您的專案 ID。
  • FEATUREONLINESTORE_NAME:包含功能檢視畫面的線上商店名稱。
  • FEATUREVIEW_NAME:要更新的地圖項目檢視畫面名稱。
  • FEATUREGROUP_NAME:您要與地圖項目檢視畫面建立關聯的地圖項目群組名稱。
  • FEATURE_ID_1FEATURE_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", ...]

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"
  }
}

後續步驟