是否可以使用元数据作为 Azure 搜索中自定义技能的输入?

Is it possible to use metadata as input for custom skill in azure search?

几个月前我开始使用 Azure 搜索,但我对 blob 文件的元数据有疑问。

我需要文件的元数据(来自 Azure Blob)才能在我的习惯技能中使用它。 (更具体地说,我需要存储它的 blob 文件的 URL)。

要做到这一点,我需要在我的技能组合中做到这一点,我会做类似 this image 的事情。但这是不可能的,因为来源必须以 /document?如果我将“/document/metadata_storage_path/”作为“Source”,我最后会得到一个空值吗?

有没有办法获取文件的元数据作为输入以进一步使用它?

提前致谢!

我认为您的源路径必须是“/document/metadata_storage_path”,末尾没有额外的“/”。使用额外的“/”,源路径被解释为 metadata_storage_path 中名称为“”(空字符串)的目录。

我发现了为什么它(和解决方案)对我不起作用。我希望我能帮助其他遇到这个问题的人。

Sophiac 上面提到的语法是正确的。所以在我的例子中,我使用 "metadata_storage_path" 作为技能组的输入:

{
      "@odata.type": "#Microsoft.Skills.Custom.WebApiSkill",
      "description": "Our new substring custom skill",
      "uri": "https://customskillsubstring.azurewebsites.net/api/Translate?code=OkzL7G3wX----jCqQylUyJJPaggSaFQCaQ==",
      "batchSize":1,
      "context": "/document",
      "inputs": [
        {
          "name": "text", "source": "/document/metadata_storage_path"
        }
      ],
      "outputs": [
        {
          "name": "text",
          "targetName": "metadata_storage_path_wathever"
        }
      ]
    }

问题出在索引器中。我在字段映射中将 "metadata_storage_path" 映射到其他内容(在我的例子中是 "blob_uri")。问题是这不是真正的映射,而更像是替换。所以 "metadata_storage_path" 在技能集中是空的,因为它已经被替换了。

但是如果我使用 "blob_uri" 它就可以了。 解决方案是您可以将一个输入映射到索引器中的多个事物:

"fieldMappings" : [
        {
          "sourceFieldName" : "metadata_storage_name",
          "targetFieldName" : "id",
          "mappingFunction" :
            { "name" : "base64Encode" }
        },
        {
          "sourceFieldName" : "content",
          "targetFieldName" : "content"
        },
        {
          "sourceFieldName" : "metadata_storage_path",
          "targetFieldName" : "blob_uri"
        },
        {
          "sourceFieldName" : "metadata_storage_path",
          "targetFieldName" : "metadata_storage_path"
        }
   ], 

现在我可以使用 "blob_uri" 和 "metadata_storage_path" 作为我的习惯技能的输入。