Integrate Elasticsearch and implement search index Sync patterns in NestJS. Use when integrating Elasticsearch or implementing search index sync in NestJS.
Scanned 6/6/2026
Install via CLI
openskills install HoangNguyen0403/agent-skills-standard---
name: nestjs-search
description: Integrate Elasticsearch and implement search index Sync patterns in NestJS. Use when integrating Elasticsearch or implementing search index sync in NestJS.
metadata:
triggers:
files:
- '**/*.service.ts'
- '**/search/**'
keywords:
- Elasticsearch
- CQRS
- Synchronization
---
# Search Engine & Full-Text
## **Priority: P1 (OPERATIONAL)**
- **Pattern**: **CQRS (Command Query Responsibility Segregation)**.
- **Write**: To Primary Database (Postgres/MySQL). Source of Truth.
- **Read (Complex)**: To Search Engine (Elasticsearch, OpenSearch, MeiliSearch). Optimized for filtering, fuzzy search, and aggregation.
## Synchronization ( Hard Part)
- **Dual Write (Anti-Pattern)**: `await db.save(); await es.index();`.
- _Why_: Partial failures leave data inconsistent. Slows down HTTP response.
- **Event-Driven (Recommended)**:
1. Service writes to DB.
2. Service emits `EntityUpdated`.
3. Event Handler (Async) pushes to Queue (BullMQ).
4. Worker indexes document to Search Engine with retries.
- **CDC (Golden Standard)**: Change Data Capture (Debezium). Connects directly to DB transaction log. No app conceptual overhead, but higher ops complexity.
## Organization
- **Module**: Encapsulate client in `SearchModule`.
- **Abstraction**: Create generic `SearchService<T>` helpers.
- `indexDocument(id, body)`
- `search(query, filters)`
- **Mapping**: Use `class-transformer` to map Entities to "Search Documents". Keep docs flatter than relational entities.
## Testing
- **E2E**: not mock search engine in critical E2E flows.
- **Docker**: Spin up `elasticsearch:8` container in test harness to verify indexing works.
## Anti-Patterns
- **No dual writes to DB + ES**: Use event-driven or CDC pattern; dual writes risk partial failure inconsistency.
- **No Elasticsearch for structured queries**: Use DB indexes for filtering; ES for full-text and complex search.
- **No ES mocks in E2E search tests**: Spin up `elasticsearch:8` container to verify indexing behavior accurately.No comments yet. Be the first to comment!
Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.
SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.
Python backend development expertise for FastAPI, security patterns, database operations, Upstash integrations, and code quality. Use when: (1) Building REST APIs with FastAPI, (2) Implementing JWT/OAuth2 authentication, (3) Setting up SQLAlchemy/async databases, (4) Integrating Redis/Upstash caching, (5) Refactoring AI-generated Python code (deslopification), (6) Designing API patterns, or (7) Optimizing backend performance.
Drive the full internationalization journey for a project — detect the stack, recommend a library, set up the chosen library, wrap existing strings, and optionally connect a translation platform. Use when the user asks to add or configure i18n, internationalization, localization, multi-language support, or translations — including when they explicitly mention LinguiJS, Lingui, next-intl, "wrap strings", "find hardcoded text", "make my app translatable", or "set up translations". Triggers on g...
PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.