简体   繁体   中英

Trying to get specific fields using field_mask in Google Cloud document AI API request Python

I'm having this issue because i only want specific fields from the default JSON that returns Google Cloud Document AI . The fields i want to get using the field mask are: "text" and inside "pages" i just only want "tables" and "formFields". For "text" "tables" i haven't got any issues doing the field_mask param in the request like this:

# Configure the process request
        request = documentai.ProcessRequest( 
            name=resource_name, raw_document=raw_document, field_mask="text,pages.tables"
        ) 

The problem is only when im trying to access the fields inside "formFields" because i just want the marked fields i show in this image of the JSON:

在此处输入图像描述

I tried using field_mask="pages.formFields.fieldName.textAnchor.content,pages.formFields.fieldValue.textAnchor.content" And when i do the request using Postman, the request take a long time with "Sending request" message and never returns anything.

I want to remember that this problem only happens when im trying to access a field inside "formFields", if i don't try this the request is succesfull so i think the problem isn't associated with how i do the request, i think is just im not using the correct syntax and i can't find any information or documentation about this. Thank you and advise me if you need more information or code.

Google Documentation on Field Mask mentions,

A repeated field is not allowed except at the last position of a field mask.

It looks like child values like "content"(in your JSON) cannot be retrieved directly using field mask. However, one can apply filters using client library to retrieve these child values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM