You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在分块Azure AI搜索索引中获取对应分块的图片Base64数据

解决Azure AI搜索分块对应图片Base64的问题

第一步:排查索引字段定义错误

错误提示的核心是索引name中没有匹配image的字段,先确认你的索引结构:

  • 确保索引里存在名为image的字段,类型设置为Edm.String(用来存储Base64字符串)
  • 如果之前是通过「导入并向量化数据」自动创建的索引,需要手动添加image字段,自动创建的索引不会包含这个自定义字段

第二步:修正技能集的索引投影配置

当前配置的问题在于图片路径关联错误,且没有正确将分块(page)与对应图片绑定。修改后的配置如下:

"indexProjections": {
    "selectors": [
      {
        "targetIndexName": "name",
        "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": []
          },
          {
            "name": "image",
            "source": "/document/normalized_images/*/data",
            "sourceContext": "/document/pages/*",
            "inputs": [
              {
                "source": "/document/pages/*/number",
                "name": "pageNumber"
              },
              {
                "source": "/document/normalized_images/*/pageNumber",
                "name": "imagePageNumber"
              }
            ],
            "transform": "($where: $imagePageNumber == $pageNumber).$data"
          }
        ]
      }
    ]
}

配置说明

  • 新增transform逻辑:通过页面编号(pageNumber)匹配图片所属的页面,确保每个分块(对应单个page)只获取当前页面的图片Base64数据
  • 修正source路径为/document/normalized_images/*/data,这是标准化图片Base64数据的正确路径
  • 通过inputs传入分块的页面编号和图片关联的页面编号,用$where过滤出当前分块对应的图片

替代方案:使用自定义技能关联分块与图片

如果上述投影映射的transform逻辑无法满足需求,可以添加一个自定义技能:

  1. 在技能集中新增一个自定义技能,输入为分块的页面编号和所有normalized_images数据
  2. 自定义技能内部逻辑:根据页面编号筛选出对应图片的Base64数据
  3. 在索引投影中,将image字段的source指向自定义技能的输出结果

内容的提问来源于stack exchange,提问作者alice

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 11:17:43