Chuyển đến nội dung
Skillpedia
Cơ sở dữ liệu18k · #10675

elasticsearch

Skill này làm gì

Skill này hướng dẫn làm việc với Elasticsearch, gồm cú pháp truy vấn, mapping trường, aggregation và sức khỏe cluster. Nó dành cho người xây dựng tính năng tìm kiếm hoặc phân tích log và dữ liệu chuỗi thời gian.

Khi nào nên dùng

  • ✓Khi bạn cần viết truy vấn tìm kiếm hoặc lọc kết quả trong Elasticsearch.
  • ✓Khi bạn thiết kế mapping index trước khi nạp dữ liệu vào Elasticsearch.
  • ✓Khi trạng thái sức khỏe cluster là vàng hoặc đỏ và cần điều tra.

Liên kết skill

https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/elasticsearch/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/RightNow-AI/openfang/blob/main/crates/openfang-skills/bundled/elasticsearch/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Viết một truy vấn Elasticsearch tìm log lỗi trong 24 giờ qua và đếm chúng theo tên dịch vụ.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill khuyên dùng mapping rõ ràng, cấu trúc truy vấn rõ ràng và aggregation, cùng các bước kiểm tra sức khỏe cluster và kích thước shard.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Elasticsearch Expert

A search and analytics specialist with deep expertise in Elasticsearch cluster architecture, query DSL, mapping design, and performance optimization. This skill provides production-grade guidance for building search experiences, log analytics pipelines, and time-series data platforms using the Elastic stack.

Key Principles

  • Design mappings explicitly before indexing data; relying on dynamic mapping leads to field type conflicts and bloated indices
  • Understand the difference between keyword fields (exact match, aggregations, sorting) and text fields (full-text search with analyzers)
  • Use index aliases for zero-downtime reindexing, canary deployments, and time-based index rotation
  • Size shards between 10-50 GB for optimal performance; too many small shards waste overhead, too few large shards limit parallelism
  • Monitor cluster health (green/yellow/red) continuously and investigate yellow status immediately, as it indicates unassigned replica shards

Techniques

  • Construct bool queries with must (scored AND), filter (unscored AND), should (OR with minimum_should_match), and must_not (exclusion) clauses
  • Use match queries for full-text search with analyzer-aware tokenization, and term queries for exact keyword lookups without analysis
  • Build aggregations: terms for top-N cardinality, date_histogram for time bucketing, nested for sub-document analysis, and pipeline aggs like cumulative_sum
  • Apply Index Lifecycle Management (ILM) policies with hot/warm/cold/delete phases to automate rollover and data retention
  • Reindex with POST _reindex using source/dest, applying scripts for field transformations during migration
  • Check cluster allocation with GET _cluster/allocation/explain to diagnose why shards remain unassigned
  • Tune search performance with the search profiler API, request caching, and pre-warming for frequently used queries

Common Patterns

  • Search-as-you-type: Use the search_as_you_type field type or edge_ngram tokenizer with a match_phrase_prefix query for autocomplete experiences
  • Parent-Child Relationships: Use join field types for one-to-many relationships where child documents update independently, avoiding costly nested reindexing
  • Cross-cluster Search: Configure remote clusters and use cluster:index syntax to query across multiple Elasticsearch deployments transparently
  • Snapshot and Restore: Register a snapshot repository (S3, GCS, or filesystem) and schedule regular snapshots for disaster recovery with SLM policies

Pitfalls to Avoid

  • Do not use wildcard queries on text fields with leading wildcards, as they bypass the inverted index and cause full field scans
  • Do not index large documents (over 100 MB) without splitting them; they cause memory pressure during indexing and merging
  • Do not set number_of_replicas to 0 in production; replicas provide both search throughput and data redundancy
  • Do not update mappings on existing indices for incompatible type changes; create a new index with the correct mapping and reindex the data
Câu hỏi thường gặp

Vì sao tự định nghĩa mapping?

Dựa vào mapping tự động có thể gây xung đột kiểu trường và index phình to, nên skill khuyên dùng mapping rõ ràng.

Trạng thái cluster vàng nghĩa là gì?

Skill nói vàng thường nghĩa là các replica shard chưa được gán, nên cần điều tra ngay.

Trường keyword và text khác nhau thế nào?

Trường keyword khớp giá trị chính xác và hỗ trợ sắp xếp, còn trường text được phân tích để tìm kiếm toàn văn.

Chi tiết

Mô tả gốc của tác giả

Elasticsearch expert for queries, mappings, aggregations, index management, and cluster operations

repo: RightNow-AI/openfang

Độ phổ biến

Sao GitHub
18k
Vị trí xếp hạng
#10675
Giấy phép
Apache-2.0
Cập nhật
2/7/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự