AI / LangChain4j interview questions
What is the DocumentLoader API in LangChain4j and what sources does it support?
Document loaders are the entry point of any RAG ingestion pipeline — they read raw content from a source and return it as a list of Document objects, each containing the text content and source metadata. LangChain4j's loaders all implement the DocumentLoader interface and populate the Document.metadata() map with source-specific information like file path, URL, or S3 key.
Built-in document loader sources include:
| Loader | Source | Notes |
|---|---|---|
| FileSystemDocumentLoader | Local files and directories | Supports glob patterns; auto-detects parser by extension |
| UrlDocumentLoader | HTTP/HTTPS URLs | Fetches and parses web pages |
| ClassPathDocumentLoader | Classpath resources | Good for embedded documentation in JARs |
| AmazonS3DocumentLoader | AWS S3 buckets | Via langchain4j-document-loader-amazon-s3 |
| AzureBlobStorageDocumentLoader | Azure Blob Storage | Via langchain4j-document-loader-azure-storage-blob |
| GitHubDocumentLoader | GitHub repositories | Loads files from a repo branch |
Document parsers handle format-specific extraction: TextDocumentParser for plain text, ApachePdfBoxDocumentParser for PDFs, ApacheTikaDocumentParser for Word/Excel/PowerPoint and 100+ other formats. Parsers are composable with loaders:
// Load all PDFs from a directory List<Document> docs = FileSystemDocumentLoader.loadDocuments( "./knowledge-base", PathMatcher.of("glob:**.pdf"), new ApachePdfBoxDocumentParser() );
More Related questions...