Class DoclingDocumentParser
- All Implemented Interfaces:
DocumentParser
DocumentParser backed by a Docling Serve instance.
The operation performed by Docling (convert, hierarchical chunking, hybrid chunking, ...) is controlled by the
DocumentRequest template supplied to the DoclingDocumentParser.Builder. The template carries everything except the document
source: the parser injects the source of the InputStream being parsed into a fresh copy of the template for
each call, then routes the request to the matching Docling endpoint. How the resulting response is turned into a
Document is controlled by the document extractor (for
conversion requests) and the chunk extractor (for chunk requests);
text-only variants are also available.
How Docling is actually called is controlled by the request executor. By default the parser calls the asynchronous convert/chunk endpoints and exposes both a blocking
parse(InputStream) and a non-blocking parseAsync(InputStream).
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDoclingDocumentParser(ai.docling.serve.api.DoclingServeApi doclingClient) Deprecated, for removal: This API element is subject to removal in a future version.DoclingDocumentParser(ai.docling.serve.api.DoclingServeApi doclingClient, ai.docling.serve.api.convert.request.options.ConvertDocumentOptions options) Deprecated, for removal: This API element is subject to removal in a future version.usebuilder()withDoclingDocumentParser.Builder.doclingClient(DoclingServeApi)and aDoclingDocumentParser.Builder.documentRequest(DocumentRequest)carrying aConvertDocumentRequestwith the desiredConvertDocumentOptionsinstead -
Method Summary
Modifier and TypeMethodDescriptionbuilder()parse(InputStream inputStream) Parses a givenInputStreaminto aDocument.parseAsync(InputStream inputStream) Parses the givenInputStreamwithout blocking, returning a stage that completes with the resultingDocument.
-
Constructor Details
-
DoclingDocumentParser
@Deprecated(forRemoval=true) public DoclingDocumentParser(ai.docling.serve.api.DoclingServeApi doclingClient) Deprecated, for removal: This API element is subject to removal in a future version.usebuilder()withDoclingDocumentParser.Builder.doclingClient(DoclingServeApi)instead -
DoclingDocumentParser
@Deprecated(forRemoval=true) public DoclingDocumentParser(ai.docling.serve.api.DoclingServeApi doclingClient, ai.docling.serve.api.convert.request.options.ConvertDocumentOptions options) Deprecated, for removal: This API element is subject to removal in a future version.usebuilder()withDoclingDocumentParser.Builder.doclingClient(DoclingServeApi)and aDoclingDocumentParser.Builder.documentRequest(DocumentRequest)carrying aConvertDocumentRequestwith the desiredConvertDocumentOptionsinstead
-
-
Method Details
-
builder
-
parse
Description copied from interface:DocumentParserParses a givenInputStreaminto aDocument. The specific implementation of this method will depend on the type of the document being parsed.Note: This method does not close the provided
InputStream- it is the caller's responsibility to manage the lifecycle of the stream.- Specified by:
parsein interfaceDocumentParser- Parameters:
inputStream- TheInputStreamthat contains the content of theDocument.- Returns:
- The parsed
Document.
-
parseAsync
Parses the givenInputStreamwithout blocking, returning a stage that completes with the resultingDocument. This is the asynchronous counterpart ofparse(InputStream)and is intended for reactive or non-blocking pipelines.- Parameters:
inputStream- the document content to parse; the caller owns its lifecycle and this method does not close it- Returns:
- a stage completing with the parsed
Document
-
builder()withDoclingDocumentParser.Builder.doclingClient(DoclingServeApi)instead