liveBook · Manning

Spring AI Tika Document Reader

As explained in Spring AI in Action

TikaDocumentReader is a Spring AI document reader that uses Apache Tika to read many document formats.

TikaDocumentReader loads documents into Spring AI when an application must accept more than one file format. Based on Apache Tika, it handles formats such as PDF, plain text, Microsoft Word, Excel, and PowerPoint, making it a flexible alternative to a PDF-specific reader. section 4.3.3

In a Spring Boot document-ingestion pipeline, the reader can consume file bytes from Spring Function Catalog and emit Spring AI Document objects. A reactive Flux keeps files moving through the long-running pipeline as they become available; boundedElastic scheduling handles the reader operation without interrupting the reactive flow. section 4.3.3

Registering the reader as a pipeline function

Add the Spring AI Tika reader dependency, then define a bean such as: @Bean Function<Flux<byte[]>, Flux<Document>> documentReader() { return resourceFlux -> resourceFlux.map(fileBytes -> new TikaDocumentReader(new ByteArrayResource(fileBytes)).get().getFirst()).subscribeOn(Schedulers.boundedElastic()); } section 4.3.3

implementation 'org.springframework.ai:spring-ai-tika-document-reader'

Inspect the dependency required to place TikaDocumentReader on the application classpath. section 4.3.3

How Spring AI in Action covers it

How deep it goes
Explains supported formats, dependency setup, reactive inputs and outputs, and a working bean implementation without detailing Apache Tika internals.
Examples
Uses a Board Game Buddy rules loader that accepts file bytes, creates a ByteArrayResource, and emits the first parsed Document.
What it assumes
Assumes Spring Boot, Spring AI, Project Reactor Flux, and file-supplier knowledge while explaining why byte streams continue through the pipeline.
What you can do after
Build it from scratch as a reactive Spring function that converts incoming file bytes into Spring AI documents.
How it connects
Connects document ingestion with Apache Tika, Spring Boot, Project Reactor, Spring Function Catalog, document splitting, and vector stores.

This explainer was generated by Manning's knowledge graph from the text of Spring AI in Action. The section links point to the parts of the book it draws on.