I’m looking at the Google DocumentAI SDK and I’m trying to filter out an “inner” field, specifically the BoundingPoly.vertices
field from all objects.
The bounding poly is part of the Layout
object which is itself part of the Page
object but also Block
, Paragraph
and many other objects. I’m looking to filter out the vertices
field from everywhere because the BoundingPoly also comes with the normalizedVertices
field which is equivalent and I don’t need both of them (each document shard I receive contains 8000 x2 or those objects and JSON parsing is the slowest part of the process in general).
I tried something like this
FieldMask.Builder bldr = FieldMask.newBuilder();
for (Descriptors.FieldDescriptor fieldDescr : BoundingPoly.getDescriptor().getFields()) {
if("vertices".equalsIgnoreCase(fieldDescr.getName()))
continue;
bldr.addPaths("bounding_poly." + fieldDescr.getJsonName());
}
but the API complains with Only top level document and page fields are supported in field mask, got bounding_poly.normalizedVertices which means that it can either accept field on the Document
or on the Page
object.
Is there another way of doing this? I don’t want to filter the JSON file or some weird thing like that, I’d expect the API to support this.