
elasticsearch-reindex
Guide Elasticsearch reindex for performance: local and remote, slicing, throttling, task API. Use when copying or migrating indices, changing mappings, or transforming during reindex.
- Installs
- 1.1K
- Last 24h
- +20
- Trending rank
- #5898
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/elastic/agent-skills --skill elasticsearch-reindex- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads elasticsearch-reindex automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Elasticsearch Reindex
Copy documents from source indices or data streams to a destination using POST /_reindex. An expert reindex workflow
prepares the destination explicitly, chooses local versus remote execution, filters at the source when only a subset is
needed, runs long copies asynchronously, tracks the task to completion, and verifies the destination document count
before reporting results.
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.
Process
-
Confirm connectivity and deployment type. Call
GET /. Readbuild_flavorandversion.numberto know whether shard, replica, and cluster-settings APIs are available (Serverless manages shards/replicas internally and blocks most_cluster/*APIs). The decision: continue only when the cluster is reachable. If the call fails, stop — do not guess endpoints or credentials. -
Decide local versus remote reindex. Compare where the source and destination live.
- Same cluster — use local reindex:
source.indexanddest.indexonly. Do not addsource.remotewhen both indices are on the cluster you are connected to. - Different cluster — use reindex from remote: add
source.remotewith the remote cluster URL and credentials. Remote reindex does not support slicing; compensate with query-based partitioning (date ranges, term filters) across parallel requests. Confirm the remote host is allowlisted on Self-Managed / ECH (reindex.remote.whitelistin cluster config); Serverless manages allowlisting internally (ECH remotes only, Tech Preview).
Data needed: source index name(s), destination index name, and whether they share a cluster.
- Same cluster — use local reindex:
-
Inspect the source — never guess field names or counts. Call
GET /{source}/_mappingto ground field names and types. CallGET /{source}/_count(orGET /_cat/count/{source}?h=counton Self-Managed / ECH) to learn how many documents exist.The decision: full copy versus filtered subset.
- Full copy — omit
source.query(match-all behavior). - Filtered subset — add
source.querywith Query DSL. For time ranges, use arangefilter on the timestamp field (commonly@timestamp), e.g."gte": "2025-01-01", "lt": "2025-02-01"for January 2025. Do not run a full-index copy when the user asked for a date range or other filter.
Data needed: the user's filter criteria and the mapping-confirmed field names.
- Full copy — omit
-
Prepare the destination index before copying.
_reindexdoes not copy mappings, shard counts, or analyzers. Create the destination with explicit settings and mappings derived from the source mapping viaPUT /{dest}.- On Self-Managed / ECH: set
number_of_replicas: 0andrefresh_interval: "-1"on the destination during the copy for write throughput; restore production values afterward withPUT /{dest}/_settings. - On Serverless: omit
number_of_shardsandnumber_of_replicas(managed by Elastic); you may setrefresh_interval: "-1"during the copy. - For data stream destinations: ensure an index template with
data_stream: {}exists, create the data stream, and setdest.op_typeto"create"(append-only).
The decision: create/prepare the target rather than relying on auto-creation with dynamic mapping. Wrong or missing mappings cause partial failures or silent type coercion.
Data needed: destination name, corrected or compatible mappings, and deployment-specific settings constraints.
- On Self-Managed / ECH: set
-
Build and submit the reindex request. Call
POST /_reindex?wait_for_completion=falsefor any copy that may take more than a few seconds or when the user says the index is large — the response returns a task id immediately instead of blocking.Request body essentials:
source.index— source index or data stream (correct name, not reversed withdest.index).dest.index— prepared destination from step 4.source.query— include only when step 3 chose a filtered subset.conflicts: "proceed"— when retrying a partially complete reindex.- Optional tuning:
source.size(batch size),requests_per_second(throttle),slices=autoon local reindex only (parallelize per primary shard — never for remote),scroll(increase keep-alive on slow clusters),max_docs(test runs),script(transform),dest.pipeline(ingest enrichment).
Example filtered subset (January 2025 only):
{ "source": { "index": "eval-reindex-src", "query": { "range": { "@timestamp": { "gte": "2025-01-01", "lt": "2025-02-01" } } } }, "dest": { "index": "eval-reindex-jan" } }Do not reach for
_split,_shrink, or snapshot/restore when the task is a filtered subset copy or a straight document migration — those APIs solve different problems. -
Track the task to completion. Store the task id from the reindex response. Poll
GET /_tasks/{task_id}untilcompletedistrue. Readstatus.total,status.created, andresponse.failures. On Self-Managed / ECH you may also list active reindex tasks withGET /_tasks?actions=*reindex&detailed; on Serverless, query by task id only (list/cancel are not available). Adjust throttling mid-flight withPOST /_reindex/{task_id}/_rethrottle?requests_per_second=Nwithout canceling. -
Verify and report the destination count. Call
GET /{dest}/_count(works on all deployment types). On Self-Managed / ECH you may also useGET /_cat/count/{dest}?h=count. Compare source filter expectations to the destination count. Report the exact count from the destination — do not estimate or guess.After a successful full copy, restore production settings on the destination with
PUT /{dest}/_settings(replicas and refresh interval on Self-Managed / ECH; refresh interval only on Serverless).
Deployment constraints
| Capability | Self-Managed / ECH | Serverless |
|---|---|---|
| Local reindex | Full support | Full support |
| Reindex from remote | Full support | Tech Preview — ECH remotes only |
number_of_shards/replicas | User-configurable | Managed — omit on index creation |
slices=auto (local only) | Supported | Supported for local reindex |
GET /_cat/count/{index} | Supported | Not available — use GET /{index}/_count |
GET /_tasks (list/cancel) | Full | Get by task id only |
PUT /_cluster/settings | Supported | Blocked |
_split / _shrink | Supported | Not available |
Consider alternatives first
- Runtime fields — fix field-type mismatches or add computed fields without reindexing when stored values need not change.
- Aliases — redirect queries transparently; combine with reindex for zero-downtime mapping changes.
- Snapshot and restore (Self-Managed / ECH) — faster whole-index transfer when no transformation is needed.
See the decision tree in references/patterns.md.
Reference material
- API parameter reference — full
POST /_reindexbody and query parameters - Multi-step patterns — mapping changes, remote migration, merge, ingest pipeline, performance
- Tuning — batch size (
source.size), timestamps, versioning - Troubleshooting — mapping conflicts, scroll timeouts, count mismatches
Examples
"Copy logs-2024 into a new index with a corrected mapping" — create the destination first, then reindex:
POST /_reindex
{ "source": { "index": "logs-2024" }, "dest": { "index": "logs-2024-v2" } }
"Reindex a large index in parallel and throttle it" — slice automatically and cap the request rate:
POST /_reindex?slices=auto&requests_per_second=2000
{ "source": { "index": "events" }, "dest": { "index": "events-v2" } }
"Migrate only recent documents" — filter the source with a query:
POST /_reindex
{
"source": { "index": "metrics", "query": { "range": { "@timestamp": { "gte": "now-30d" } } } },
"dest": { "index": "metrics-recent" }
}
Guidelines
- Confirm deployment type first. Call
GET /and readbuild_flavor; shard, replica, cluster-settings, and task APIs differ between Self-Managed / ECH and Serverless (see Deployment constraints). - Prefer an alternative when it fits. Runtime fields, aliases, or snapshot-and-restore often avoid a full reindex.
- Tune the destination for the copy. On Self-Managed / ECH set
number_of_replicas: 0andrefresh_interval: "-1"during the copy, then restore production settings afterward; on Serverless these are managed. - Parallelize large copies. Use
slices=autofor local reindex and throttle withrequests_per_secondto protect the cluster. - Run big jobs asynchronously. Submit with
wait_for_completion=falseand poll the task instead of blocking. - Verify by count. Compare the source filter expectation to the exact destination
GET /{dest}/_count— never estimate.
Operations
| HTTP API (shorthand) | elastic CLI command |
|---|---|
GET / | elastic es info |
GET /{index}/_mapping | elastic es indices get-mapping --index '<index>' |
GET /{index}/_count | elastic es count --index '<index>' |
GET /_cat/count/{index}?h=count | elastic es cat count --index '<index>' --h count |
PUT /{index} | elastic es indices create --index '<index>' --mappings '<json>' --settings '<json>' |
PUT /{index}/_settings | elastic es indices put-settings --index '<index>' --settings '<json>' |
POST /_reindex?wait_for_completion=false | elastic es reindex --wait-for-completion false --source '<json>' --dest '<json>' |
GET /_tasks/{task_id} | elastic es tasks get --task-id '<task_id>' |
GET /_tasks?actions=*reindex&detailed | elastic es tasks list --actions '*reindex' --detailed |
POST /_tasks/{task_id}/_cancel | elastic es tasks cancel --task-id '<task_id>' |
POST /_reindex/{task_id}/_rethrottle?requests_per_second=N | elastic es reindex-rethrottle --task-id '<task_id>' --requests-per-second <N> |
FAQ
What does the elasticsearch-reindex skill do?
Guide Elasticsearch reindex for performance: local and remote, slicing, throttling, task API. Use when copying or migrating indices, changing mappings, or transforming during reindex.
How do I install elasticsearch-reindex?
Run npx skills add https://github.com/elastic/agent-skills --skill elasticsearch-reindex in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/elasticsearch-reindex/ (personal) or .claude/skills/elasticsearch-reindex/ (project).
Which AI agents can use elasticsearch-reindex?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is elasticsearch-reindex safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains elasticsearch-reindex?
It is published by elastic in elastic/agent-skills. It has 1,061 recorded installs.
More from elastic/agent-skills
elasticsearch-esql
elastic/agent-skills
Execute ESQL (Elasticsearch Query Language) queries, use when the user wants to query Elasticsearch data, analyze logs, aggregate metrics, explore data, or create charts and dashboards from ESQL results.
elasticsearch-onboarding
elastic/agent-skills
Help developers new to Elasticsearch get from zero to a working search experience. Guide them through understanding their intent, mapping their data, and building a search experience with best practices baked in. Use this when the user shows intent to build search-related functionality, asks about Elasticsearch-related concepts for their use case, or expresses the need for help getting started with Elasticsearch.
kibana-dashboards
elastic/agent-skills
Create and manage Kibana Dashboards and Lens visualizations. Use when you need to define dashboards and visualizations declaratively, version control them, or automate their deployment.
security-case-management
elastic/agent-skills
Create, search, update, and manage SOC cases via the Kibana Cases API. Use when tracking incidents, linking alerts to cases, adding investigation notes, or managing triage output.
kibana-alerting-rules
elastic/agent-skills
Create and manage Kibana alerting rules. Use when creating, updating, or managing rule lifecycle (enable, disable, mute, snooze), choosing metric threshold rule types and params, or read-only find/list with tag filters.
kibana-agent-builder
elastic/agent-skills
Create and manage Kibana Agent Builder agents and custom tools. Use when asked to create, update, delete, test, or inspect agents or tools in Agent Builder, or when the user wants to understand what agents or tools already exist.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.