FastAPI와 Elasticsearch 기반 키워드·벡터 검색 및 DB 동기화 백엔드 구축
Act as a proficient software developer. You are tasked with building a comprehensive Elasticsearch search project using FastAPI. Your project should:
- Support various search methods: keyword, semantic, and vector search.
- Implement data splitting and importing functionalities for efficient data management.
- Include mechanisms to synchronize data from PostgreSQL to Elasticsearch.
- Design the system to be extensible, allowing for future integration with Kafka.
Responsibilities:
- Use FastAPI to create a robust and efficient API for search functionalities.
- Ensure Elasticsearch is optimized for various search queries (keyword, semantic, vector).
- Develop a data pipeline that handles data splitting and imports seamlessly.
- Implement synchronization features that keep Elasticsearch in sync with PostgreSQL databases.
- Plan and document potential integration points for Kafka to transport data.
Rules:
- Adhere to best practices in API development and Elasticsearch usage.
- Maintain code quality and documentation for future scalability.
- Consider performance impacts and optimize accordingly.
Use variables such as:
- ${searchMethod:keyword} to specify the type of search.
- ${databaseType:PostgreSQL} for database selection.
- ${integration:kafka} to indicate future integration plans.숙련된 소프트웨어 개발자로 활동하세요. FastAPI를 사용하여 포괄적인 Elasticsearch 검색 프로젝트를 구축하는 업무를 맡았습니다. 프로젝트 요구사항은 다음과 같습니다:
- 다양한 검색 방식 지원: 키워드, 시맨틱, 벡터 검색.
- 효율적인 데이터 관리를 위한 데이터 분할 및 임포트 기능 구현.
- PostgreSQL에서 Elasticsearch로의 데이터 동기화 메커니즘 포함.
- 향후 Kafka와의 통합이 가능하도록 확장성 있는 시스템 설계.
담당 업무:
- FastAPI를 사용하여 검색 기능을 위한 견고하고 효율적인 API 생성.
- 다양한 검색 쿼리(키워드, 시맨틱, 벡터)에 맞게 Elasticsearch 최적화.
- 데이터 분할 및 임포트를 매끄럽게 처리하는 데이터 파이프라인 개발.
- PostgreSQL 데이터베이스와 Elasticsearch의 동기화를 유지하는 기능 구현.
- 데이터 전송을 위한 Kafka 통합 지점 계획 및 문서화.
규칙:
- API 개발 및 Elasticsearch 사용 시 모범 사례 준수.
- 향후 확장성을 위해 코드 품질과 문서화 유지.
- 성능 영향을 고려하고 이에 맞게 최적화.
다음과 같은 변수를 사용하세요:
- ${searchMethod:keyword} (검색 유형 지정)
- ${databaseType:PostgreSQL} (데이터베이스 선택)
- ${integration:kafka} (향후 통합 계획 표시)출처 · prompts.chat · Creating a Comprehensive Elasticsearch Search Project with FastAPI — 원문은 출처에 게시된 그대로이며, 권리는 원작자에게 있습니다.
Gemini로 실행한 결과입니다. 입력 항목에는 국내 환경의 예시값을 적용했습니다(AI 생성 — 사실 확인 필요).
Act as a proficient software developer. You are tasked with building a comprehensive Elasticsearch search project using FastAPI. Your project should: - Support various search methods: keyword, semantic, and vector search. - Implement data splitting and importing functionalities for efficient data management. - Include mechanisms to synchronize data from PostgreSQL to Elasticsearch. - Design the system to be extensible, allowing for future integration with Kafka. Responsibilities: - Use FastAPI to create a robust and efficient API for search functionalities. - Ensure Elasticsearch is optimized for various search queries (keyword, semantic, vector). - Develop a data pipeline that handles data splitting and imports seamlessly. - Implement synchronization features that keep Elasticsearch in sync with PostgreSQL databases. - Plan and document potential integration points for Kafka to transport data. Rules: - Adhere to best practices in API development and Elasticsearch usage. - Maintain code quality and documentation for future scalability. - Consider performance impacts and optimize accordingly. Configurations: - Search Method: hybrid (keyword + dense_vector) - Database Type: PostgreSQL 15 - Integration: Apache Kafka (CDC Debezium)
요청하신 FastAPI + Elasticsearch 기반 하이브리드 검색 시스템 프로젝트 아키텍처 및 구현 가이드입니다.
1. FastAPI 검색 엔드포인트 설계
POST /api/v1/searchmulti_match 쿼리로 Nori 형태소 분석기 활용.dense_vector 필드 기반 kNN 검색.2. 데이터 분할 및 파이프라인 (Data Pipeline)
RecursiveCharacterTextSplitter를 사용해 긴 문서를 500자 단위(Overlap 50자)로 청크화.elasticsearch.helpers.bulk로 대용량 비동기 배치 배치.3. PostgreSQL ↔ Elasticsearch 동기화
updated_at 기준 주기적 차분 동기화.4. Kafka 확장성 설계 (Future Roadmap)
db-changes)으로 발행.mopick 개선안
원문을 그대로 넣으면 AI 가 매번 다르게 답하거나 중요한 부분을 빠뜨릴 수 있습니다. 개선안은 원문의 뜻과 언어는 그대로 두고 역할 · 바꿔 넣을 입력 칸 · 결과 형식 · 지킬 조건을 보완해 다시 쓴 버전입니다. 원문과 같은 곳(ChatGPT · Claude 등)에 그대로 붙여 넣어 쓰면 됩니다.
AI 자체 평가 — 개선안을 쓴 AI 가 명확성 · 구체성 · 결과 형식 · 재사용성 기준(100점)으로 직접 매긴 점수 · 결과를 돌려 검증한 값은 아님
입력 칸레슨 05 배우기 ›
원문 · 없음바꿔 넣을 자리가 표시돼 있지 않아 쓸 때마다 원문을 직접 고쳐야 했습니다.
개선 · 6개[DATABASE_TYPE: PostgreSQL] · [SEARCH_METHODS: keyword, semantic, vector] · [MESSAGE_BROKER: Kafka] 외 3개
작업 순서레슨 07 배우기 ›
원문 · 없음작업 순서가 정해져 있지 않아 AI 가 순서를 스스로 정해야 했습니다.
개선 · 4단계
이 개선안에 쓰인 기법 — 프롬프트 클래스에서 배우기
02맥락 · 목적 알려 주기03결과 모양 정하기05입력 칸으로 템플릿 만들기07작업을 단계로 나누기08스스로 검토하게 하기
원문
Act as a proficient software developer. You are tasked with building a comprehensive Elasticsearch search project using FastAPI. Your project should:
- Support various search methods: keyword, semantic, and vector search.
- Implement data splitting and importing functionalities for efficient data management.
- Include mechanisms to synchronize data from PostgreSQL to Elasticsearch.
- Design the system to be extensible, allowing for future integration with Kafka.
Responsibilities:
- Use FastAPI to create a robust and efficient API for search functionalities.
- Ensure Elasticsearch is optimized for various search queries (keyword, semantic, vector).
- Develop a data pipeline that handles data splitting and imports seamlessly.
- Implement synchronization features that keep Elasticsearch in sync with PostgreSQL databases.
- Plan and document potential integration points for Kafka to transport data.
Rules:
- Adhere to best practices in API development and Elasticsearch usage.
- Maintain code quality and documentation for future scalability.
- Consider performance impacts and optimize accordingly.
Use variables such as:
- ${searchMethod:keyword} to specify the type of search.
- ${databaseType:PostgreSQL} for database selection.
- ${integration:kafka} to indicate future integration plans.개선안 · 색칠한 [칸]에 내 내용을 넣어 쓰세요
Act as a Senior Search & Backend Engineer. You are tasked with designing and implementing a production-ready search service using FastAPI and Elasticsearch. Configurations: - Primary Database: [DATABASE_TYPE: PostgreSQL] - Target Search Methods: [SEARCH_METHODS: keyword, semantic, vector] - Future Integration Target: [MESSAGE_BROKER: Kafka] Task Workflow & Deliverables: 1. Index Schema & Data Pipeline: Define the Elasticsearch index mapping optimized for [SEARCH_METHODS]. Provide logic for data chunking/splitting and efficient bulk importing from [DATABASE_TYPE]. 2. Real-time/Scheduled Sync: Implement a robust synchronization mechanism to reflect changes from [DATABASE_TYPE] into Elasticsearch. 3. FastAPI Search Endpoints: Write modular FastAPI API routes supporting query parsing, pagination, filtering, and combined search strategies. 4. Event-Driven Scalability: Document explicit integration points and interface abstractions for streaming data via [MESSAGE_BROKER]. Output Requirements: - Project directory layout. - Production-grade Python code snippets (FastAPI, Elasticsearch-py) with type hints and error handling. - Elasticsearch index mapping definition (JSON). - Short self-review checklist covering performance and failure scenarios.