feat: implement complete MCP search and retrieval API with hybrid search engine - #13
Merged
Conversation
- Set HTTP content-type to application/x-ndjson; charset=UTF-8 - Send request body as byte[] instead of String to prevent Korean characters from being replaced with '?' - Remove hardcoded 'PDF' fileType, now dynamically resolved from SourceDocument - Add proper error handling for fileType resolution with 'UNKNOWN' fallback - Replace manual JSON serialization with Jackson ObjectMapper for reliability - Improve bulk indexing error handling with detailed error extraction
- Add OpenApiConfig with proper API key authentication setup - Improve DocsSourceController with comprehensive Swagger annotations - Add detailed request/response examples for all admin endpoints - Fix file upload to show proper file selection UI instead of text input - Add proper error response examples with specific error codes - Configure security requirements per endpoint group (admin vs public)
- Add GetContentRequest with flexible chunkId binding (String type) - Add JsonProperty and JsonAlias annotations for multiple field name support - Add SearchResultsResponse for structured search result wrapping - Update SearchResultItem chunkId from UUID to String to handle chunk ID patterns - Add comprehensive validation annotations and error messages - Ensure compatibility with MCP protocol JSON format requirements
- Add SearchService with Elasticsearch hybrid search (BM25 + vector similarity) - Implement proper relevance scoring with normalization against max score - Add ContentRetrievalService with tiktoken-compatible token limiting - Fix chunk ID parsing to handle string patterns without UUID conversion - Add comprehensive error handling and logging in Korean for debugging - Implement PRD-compliant snippet generation (50 chars + ellipsis) - Add proper token truncation from end to preserve important context
…tation - Add DocsSearchController interface with detailed Swagger documentation - Implement SearchController with find_knowledge and get_content MCP tools - Add comprehensive API examples and error response documentation - Ensure proper Content-Type handling for JSON requests - Follow team pattern of separating interface documentation from implementation - Add security requirements annotation (no auth for MCP endpoints) - Implement proper request validation and error handling
- Update application.yml with search API configuration parameters - Add Elasticsearch index settings and search parameter tuning - Improve docker-compose.yml for better service orchestration - Update mcp-adapter Dockerfile for enhanced compatibility - Configure proper service discovery and networking settings
- Remove duplicate method declarations causing compilation errors - Clean up redundant imports and class definitions - Add EmbeddingConfig for centralized embedding model configuration - Ensure proper service integration without conflicts
- Add V2 migration to extend document_chunks table with missing columns - Ensure database schema compatibility with search API requirements - Support enhanced metadata and indexing capabilities
- Remove redundant PRD references in comments for cleaner code - Simplify documentation while maintaining functionality - Keep essential technical details in method documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This PR implements the complete MCP Search & Retrieval API system with hybrid search capabilities and comprehensive Swagger documentation. It establishes the core search infrastructure that enables AI assistants to interact with OpenContext through the two-phase search strategy (exploratory search → focused retrieval).
Related Issues
Testing Instructions
GET /api/v1/search?query=<your-query>&topK=5for hybrid search functionality.POST /api/v1/get-contentwith JSON body{"chunkId": "<chunk-id>", "maxTokens": 8000}.metadata.fileTypereflects actual uploaded file types (PDF/MARKDOWN)./swagger-ui.htmland verify comprehensive API documentation.Key Implementation Features
Search & Retrieval Engine
tiktoken-cl100k_basecompatibility.find_knowledgeandget_contenttool implementation.API Documentation & UX
Technical Improvements
chunkIdhandling (String vs UUID).ChunkingServiceduplicate code compilation issues.Data Flow
Search Flow
Content Retrieval Flow
Checklist
Additional Notes
MCP Integration Ready
GET /api/v1/searchreturns ranked knowledge chunks with titles and snippets.POST /api/v1/get-contentprovides full content with token management.CommonResponse<T>pattern.Bug Fixes & Improvements
Breaking Changes
SearchResultItem.chunkIdchanged fromUUIDtoStringtype for better compatibility.application.ymlconfiguration parameters for search functionality.Architecture Alignment
DocsSourceControllerpattern for clean separation.SearchServiceandContentRetrievalService.GlobalExceptionHandlerintegration.