Bootstrap an Index
A 4-step recipe with Elasticsearch. We can help you get access.
Recipe · 4 steps
Bootstrap an Index
with Elasticsearch
Idempotently create an Elasticsearch index and verify its resulting configuration.
- Read cluster health before writing anything, so the workflow fails fast against a cluster that cannot accept an index creation.
- Probe for the target index with a HEAD request. A 404 here is an expected answer, not a failure, so both 200 and 404 are treated as success and the status code drives the branch.
- Create the index with the supplied settings and mappings. Only reached when the probe returned 404, which keeps the workflow idempotent.
- Read the index back to confirm the settings and mappings Elasticsearch actually resolved, which may include defaults the caller did not supply.
What you'll need to have ready
- index: The name of the index to bootstrap (e.g. "products").
- settings: Index settings such as number_of_shards and number_of_replicas.
- mappings: The field mappings that define the index schema.
For your developer
Arazzo workflow elasticsearch:bootstrap-index, 4 operations: clusterHealth → indexExists → createIndex → getIndex. Specs on APIs.io.