Feature/ingestion pipeline#12
Conversation
- Create new service for parsing uploaded documents - Integrate with Unstructured API for text extraction - Support multiple document formats (PDF, Markdown, etc.) - Handle document parsing errors and validation
- Update CommonResponse for better API response formatting - Improve WebConfig for enhanced web configuration - Add new error codes for document processing pipeline
- Modify DTO structure to support document chunking - Update fields for better chunk processing - Prepare data model for chunking service integration
- Rename parent_chunk_id to parent_chunk_uuid for consistency - Add source_document_uuid for direct access - Improve JPA relationship mapping structure
- Add document status management methods - Implement complete document deletion pipeline - Improve logging with emojis and categories - Add Elasticsearch and PostgreSQL cleanup integration
- Implement document chunking logic and strategies - Add hierarchical structure management - Support various document types and formats
- Add updateLastIngestedAt for tracking ingestion completion - Add updateErrorMessage and clearErrorMessage for error handling - Improve entity state management capabilities
- Integrate LangChain4j with Ollama for embedding generation - Implement batch processing for performance optimization - Generate semantic vectors for document chunks - Support configurable batch sizes and model parameters
- Implement Elasticsearch bulk indexing for vector data - Add PostgreSQL hierarchy storage for document structure - Include content sanitization to prevent JSON parsing errors - Support batch processing for performance optimization
…line - Add full document processing pipeline (PARSING → CHUNKING → EMBEDDING → INDEXING) - Implement asynchronous processing for better performance - Integrate with new modular services (ChunkingService, EmbeddingService, IndexingService) - Add comprehensive error handling and status management
There was a problem hiding this comment.
Pull Request Overview
This PR implements a complete document ingestion pipeline that transforms the legacy monolithic architecture into a modular service-based system. It establishes an end-to-end workflow for document processing from upload through semantic search indexing, with comprehensive async processing and error handling.
- Pipeline Implementation: Transforms single-responsibility controller into orchestrated pipeline (PARSING → CHUNKING → EMBEDDING → INDEXING)
- Service Modularization: Breaks down monolithic SourceDocumentService into specialized services (DocumentParsingService, ChunkingService, EmbeddingService, IndexingService)
- Dual Storage Strategy: Implements hybrid storage with Elasticsearch for vector search and PostgreSQL for hierarchical structure
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| SourceDocumentService.java | Complete removal of legacy monolithic service |
| SourceController.java | New unified controller with embedded pipeline orchestration |
| FileStorageService.java | Enhanced with document metadata management and comprehensive deletion |
| DocumentParsingService.java | New service for Unstructured API integration |
| ChunkingService.java | New service for hierarchical document chunking |
| EmbeddingService.java | New service for LangChain4j/Ollama embedding generation |
| IndexingService.java | New service for dual Elasticsearch/PostgreSQL indexing |
| Entity/DTO updates | Schema changes to support new pipeline architecture |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| .hierarchyLevel(chunk.getHierarchyLevel()) | ||
| .parentChunkId(parentChunkUuid) | ||
| .elementType(chunk.getElementType()) | ||
| .sequenceInDocument(0) // 기본값 설정, 실제로는 순서에 따라 설정해야 함 |
There was a problem hiding this comment.
The sequenceInDocument field is hardcoded to 0 with a Korean comment indicating this should be set based on actual order. This could lead to incorrect document structure representation and should be properly calculated.
| .sequenceInDocument(0) // 기본값 설정, 실제로는 순서에 따라 설정해야 함 | |
| .sequenceInDocument(i) // 실제 순서에 따라 설정 |
| json.append("}"); | ||
| return json.toString(); | ||
| } | ||
| return obj.toString(); |
There was a problem hiding this comment.
The manual JSON serialization implementation is fragile and incomplete. Consider using Jackson ObjectMapper for proper JSON serialization, especially since the comment on line 261 acknowledges this should use ObjectMapper.
| return obj.toString(); | |
| private static final ObjectMapper objectMapper = new ObjectMapper(); | |
| /** | |
| * 객체를 JSON 문자열로 변환합니다. | |
| * Jackson ObjectMapper를 사용하여 안전하게 변환합니다. | |
| */ | |
| private String toJsonString(Object obj) { | |
| try { | |
| return objectMapper.writeValueAsString(obj); | |
| } catch (JsonProcessingException e) { | |
| log.error("JSON 직렬화 오류", e); | |
| throw new RuntimeException("JSON 직렬화 오류", e); | |
| } |
| /** | ||
| * content 필드의 Java 코드나 특수문자를 정리하여 JSON 파싱 에러를 방지합니다. | ||
| */ | ||
| private String sanitizeContent(String content) { |
There was a problem hiding this comment.
The content sanitization logic is overly aggressive and removes potentially meaningful content. The regex patterns could inadvertently remove legitimate text that contains Java keywords or similar patterns.
| /** | ||
| * 문서 수집 파이프라인을 비동기적으로 실행합니다. | ||
| */ | ||
| @Async |
There was a problem hiding this comment.
| /** | ||
| * 문서 삭제 파이프라인을 비동기적으로 실행합니다. | ||
| */ | ||
| @Async |
There was a problem hiding this comment.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ice.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Here's the PR template in English based on the git log:
Summary of Changes
This PR implements a complete document processing pipeline that transforms the existing legacy architecture into a new modular service architecture. It supports the entire workflow from document upload to semantic search, including asynchronous processing and comprehensive error handling.
Type of Change
Related Issues
Testing Instructions
Screenshots (if applicable)
Checklist
Additional Notes
🚀 Key Implementation Features
🔧 Technical Improvements
@AsyncData Flow
🏗️ Architecture Changes
This PR represents a complete redesign of the document processing system, so please review it from an overall architecture perspective. The changes include significant refactoring and new service implementations that work together to provide a robust document ingestion pipeline.