更新 Azure AI 搜尋服務 REST API (技能集)

您可以使用 HTTP PUT 來更新現有的 技能集知識存放區 ,並指定要在要求 URI 上更新的技能集名稱。

PUT https://[servicename].search.windows.net/skillsets/[skillset name]?api-version=[api-version]
  Content-Type: application/json
  api-key: [admin key]

注意

技能集是 Azure AI 搜尋中 AI 擴充 的基礎。 免費資源可供有限處理,但對於較大型且更頻繁的工作負載,則需要可計費的認知服務資源。 如需詳細資訊,請參閱 將認知服務資源附加至 Azure AI 搜尋技能集

URI 參數

參數 Description
服務名稱 必要。 將此設定為搜尋服務的唯一使用者定義名稱。
技能集名稱 必要。 要求 URI 會指定要更新的技能集名稱。
api-version 必要。 目前的穩定版本為 api-version=2020-06-30 。 如需更多版本,請參閱 API 版本
disableCacheReprocessingChangeDetection 選擇性。 預設會用於累加式擴充 (false) 。 設定為 true ,以防止根據目前動作更新現有檔。 如需詳細資訊,請參閱 快取管理

要求標頭

下表說明必要及選用的要求標頭。

欄位 Description
Content-Type 必要。 請設為 application/json
api-key 如果您使用 Azure 角色 ,而且要求會提供持有人權杖,則為選擇性,否則需要金鑰。 API 金鑰是唯一的系統產生字串,可驗證對搜尋服務的要求。 更新要求必須包含 api-key 設定為系統管理員金鑰的標頭 (,而不是查詢金鑰) 。 如需詳細資訊 ,請參閱使用金鑰驗證連線到 Azure AI 搜尋 服務。

要求本文

要求本文語法與 Create Skillset相同。

更新現有的技能集時,整個定義會取代為要求本文的內容。 一般而言,用於更新的最佳模式是使用 GET 擷取技能集定義、修改它,然後使用 PUT 進行更新。

回應

若要求成功,應該會看到狀態碼 "201 Created"。

根據預設,回應本文將包含所建立技能集定義的 JSON。 不過,如果將 Prefer 要求標頭設為 return=minimal,回應本文將會空白,而成功狀態碼會是 "204 No Content",而不是 "201 Created"。 無論使用 PUT 或 POST 建立技能集,都會發生此情況。

範例

範例:更新技能集

下列範例會更新用來擴充財務檔集合的技能集。

PUT https://[servicename].search.windows.net/skillsets/financedocenricher?api-version=2020-06-30
api-key: [admin key]
Content-Type: application/json

要求的本文是 JSON 文件。 這個特定技能集會以非同步方式使用兩種技能,獨立處理 的 /document/content 本質作為兩個不同的轉換。 或者,您可以將某個轉換的輸出導向為另一個轉換的輸入。 如需詳細資訊,請參閱如何定義技能集

{
  "name": "financedocenricher",
  "description": 
  "An updated version of a skillset used to extract sentiment from financial records, extract company names, and then find additional information about each company mentioned. This version changes the target names.",
  "skills":
  [
    {
      "@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill",
      "categories": [ "Organization" ],
      "defaultLanguageCode": "en",
      "inputs": [
        {
          "name": "text",
          "source": "/document/content"
        }
      ],
      "outputs": [
        {
          "name": "organizations",
          "targetName": "companies"
        }
      ]
    },
    {
      "@odata.type": "#Microsoft.Skills.Text.SentimentSkill",
      "inputs": [
        {
          "name": "text",
          "source": "/document/content"
        }
      ],
      "outputs": [
        {
          "name": "score",
          "targetName": "positivityscore"
        }
      ]
    },
  ],
  "cognitiveServices": 
  {
  "@odata.type": "#Microsoft.Azure.Search.CognitiveServicesByKey",
  "description": "mycogsvcs resource in West US 2",
  "key": "<your key goes here>"
  }
}

範例:移除認知服務金鑰

如果您想要更新現有的技能集,並移除附加至它的認知服務金鑰,請將 設定 @odata.type#Microsoft.Azure.Search.DefaultCognitiveServices 來修改 區 cognitiveServices 段。

{
  "name": "financedocenricher"
  "skills":
  [
    {
      "@odata.type": "#Microsoft.Skills.Text.EntityRecognitionSkill",
      "categories": [ "Organization" ],
      "defaultLanguageCode": "en",
      "inputs": [
        {
          "name": "text",
          "source": "/document/content"
        }
      ],
      "outputs": [
        {
          "name": "organizations",
          "targetName": "companies"
        }
      ]
    },
  ],
  "cognitiveServices": 
  {
  "@odata.type": "#Microsoft.Azure.Search.DefaultCognitiveServices"
  }
}

另請參閱