Elasticsearch "index_not_found_exception" in CI
A request targeted an index that does not exist on the cluster. A CI service container starts empty, so any query that assumes an index is present fails with index_not_found_exception until a setup step creates and populates it.
What this error means
A search or update returns HTTP 404 with "index_not_found_exception" and "no such index [name]". It passes locally where the index already exists.
{"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index
[products]","index":"products"}],"type":"index_not_found_exception"},"status":404}Common causes
The fresh cluster has no indices
A CI container starts empty; unlike a developer machine, no indices exist until the test setup creates them.
Strict index resolution rejects missing targets
With ignore_unavailable off, a query against a non-existent index is a hard 404 rather than an empty result.
How to fix it
Create and seed the index in setup
- Add a setup step that creates the index (with its mapping) before tests run.
- Seed any fixture documents the tests expect.
- Refresh the index so the documents are searchable immediately.
curl -X PUT "http://localhost:9200/products"
curl -X POST "http://localhost:9200/products/_doc?refresh=true" \
-H 'Content-Type: application/json' -d '{"name":"widget"}'Tolerate missing indices where appropriate
For read paths that may run before seeding, pass ignore_unavailable=true so a missing index yields an empty result instead of a 404.
How to prevent it
- Create every index the tests need in a deterministic setup step.
- Do not assume a CI cluster inherits indices from anywhere.
- Use
refresh=trueafter seeding so documents are searchable at once.