Official agent skill

Elasticsearch Index Design

by elastic in elastic/agent-skills

Design and review Elasticsearch index mappings for stated access patterns: correct field types, text+keyword multi-fields, docvalues tuning, mapping-explosion avoidance, and explicit shard settings.

OfficialApache-2.0Auto-check passedBackend & APIs

Install Elasticsearch Index Design

skills CLI
$ npx skills add elastic/agent-skills --skill elasticsearch-index-design -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install elastic/agent-skills elasticsearch-index-design --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/elastic/agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/elasticsearch/elasticsearch-index-design .claude/skills/elasticsearch-index-design && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
elasticsearch-index-design
GitHub stars
592
Token cost
~3.1k tokens
SKILL.md length
1,138 words
Files
4 (incl. references)
Skills in repo
26
Repo updated
First seen
Licence
Apache-2.0

At a glance

Design and review Elasticsearch index mappings for stated access patterns: correct field types, text+keyword multi-fields, docvalues tuning, mapping-explosion avoidance, and explicit shard settings.

  • Works in 4 steps: Gather access patterns per field. Before… → Choose field types from access patterns.… → Guard against mapping explosion and… → …
  • Creating a new index
  • SKILL.md covers Environment Configuration, Process, Review checklist and Examples, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Elasticsearch Index Design is an agent skill from elastic/agent-skills, published by the product's own GitHub organization. Design and review Elasticsearch index mappings for stated access patterns: correct field types, text+keyword multi-fields, docvalues tuning, mapping-explosion avoidance, and explicit shard settings. Use when creating a new index, reviewing a mapping for storage or query performance, fixing wrong field types, or when the user asks which type to use for search, filter, sort, or aggregation on a field.

Its SKILL.md is about 3.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/field-type-decisions.md`, `references/mapping-explosion.md` and `references/multi-field-patterns.md`). Compatibility notes: Elasticsearch 8.x or 9.x, self-managed, Elastic Cloud Hosted, or Elastic Cloud Serverless; explicit shard and replica settings apply to self-managed and…

It sits in Backend & APIs, covering Search implementation. It works with Elasticsearch. The repository describes itself as: Official Elastic Skills. The licence is Apache-2.0.

When your agent uses it

  • Creating a new index
  • Reviewing a mapping for storage
  • Query performance
  • Fixing wrong field types

Example prompts

  • “/elasticsearch-index-design”

Requirements

  • Compatibility (from SKILL.md): Elasticsearch 8.x or 9.x, self-managed, Elastic Cloud Hosted, or Elastic Cloud Serverless; explicit shard and replica settings apply to self-managed and Elastic Cloud Hosted only (managed internally on Serverless). Requires the `elastic` CLI ≥ 0.2 with `stack es` support.

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  1. Gather access patterns per field. Before choosing types, list how each field is used. For every field capture
  2. Choose field types from access patterns. Map each field to the minimal type set that satisfies its pattern. Read
  3. Guard against mapping explosion and storage bloat. On high-volume indices, type mistakes multiply cost. Read
  4. Apply design: create new index and reindex when types change. Elasticsearch cannot change an existing field's

What it can do on your machine

Read from SKILL.md and the folder at commit baa5111. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are json).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Elasticsearch 8.x or 9.x, self-managed, Elastic Cloud Hosted, or Elastic Cloud Serverless; explicit shard and replica settings apply to self-managed and Elastic Cloud Hosted only (managed internally on Serverless). Requires the `elastic` CLI ≥ 0.2 with `stack es` support.

    From compatibility in the SKILL.md frontmatter.

Context cost

Elasticsearch Index Design loads about 3.1k tokens when it runs, and up to ~6.4k if it reads all its reference files. Until then it costs about 108 tokens; SKILL.md has 1,138 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~108
When it runs · the whole SKILL.md, loaded when a task matches
~3.1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~6.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from elastic/agent-skills at commit baa5111, republished under its Apache-2.0 licence (© elastic). 1,138 words, ~3,110 tokens.

Download SKILL.mdSave it as .claude/skills/elasticsearch-index-design/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
elasticsearch-index-design
description
Design and review Elasticsearch index mappings for stated access patterns: correct field types, text+keyword multi-fields, doc_values tuning, mapping-explosion avoidance, and explicit shard settings. Use when creating a new index, reviewing a mapping for storage or query performance, fixing wrong field types, or when the user asks which type to use for search, filter, sort, or aggregation on a field.
compatibility
Elasticsearch 8.x or 9.x, self-managed, Elastic Cloud Hosted, or Elastic Cloud Serverless; explicit shard and replica settings apply to self-managed and Elastic Cloud Hosted only (managed internally on Serverless). Requires the `elastic` CLI ≥ 0.2 with `stack es` support.
metadata.author
elastic
metadata.version
0.1.0
metadata.universal
true

Elasticsearch Index Design

Design explicit index mappings from access patterns, review existing mappings for type and storage mistakes, and apply corrections through a new index plus reindex when field types must change.

<!-- begin-partial: preamble -->

Environment Configuration

This skill executes Elasticsearch operations through the elastic CLI. If the elastic CLI is not installed, tell the user what it is needed for. Do not guess credentials, call the HTTP API directly, or attempt other workarounds.

This skill references operations in HTTP-shorthand form (e.g., GET /, GET /_cat/indices, GET /{index}/_mapping, GET /{index}/_settings/index.mode, POST /_query). The Operations table at the end of this document maps each shorthand to the equivalent elastic CLI command — always use the CLI rather than calling the HTTP API directly.

<!-- end-partial: preamble -->

Process

  1. Gather access patterns per field. Before choosing types, list how each field is used. For every field capture:

    • Search — full-text match, phrase, relevance scoring?
    • Filter — exact term, terms set, prefix?
    • Aggregate — terms, cardinality, histogram, stats?
    • Sort — ascending/d descending in result sets?
    • Retrieve only — returned in _source but never queried?

    The decision: classify each field into one primary access pattern (search, exact, numeric metric, date, boolean, structured object, or retrieve-only). Missing access-pattern data is a blocker — ask the user rather than guessing. Call GET / to confirm connectivity; when reviewing an existing index, call GET /{index}/_mapping to ground the discussion in the current mapping.

  2. Choose field types from access patterns. Map each field to the minimal type set that satisfies its pattern. Read Field Type Decisions and Multi-Field Patterns before proposing mappings.

    Key judgments:

    PatternMapping
    Full-text search onlytext (no keyword sub-field)
    Filter / agg / sort onlykeyword (not text)
    Full-text search and sort or aggregationtext with fields.keyword multi-field
    Decimal price or metricdouble, float, or scaled_float — not text or integer
    Timestampdate
    True/false flagboolean
    Free-form key/value map with many distinct keysflattened — not dynamic object

    Multi-field rule: When a field must be searchable and sortable/aggregatable (e.g. product name), map it as text with a keyword sub-field — search on name, sort and aggregate on name.keyword. Mapping as only text or only keyword is wrong for that combined pattern.

    Explicit mapping rule: For new indices, always define mappings explicitly with PUT /{index}. Do not rely on dynamic mapping for production indices — the first document can lock in wrong types (strings as text, ambiguous numbers as keyword).

    Index settings: Set deliberate number_of_shards and number_of_replicas in the same PUT /{index} request when the deployment allows it (Self-Managed / Elastic Cloud Hosted). On Serverless, omit shard and replica counts (Elastic manages them); still supply explicit mappings. State chosen values or document that defaults apply.

    Example — products index optimized for search plus sort/agg on name:

    json
    {
      "settings": {
        "number_of_shards": 1,
        "number_of_replicas": 1
      },
      "mappings": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keyword": { "type": "keyword", "ignore_above": 256 }
            }
          },
          "price": { "type": "double" },
          "created": { "type": "date" },
          "in_stock": { "type": "boolean" }
        }
      }
    }

    Create with PUT /products passing the settings and mappings blocks. Verify with GET /products/_mapping.

  3. Guard against mapping explosion and storage bloat. On high-volume indices, type mistakes multiply cost. Read Mapping Explosion and Storage Bloat and apply these review checks:

    • Analyzed-but-not-searched fields — Fields used only for filter and aggregation (url, HTTP status_code, tags, IDs) must be keyword, not text. text wastes space; aggregations on text require fielddata or a .keyword sub-field that should not exist if the field is not searched.
    • message.keyword without ignore_above — A keyword sub-field on a large full-text body indexes the entire raw string as one term. Flag this anti-pattern; remove the sub-field when only full-text search is needed, or add ignore_above when a bounded exact-match sub-field is truly required.
    • Dynamic free-form objects — object with "dynamic": true on user-supplied key/value data with thousands of distinct keys causes mapping explosion. Recommend flattened (or strict dynamic / allowlist strategy).
    • doc_values: false — On fields retrieved in hits but never sorted, aggregated, or filtered (e.g. display-only session_id), set "doc_values": false on keyword to save disk at scale.
    • scaled_float — For metrics with bounded precision (e.g. response_time_ms), prefer scaled_float with an appropriate scaling_factor over plain float/double when storage dominates.

    Prefer "dynamic": "strict" on the root mapping unless unknown fields are an explicit requirement.

  4. Apply design: create new index and reindex when types change. Elasticsearch cannot change an existing field's type in place. When review finds wrong types (text→keyword, object→flattened, float→scaled_float, doc_values changes on existing fields), state clearly that fixes require a new index and reindex — not a mapping update on the live index.

    Workflow for correcting an existing high-volume index such as events:

    1. Design the corrected mapping on a new index name (e.g. events-v2) incorporating all fixes from steps 2–3.
    2. Create the destination with PUT /events-v2 and the full corrected mappings (and settings where applicable).
    3. Copy documents with POST /_reindex — for large indices use wait_for_completion=false and track the task. Source: { "index": "events" }, destination: { "index": "events-v2" }.
    4. Verify with GET /events-v2/_count (compare to source count) and GET /events-v2/_mapping (confirm types).
    5. Cut over reads and writes (index alias swap or application config) after validation.

    Example corrected excerpt for the events review pattern:

    json
    {
      "mappings": {
        "properties": {
          "@timestamp": { "type": "date" },
          "event_id": { "type": "keyword" },
          "session_id": { "type": "keyword", "doc_values": false },
          "url": { "type": "keyword" },
          "status_code": { "type": "keyword" },
          "response_time_ms": { "type": "scaled_float", "scaling_factor": 100 },
          "tags": { "type": "keyword" },
          "message": { "type": "text" },
          "labels": { "type": "flattened" }
        }
      }
    }

    Do not attempt in-place mapping fixes for these type changes — they are rejected or leave data inconsistent. For greenfield indices, a single PUT /{index} before first ingest avoids reindex entirely.

Show full SKILL.md (308 more words)Show less

Review checklist

When the user supplies a mapping JSON and usage notes, walk this checklist in order:

  1. Match each field's type to its stated access pattern (see step 2).
  2. Flag text on filter/agg-only fields; flag missing multi-fields where search and sort/agg share one logical field.
  3. Flag message.keyword (or similar) without ignore_above on large analyzed text.
  4. Flag dynamic object on high-cardinality free-form maps; recommend flattened.
  5. Propose retrieve-only and numeric storage optimizations (doc_values: false, scaled_float).
  6. State that type changes require a new index and POST /_reindex, then show the corrected mapping and reindex plan.

Examples

"Users search product names and also sort and aggregate on them" — one logical field, two access patterns, so use a text field with a keyword multi-field:

json
{
  "mappings": {
    "properties": {
      "product_name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }
    }
  }
}

"A status field is only ever filtered and aggregated, never full-text searched" — use keyword, not text:

json
{ "mappings": { "properties": { "status": { "type": "keyword" } } } }

"Free-form labels object with unbounded keys" — avoid mapping explosion with flattened:

json
{ "mappings": { "properties": { "labels": { "type": "flattened" } } } }

Guidelines

  • Minimal mapping — Map only what access patterns require; every sub-field and analyzed form adds indexed data.
  • Never guess access patterns — Wrong type choice is expensive to fix at scale.
  • Verify after create — Always confirm with GET /{index}/_mapping; use GET /{index}/_count after reindex.
  • Cross-skill boundary — Copying documents between indices is POST /_reindex (see the reindex skill for slicing, throttling, and task tracking). Loading files into a new index is bulk ingest, not index design.

Reference material

Operations

HTTP API (shorthand)elastic CLI command
GET /elastic es info
GET /{index}/_mappingelastic es indices get-mapping --index '<index>'
PUT /{index}elastic es indices create --index '<index>' --mappings '<json>' --settings '<json>'
POST /_reindexelastic es reindex --source '<json>' --dest '<json>'
POST /_reindex?wait_for_completion=falseelastic es reindex --wait-for-completion false --source '<json>' --dest '<json>'
GET /{index}/_countelastic es count --index '<index>'

© elastic, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in skills/elasticsearch/elasticsearch-index-design of elastic/agent-skills.

  • SKILL.md
  • references/field-type-decisions.md
  • references/mapping-explosion.md
  • references/multi-field-patterns.md

Open the folder on GitHubat commit baa5111

Compare with similar skills

Elasticsearch Index Design next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Elasticsearch Index Design compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Elasticsearch Index Design this skillelastic/agent-skills592—~3.1kAutomated safety check: PassApache-2.0
Product Full-Text Searchlobehub/lobehub83k—~4.1kAutomated safety check: PassCustom licence
Foundatio Repositoriesexceptionless/Exceptionless2.5k—~1.9kAutomated safety check: PassApache-2.0
Elasticsearch Authnaspectrr/deer405—~1.2kAutomated safety check: NotesMIT
Elasticsearch Authzaspectrr/deer405—~1.8kAutomated safety check: PassMIT
Elasticsearch File Ingestaspectrr/deer405—~684Automated safety check: PassMIT

Similar skills

  • Guides work on LobeHub's own product search: the shared search repository, provider choice, Elasticsearch mappings, change syncing and reindexing.

    83k GitHub stars~4.1k tokensUpdated today
    Backend & APIsAuto-check passed
  • Foundatio Repositories

    exceptionless/Exceptionless

    Query, aggregate, patch, or paginate Exceptionless data through its Elasticsearch repository abstractions.

    2.5k GitHub stars~1.9k tokensUpdated 3 days ago
    Backend & APIsAuto-check passed
  • Elasticsearch Authn

    aspectrr/deer

    Authenticate to Elasticsearch using native, file-based, LDAP/AD, SAML, OIDC, Kerberos, JWT, or certificate realms.

    405 GitHub stars~1.2k tokensUpdated 5 mo ago
    Backend & APIsAuto-check: notes
  • Elasticsearch Authz

    aspectrr/deer

    Manage Elasticsearch RBAC: native users, roles, role mappings, document- and field-level security.

    405 GitHub stars~1.8k tokensUpdated 5 mo ago
    Backend & APIsAuto-check passed
  • Ingest and transform data files (CSV/JSON/Parquet/Arrow IPC) into Elasticsearch with stream processing and custom transforms.

    405 GitHub stars~684 tokensUpdated 5 mo ago
    Backend & APIsAuto-check passed
  • Diagnose and resolve Elasticsearch security errors: 401/403 failures, TLS problems, expired API keys, role mapping mismatches, and Kibana login issues.

    405 GitHub stars~4.9k tokensUpdated 5 mo ago
    Backend & APIsAuto-check passed

More from elastic/agent-skills

All 26 skills in this repo
  • Security Alert Triage

    elastic/agent-skills

    Official

    Triage Elastic Security alerts — gather context, classify threats, create cases, and acknowledge.

    592 GitHub starsUsed in 1 repo~3.5k tokens
    Auto-check: notes
  • Security Case Management

    elastic/agent-skills

    Official

    Create, search, update, and manage SOC cases via the Kibana Cases API.

    592 GitHub starsUsed in 1 repo~2.6k tokens
    Auto-check: notes
  • Official

    Create, tune, and manage Elastic Security detection rules (SIEM and Endpoint).

    592 GitHub starsUsed in 1 repo~3.9k tokens
    Auto-check: notes
  • Kibana Dashboards

    elastic/agent-skills

    Official

    Create and manage Kibana Dashboards and Lens visualizations.

    592 GitHub starsUsed in 1 repo~3.7k tokens
    Auto-check passed
  • Official

    Generate sample security events, attack scenarios, and synthetic alerts for Elastic Security.

    592 GitHub stars~2k tokensUpdated 3 days ago
    Auto-check passed
  • Cloud Onboarding

    elastic/agent-skills

    Official

    Onboard an Elastic Cloud organization: configure the elastic CLI's Cloud context and API key, establish a default region, then invite users, assign predefined or custom Serverless project roles, and…

    592 GitHub stars~4.1k tokensUpdated 3 days ago
    Auto-check passed

Works with

Categories

Questions about Elasticsearch Index Design

What does Elasticsearch Index Design do?

Design and review Elasticsearch index mappings for stated access patterns: correct field types, text+keyword multi-fields, docvalues tuning, mapping-explosion avoidance, and explicit shard settings. Elasticsearch Index Design is an agent skill from elastic/agent-skills, published by the product's own GitHub organization. Design and review Elasticsearch index mappings for stated access patterns: correct field types, text+keyword multi-fields, docvalues tuning, mapping-explosion avoidance, and explicit shard settings.

When should I use Elasticsearch Index Design?

Elasticsearch Index Design fits situations like: creating a new index; reviewing a mapping for storage; query performance; fixing wrong field types.

How do I install Elasticsearch Index Design in Claude Code?

Run `npx skills add elastic/agent-skills --skill elasticsearch-index-design -a claude-code`. Or copy the skill folder (skills/elasticsearch/elasticsearch-index-design in elastic/agent-skills) into .claude/skills/elasticsearch-index-design in your project. Claude Code loads it when a task matches its description.

How do I install Elasticsearch Index Design in Codex?

Run `npx skills add elastic/agent-skills --skill elasticsearch-index-design -a codex`. Or copy the skill folder (skills/elasticsearch/elasticsearch-index-design in elastic/agent-skills) into .agents/skills/elasticsearch-index-design in your project. Codex loads it when a task matches its description.

Can I use Elasticsearch Index Design in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add elastic/agent-skills --skill elasticsearch-index-design -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/elasticsearch-index-design, .gemini/skills/elasticsearch-index-design, .github/skills/elasticsearch-index-design and .opencode/skills/elasticsearch-index-design in your project.

What does Elasticsearch Index Design need to run?

SKILL.md names no scripts, command-line tools or credentials: Elasticsearch Index Design is instructions for the agent only. Compatibility (from SKILL.md): Elasticsearch 8.x or 9.x, self-managed, Elastic Cloud Hosted, or Elastic Cloud Serverless; explicit shard and replica settings apply to self-managed and Elastic Cloud Hosted only (managed internally on Serverless). Requires the `elastic` CLI ≥ 0.2 with `stack es` support..

Does Elasticsearch Index Design access the network?

SKILL.md names 1 domain. As links in the text: github.com. This is read from the text; nothing was executed.

Is Elasticsearch Index Design safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Elasticsearch Index Design use?

Elasticsearch Index Design is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Elasticsearch Index Design use?

About 3.1k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 3.3k tokens, read only when the agent opens those files.

What are the alternatives to Elasticsearch Index Design?

Skills that share tags, products or a category with Elasticsearch Index Design: Product Full-Text Search (lobehub/lobehub, 83k stars), Foundatio Repositories (exceptionless/Exceptionless, 2.5k stars), Elasticsearch Authn (aspectrr/deer, 405 stars) and Elasticsearch Authz (aspectrr/deer, 405 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Elasticsearch Index Design?

elastic (a GitHub organization, an official publisher) maintains it in elastic/agent-skills, which has 592 GitHub stars. The repository holds 26 skills in this directory. The repository was last updated on October 7, 2026.

Source: elastic/agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.