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

Document AI Contract Processor batchProcessDocuments忽略fieldMask问题排查

问题原因及解决方法

你的请求参数中额外添加了region字段,但BatchProcessDocumentsRequest的官方参数结构里并没有这个字段,这会导致请求解析异常,进而使fieldMask的过滤设置未被生效。

此外,name参数已经包含了区域信息(projects/XXX/locations/us/processors/3e85a4841d13ce5),完全不需要单独指定region。

修正后的代码

const documentai = require('@google-cloud/documentai').v1;
const client = new documentai.DocumentProcessorServiceClient(options);
let params = {
    "name": "projects/XXX/locations/us/processors/3e85a4841d13ce5",
    "inputDocuments": {
        "gcsDocuments": {
            "documents": [{
                "mimeType": "application/pdf",
                "gcsUri": "gs://bubble-bucket-XXX/files/CymbalContract.pdf"
            }]
        }
    },
    "documentOutputConfig": {
        "gcsOutputConfig": {
            "gcsUri": "gs://bubble-bucket-XXXX/ocr/"
        },
        "fieldMask": {
            "paths": [
                "entities"
            ]
        }
    }
};
client.batchProcessDocuments(params, function(error, operation) {
    if (error) {
        return reject(error);
    }
    return resolve({
        "operationName": operation.name
    });
});

额外检查项

  • 确保使用的@google-cloud/documentai SDK是最新版本,旧版本可能存在fieldMask的兼容性问题,可通过npm update @google-cloud/documentai更新。
  • 确认fieldMask.paths的路径正确:对于Contract Processor返回的顶级entities数组,["entities"]的设置是正确的,会仅保留该字段,自动排除content(Base64图片)、pages等不需要的内容。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 10:55:21