Azure / azure-sdk-for-js

This repository is for active development of the Azure SDK for JavaScript (NodeJS & Browser). For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/javascript/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-js.
MIT License
2.09k stars 1.2k forks source link

@azure/search-documents createSkillset(): the indexProjections part of the skillset config is not applied #28478

Open sfodor opened 9 months ago

sfodor commented 9 months ago

Describe the bug I've defined a SearchIndexerSkillset type skillset with two skills and with an indexProjections propetry. It seems when I call the indexerClient.createSkillset() with this definition, then all the configurations are applied to the new skillset except the indexProjections.

To Reproduce Steps to reproduce the behavior:

  1. Create a SearchIndexerSkillset type skillset with indexProjections like "indexProjections": { "selectors": [ { "targetIndexName": "vector-xxxxxxxxx", "parentKeyFieldName": "parent_id", "sourceContext": "/document/pages/*", "mappings": [ { "name": "chunk", "source": "/document/pages/*", "sourceContext": null, "inputs": [] }, { "name": "vector", "source": "/document/pages/*/vector", "sourceContext": null, "inputs": [] }, { "name": "title", "source": "/document/metadata_storage_name", "sourceContext": null, "inputs": [] } ] } ], "parameters": { "projectionMode": "skipIndexingParentDocuments" } },
  2. Call createSkillset() with this configuration.
  3. The call is executed without any error or warning.
  4. The indexProjections is missing from the skillset config in the Azure portal.

Expected behavior The indexProjections is visible in the skillset config in the Azure portal.

dgetu commented 9 months ago

Hello, thanks for bringing this to our attention.

This will be fixed in the next release. If you need to be unblocked sooner, you can use this patch:

diff --git a/sdk/search/search-documents/src/serviceUtils.ts b/sdk/search/search-documents/src/serviceUtils.ts
index bf2805cc49..c44644b728 100644
--- a/sdk/search/search-documents/src/serviceUtils.ts
+++ b/sdk/search/search-documents/src/serviceUtils.ts
@@ -653,14 +653,10 @@ export function publicSkillsetToGeneratedSkillset(
   skillset: SearchIndexerSkillset,
 ): GeneratedSearchIndexerSkillset {
   return {
-    name: skillset.name,
-    description: skillset.description,
-    etag: skillset.etag,
-    skills: skillset.skills,
+    ...skillset,
     cognitiveServicesAccount: convertCognitiveServicesAccountToGenerated(
       skillset.cognitiveServicesAccount,
     ),
-    knowledgeStore: skillset.knowledgeStore,
     encryptionKey: convertEncryptionKeyToGenerated(skillset.encryptionKey),
   };
 }