Repository navigation
feat(api): support convert-side chunking - #833
Conversation
ConvertDocumentsOptions exposes chunking_preset and chunking_options, letting the convert endpoints chunk a document in the same pass that converts it, instead of converting and then sending the result back to /chunk. Mapping these two request properties alone would be inert, so this change lands them together with the two other pieces needed to make the feature usable: * OutputFormat.CHUNKS, the trigger the server requires in to_formats to activate chunking, appended at the end of the enum to preserve the ordinal position of the existing constants. * A new ChunkedConvertDocumentResponse (ResponseType.CHUNKED) for the in-body shape, reusing the chunk API's Chunk and Document types since the server's ChunkedDocumentResult is structurally identical. The Jackson 2/3 convert response deserializers now check for "chunks" before "documents", since a chunked response also carries a "documents" field and would otherwise be misrouted to PreSignedUrlConvertResponse. * ArtifactType.CHUNKS, so the presigned-target path (where the chunks file comes back as a "chunks" artifact) deserializes instead of throwing on an unrecognized enum constant. Related to docling-project#821, docling-project#822. Assisted-By: Claude Code <noreply@anthropic.com> Signed-off-by: Eric Deandrea <eric.deandrea@ibm.com>
There was a problem hiding this comment.
🟡 Changes recommended
Empty chunk lists omit the chunks discriminator during serialization, breaking response round-trips, while documentation also overstates inline-chunk support and uses an unregistered preset example.
3 open issues
What changed in this PR
Adds Java API support for requesting chunking during document conversion, avoiding a separate /chunk request where supported by the server. This complements the output-format additions in #828 and addresses #821.
Changes:
- Adds chunking options and
CHUNKSoutput/artifact enum values. - Introduces a chunked convert response and updates both Jackson deserializers to recognize it.
- Adds model tests, client regression coverage, and release documentation.
| File | Description |
|---|---|
docs/src/doc/docs/whats-new.md |
Documents convert-side chunking and its API additions. |
docling-serve/docling-serve-client/src/test/java/ai/docling/serve/client/AbstractDoclingServeClientTests.java |
Adds shared client coverage for chunked response dispatch. |
docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ConvertDocumentResponseTests.java |
Tests chunked response fields and defaults. |
docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/response/ArtifactRefTests.java |
Tests the chunks artifact type. |
docling-serve/docling-serve-api/src/test/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptionsTests.java |
Tests chunking options, defaults, and builder copying. |
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson3ConvertDocumentResponseDeserializer.java |
Checks for chunks before presigned documents in Jackson 3. |
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/serialization/Jackson2ConvertDocumentResponseDeserializer.java |
Checks for chunks before presigned documents in Jackson 2. |
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ResponseType.java |
Adds the CHUNKED response category. |
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConvertDocumentResponse.java |
Permits the new chunked response subtype. |
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ChunkedConvertDocumentResponse.java |
Models chunks, converted documents, and processing time. |
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ArtifactType.java |
Maps the chunks artifact value. |
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/OutputFormat.java |
Adds CHUNKS and restores the original six constants’ positions. |
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/convert/request/options/ConvertDocumentOptions.java |
Adds chunking preset and configuration properties. |
Review effort: Balanced
:java_duke: JaCoCo coverage report
|
|
||||||||||||||
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
…erver
Verified against a live docling-serve v1.41.0 container: when "chunks"
is requested in to_formats together with a single-document InBodyTarget,
the server silently omits chunk output entirely and returns a plain
in-body document response instead. The {chunks, documents,
processing_time} shape modeled by ChunkedConvertDocumentResponse is
actually the response shape of the dedicated /chunk endpoints, not
anything /convert/source ever returns, so the chunks-before-documents
dispatch fix in both Jackson deserializers was never reachable from a
real server response.
The presigned-target chunking support (ArtifactType.CHUNKS,
chunkingPreset/chunkingOptions on ConvertDocumentOptions) is unaffected
and was confirmed against the same container to behave as implemented.
Also corrects the chunkingPreset javadoc/test example: "hybrid" and
"hierarchical" are the chunker discriminator used by ChunkerOptions,
not registered chunking_preset ids.
Related to docling-project#821, docling-project#822.
Assisted-By: Claude Code <noreply@anthropic.com>
Signed-off-by: Eric Deandrea <eric.deandrea@ibm.com>
There was a problem hiding this comment.
🟡 Changes recommended
The chunking documentation incorrectly excludes ZIP output support for both chunkingPreset and chunkingOptions and needs correction while retaining the single-document in-body warning.
1 open issue
3 resolved since last review
Review effort: Balanced
The previous javadoc/whats-new.md fix overcorrected: chunk output is dropped only for a single-document InBodyTarget. Docling Serve also writes a *.chunks.jsonl file into the ZIP archive for ZipTarget and multi-document InBodyTarget requests, confirmed against the same docling-serve v1.41.0 container used to verify the earlier fix. Related to docling-project#821, docling-project#822. Assisted-By: Claude Code <noreply@anthropic.com> Signed-off-by: Eric Deandrea <eric.deandrea@ibm.com>
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |


Summary
Docling Serve's
ConvertDocumentsOptionsexposeschunking_presetandchunking_options, letting the convert endpoints chunk a document in the same pass that converts it, instead of converting and then sending the result back to/chunk. Mapping these two request properties on their own would be inert, so this PR lands them together with the two other pieces needed to make the feature usable:OutputFormat.CHUNKS— the trigger the server requires into_formatsto activate chunking. Appended at the end of the enum (along with the five values added in feat(api): add missing OutputFormat values #828) to preserve the ordinal position of the existing constants.ConvertDocumentOptions.chunkingPreset/chunkingOptions— the chunker configuration, reusing the existingChunkerOptionssealed type whosechunkerdiscriminator already matches the server'soneOf.ChunkedConvertDocumentResponse(ResponseType.CHUNKED) for the in-body response shape, reusing the chunk API'sChunkandDocumenttypes since the server'sChunkedDocumentResultis structurally identical. The Jackson 2/3 convert response deserializers now check forchunksbeforedocuments, since a chunked response also carries adocumentsfield and would otherwise be misrouted toPreSignedUrlConvertResponse.ArtifactType.CHUNKS, so the presigned-target path (where the chunks file comes back as achunksartifact) deserializes instead of throwing on an unrecognized enum constant.Closes #821. Related to #822.
Test plan
./gradlew --no-daemon :docling-serve-api:test— new unit tests forConvertDocumentOptions,ChunkedConvertDocumentResponse, andArtifactRef./gradlew --no-daemon :docling-serve-client:test— new WireMock-based regression test (shouldConvertSourceWithInBodyTargetAndChunkingSuccessfully) for both Jackson 2 and Jackson 3 clients, covering thechunks-before-documentsdispatch fix./gradlew --no-daemon spotlessCheckAssisted-By: Claude Code noreply@anthropic.com