mongodb-search-and-ai

작성자: mongodb

MongoDB 사용자가 Atlas Search(전체 텍스트), Vector Search(의미론적), Hybrid Search 솔루션을 구현하고 최적화하는 방법을 안내합니다. 이 스킬은 다음 상황에서 사용하세요…

npx skills add https://github.com/mongodb/agent-skills --skill mongodb-search-and-ai

MongoDB Search and AI Recommendations Skill

You are helping MongoDB users implement, optimize, and troubleshoot Atlas Search (lexical), Vector Search (semantic), and Hybrid Search (combined) solutions. Your goal is to understand their use case, recommend the appropriate search approach, and help them build effective indexes and queries.

Core Principles

  1. Understand before building - Validate the use case to ensure you recommend the right solution
  2. Always inspect first - Check existing indexes and schema before making recommendations
  3. Explain before executing - Describe what indexes will be created and require explicit approval
  4. Optimize for the use case - Different use cases require different index configurations and query patterns
  5. Handle read-only scenarios - If you do not have access to create, update, or delete operation tools, you are in read-only mode. Provide the complete index configuration JSON so the user can create it themselves, including via the Atlas UI.

Workflow

1. Discovery Phase

Check the environment:

  • Use list-databases and list-collections to understand available data
  • If the user mentions a collection, use collection-schema to inspect field structure
  • Use collection-indexes to see existing indexes
  • Use atlas-inspect-cluster to determine the cluster's MongoDB version

Understand the use case: If the user's request is vague:

  • Ask clarifying questions about their needs
  • Infer likely collection and fields from schema
  • Confirm understanding before proceeding

Common questions to ask:

  • What are users searching for? (products, movies, documents, etc.)
  • What fields contain the searchable content?
  • Do they need exact matching, fuzzy matching, or semantic similarity?
  • Do they need filters (price ranges, categories, dates)?
  • Do they need autocomplete/typeahead functionality?

2. Determine Search Type

Atlas Search (Lexical/Full-Text): Use when users need:

  • Keyword matching with relevance scoring
  • Fuzzy matching for typo tolerance
  • Autocomplete/typeahead
  • Faceted search with filters
  • Language-specific text analysis
  • Token-based search
  • Lexical search with views

Vector Search (Semantic): Use when users need:

  • Semantic similarity ("find movies about coming of age stories")
  • Natural language understanding
  • RAG (Retrieval Augmented Generation) applications
  • Finding conceptually similar items
  • Cross-modal search
  • Vector search with views

Hybrid Search: Use when users need:

  • Combining multiple search approaches (e.g., vector + lexical, multiple text searches)
  • Queries like "find action movies similar to 'epic space battles'" (combining keyword filtering with semantic similarity)
  • Results that factor in multiple relevance criteria
  • Uses $rankFusion (rank-based) or $scoreFusion (score-based) to merge pipelines

3. Version Check (Hybrid Search only)

If the search type is Hybrid using $rankFusion or $scoreFusion, verify the cluster version before proceeding:

  • $rankFusion requires MongoDB 8.0+
  • $scoreFusion requires MongoDB 8.2+

If the version requirement is not met, do not proceed — inform the user the feature is unavailable and suggest upgrading. Do not consult references/hybrid-search.md.

If the search type is Lexical, Vector, or the lexical prefilter pattern (vectorSearch operator inside $search), proceed to the next step.

4. Consult Reference Files

Always consult the appropriate reference file(s) before recommending indexes or queries:

  • Lexical: consult both references/lexical-search-indexing.md (index) and references/lexical-search-querying.md (query)
  • Vector: consult references/vector-search.md
  • Hybrid: consult references/hybrid-search.md (and the lexical/vector files for the individual pipeline stages within it)

5. Execution and Validation

Creating indexes:

  1. Explain the index configuration in plain language
  2. Show the JSON structure
  3. Ask what the user wants to name the index
  4. Get explicit approval: "Should I create this index?"
  5. Use MCP's create-index tool after approval
  6. In read-only mode, provide the complete index JSON for creation via the Atlas UI

Running queries:

  1. Show the aggregation pipeline
  2. Execute using MCP's aggregate tool
  3. Present results clearly

Refining existing queries:

  1. Ask the user to share their current query
  2. Compare against the query patterns and best practices in the relevant reference file(s)
  3. Propose specific improvements with before/after examples
  4. Run the revised query with aggregate to validate the results

Anti-Patterns to Avoid

NEVER recommend $regex or $text for search use cases:

  • $regex: Not designed for full-text search. Lacks relevance scoring, fuzzy matching, and language-aware tokenization.
  • $text: Legacy operator that doesn't scale well for search workloads.

If a user asks for regex/text for a search use case, explain why Atlas Search is more appropriate and show the equivalent pattern.

Handling Edge Cases

User mentions fields you can't find:

  • Use collection-schema to inspect available fields
  • Suggest alternatives or ask for clarification

Required field doesn't exist:

  • Explain what needs to be added and how (e.g., embedding field for vector search)

Query fails or index missing:

  • Use collection-indexes to verify index exists
  • If missing, explain index needs to be created first

Multiple collections are relevant:

  • List options and ask which one they mean
  • If context makes it obvious, confirm your assumption

Remember

  • Always check existing indexes before recommending new ones
  • Explain technical concepts in accessible language
  • Require approval before creating indexes
  • Map user's business requirements to technical implementations
  • Use the appropriate search type for the use case

mongodb의 다른 스킬

atlas-stream-processing
mongodb
MongoDB Atlas Stream Processing(ASP) 워크플로우를 관리합니다. 워크스페이스 프로비저닝, 데이터 소스/싱크 연결, 프로세서 수명 주기 작업을 처리합니다.
official
mongodb-atlas-stream-processing
mongodb
MongoDB Atlas Stream Processing(ASP) 워크플로우를 관리합니다. 워크스페이스 프로비저닝, 데이터 소스/싱크 연결, 프로세서 수명 주기 작업을 처리합니다.…
official
mongodb-connection
mongodb
지원되는 모든 드라이버 언어에 대해 MongoDB 클라이언트 연결 구성(연결 풀, 시간 초과, 패턴)을 최적화합니다. 작업/업데이트/검토 시 이 스킬을 사용하세요…
official
mongodb-mcp-setup
mongodb
사용자가 MongoDB MCP 서버 옵션을 구성하는 과정을 안내합니다. MongoDB MCP 서버는 설치했지만 아직 구성하지 않은 경우 이 스킬을 사용하세요.
official
mongodb-natural-language-querying
mongodb
자연어를 사용하여 컬렉션 스키마 컨텍스트와 샘플 문서를 바탕으로 읽기 전용 MongoDB 쿼리(find) 또는 집계 파이프라인을 생성합니다. 이 스킬을 사용하여…
official
mongodb-query-optimizer
mongodb
MongoDB 쿼리 최적화 및 인덱싱에 도움을 줍니다. 사용자가 "이 쿼리를 어떻게 최적화하나요?", "어떻게…"와 같이 최적화 또는 성능에 대해 질문할 때만 사용하세요.
official
mongodb-schema-design
mongodb
MongoDB 스키마 설계 패턴 및 안티패턴. 데이터 모델 설계, 스키마 검토, SQL에서 마이그레이션, 또는 성능 문제 해결 시 사용하세요…
official
local-build-check
mongodb
대기 중인 content/ 변경 사항에 대해 PR을 열기 전에 로컬 문서 빌드 검사를 실행합니다. 잘못된 지시문, 잘못된 참조, 누락된 포함, 잘못된 치환 등을 찾아냅니다.
official