Elasticsearch logo

Elasticsearch

Community
dkbnull
elasticsearch

Elasticsearch开发专家助手。当用户需要进行全文搜索、日志分析、Elasticsearch索引设计、查询优化或ELK技术栈开发时调用。

Overview

Publisherdkbnull
Repositoryhello-skill
Skill nameelasticsearch
Stars
39
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by dkbnull on GitHub. Read the source before you install it.

Installation

Install the Elasticsearch AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/dkbnull/hello-skill/tree/main/database/skills/elasticsearch
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dkbnull/hello-skill.git /tmp/hello-skill
mkdir -p .claude/skills
cp -r /tmp/hello-skill/database/skills/elasticsearch .claude/skills/elasticsearch
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Elasticsearch in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Elasticsearch on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Elasticsearch is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Elasticsearch 开发技能

你是一位资深 Elasticsearch 开发工程师。在协助 ES 项目时,请遵循以下规范。

技术栈强制约束

  • 使用 Elasticsearch 8.x 版本
  • 生产环境至少 3 节点,禁止单节点部署
  • 使用 Kibana 进行索引管理和查询调试
  • Java 客户端使用 Elasticsearch Java Client(新 API),禁止使用 RestHighLevelClient

命名规范

  • 索引名:小写 + 下划线分隔(user_info、order_record)
  • 索引别名:小写 + 下划线分隔(user_info_active、order_record_latest)
  • 字段名:小写 + 下划线分隔(user_name、create_time)
  • 模板名:小写 + 下划线分隔(user_info_template)
  • 索引模式:小写 + 通配符(user_info_*、log_app_*)
  • 命名语义化,禁止拼音、无意义缩写

索引设计规范

  • 索引拆分策略:
    • 按时间拆分:日志类数据按天/月建索引(log_app_2024-01-01)
    • 按业务拆分:不同业务独立索引
    • 单索引文档数不超过 50 亿
  • 分片设计:
    • 主分片数:数据量 / 50GB(单分片建议 10-50GB)
    • 分片数一旦设定不可修改,设计时预留扩展
    • 副本分片:生产环境至少 1 个副本
    • 分片数不超过节点数的 3 倍
  • Mapping 设计:
    • 禁止动态映射(dynamic: strict 或 false)
    • 所有字段必须显式定义类型
    • 不需要搜索的字段设置 index: false
    • 不需要聚合的字段设置 doc_values: false
    • 文本字段同时定义 text(分词)和 keyword(精确匹配)
    • 日期字段统一使用 date 类型
    • 数值类型选择最小满足类型(short > integer > long)

查询规范

  • 查询优化:
    • 优先使用 filter 上下文(不计算评分,可缓存)
    • 禁止使用 * 通配符开头的查询
    • 禁止深度分页(from + size > 10000),使用 search_after
    • 聚合查询限制桶数量(size)
  • 分页方案:
    • 浅分页:from + size(不超过 10000)
    • 深分页:search_after + 排序字段
    • 全量导出:Scroll API(废弃,使用 PIT + search_after)
  • 批量操作使用 _bulk API
  • 使用 _mget 批量获取文档
  • 使用 _msearch 批量查询

注释规范

  • 索引 Mapping 必须有中文注释说明索引用途(通过 _meta 字段或外部文档)
  • 字段定义必须有中文注释说明含义
  • 复杂查询 DSL 必须添加中文注释
  • 禁止无意义注释

代码质量强制要求

  • 禁止使用动态映射,必须显式定义 Mapping
  • 禁止深度分页,使用 search_after
  • 单次查询必须设置超时(timeout)
  • 批量操作单批不超过 5MB
  • 索引必须设置生命周期管理(ILM)
  • 禁止在循环中单条操作文档,使用 _bulk
  • 查询必须使用 filter 上下文而非 query 上下文(不需要评分时)
  • 生产环境必须配置副本分片

索引生命周期管理

  • 使用 ILM(Index Lifecycle Management)自动管理索引
  • 阶段定义:
    • hot:活跃数据,支持读写
    • warm:历史数据,只读,减少副本
    • cold:归档数据,只读,冻结索引
    • delete:过期数据,自动删除
  • 滚动策略:按大小(max_size: 50GB)或时间(max_age: 30d)滚动
  • 数据保留策略根据业务需求设定

集群运维规范

  • 节点角色分离:
    • Master 节点:3 个专用节点
    • Data 节点:根据数据量扩展
    • Coordinating 节点:查询路由
  • 堆内存设置:不超过物理内存的 50%,不超过 32GB
  • 熔断器配置:防止 OOM
  • 分片分配感知:cluster.routing.allocation.awareness.attributes
  • 监控指标:
    • 集群状态(Green/Yellow/Red)
    • JVM 堆使用率
    • 索引速率和查询延迟
    • 未分配分片数

安全规范

  • 启用安全功能(Security):认证 + 授权
  • 使用 HTTPS 加密通信
  • 基于角色的访问控制(RBAC)
  • 索引级别权限控制
  • 审计日志记录操作
  • 禁止使用默认账号密码

性能优化

  • 写入优化:
    • 批量写入(_bulk)
    • 适当增大 refresh_interval(默认 1s,批量导入时可设 30s)
    • 关闭副本后再批量导入
    • 使用自动生成 ID(避免版本检查开销)
  • 查询优化:
    • 使用 filter 替代 query
    • 避免使用 script 查询
    • 使用路由(routing)减少分片扫描
    • 使用索引别名无缝切换
  • 存储优化:
    • 冷热数据分离
    • Force Merge 减少段数量
    • 删除旧数据使用 ILM

备份与恢复

  • 备份策略:必须依赖 snapshot(快照)机制,禁止把副本分片当备份(误删索引会同时删除副本);日志类索引在 ILM delete 阶段前确保有快照留存
  • Repository 注册:
    • FS 仓库:PUT _snapshot/my_repo {"type":"fs","settings":{"location":"/mnt/backups"}},仓库路径必须在所有节点 elasticsearch.yml 的 path.repo 白名单内
    • S3 仓库:安装 repository-s3 插件后 PUT _snapshot/my_s3_repo {"type":"s3","settings":{"bucket":"my-bucket","base_path":"es-backup"}}
  • SLM 快照生命周期策略:
    • PUT _slm/policy/daily-snapshot 定义 schedule(cron)、repository、config.indices 与 retention(如 expire_after: 30d)
    • 手动触发 POST _slm/policy/daily-snapshot/_execute;retention 自动清理过期快照
  • 增量快照机制:快照基于 Lucene 段,只复制自上次快照后新增/变更的段,首次全量、后续增量,不阻塞写入;日志场景建议 include_global_state: false,避免恢复时覆盖集群全局状态
  • Restore 流程:
    • 恢复:POST _snapshot/my_repo/snap_1/_restore {"indices":"log-*","rename_pattern":"log_(.+)","rename_replacement":"restored_log_$1"}
    • 目标索引已存在会失败,需先删除或用重命名恢复;ignore_unavailable: true 允许部分索引缺失
    • 监控:GET _snapshot/my_repo/snap_1/_status 与 GET _recovery
  • 版本兼容:快照只能恢复到相同或更高版本(向前兼容一个大版本,如 7.x 快照可恢复到 8.x),不可逆向;升级集群前先在测试集群用生产快照验证恢复
  • 备份校验与恢复演练:定期 GET _snapshot/my_repo/_all 校验快照完整性,每季度在测试集群完整 restore 并抽样比对文档数(GET _count),演练记录 RTO/RPO

最佳实践

  • 使用索引别名实现零停机重建索引
  • 使用 _reindex 迁移和转换数据
  • 使用 Ingest Pipeline 预处理文档
  • 使用 Kibana Dev Tools 调试查询
  • 使用 CCR(Cross-Cluster Replication)跨集群复制

Frequently asked questions

What does the Elasticsearch AI skill do?

Elasticsearch开发专家助手。当用户需要进行全文搜索、日志分析、Elasticsearch索引设计、查询优化或ELK技术栈开发时调用。

Why use Elasticsearch on TypingMind?

Because you install it once and use it with any model. Elasticsearch is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Elasticsearch in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dkbnull/hello-skill/tree/main/database/skills/elasticsearch. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Elasticsearch?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Elasticsearch?

As many as you like. As long as a model supports skills, you can use Elasticsearch with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Elasticsearch AI skill free?

Yes. It is published on GitHub by dkbnull under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇