Run Elasticsearch 8 in Docker, create an index, bulk-load documents, and run full-text and filtered queries.
Elasticsearch is a distributed search and analytics engine built on Lucene. This lab starts a single-node instance with security disabled for local use, then walks through mapping, bulk indexing, full-text search, filters, and aggregations with plain HTTP requests.
docker compose up -d
bash examples/01_create_index.sh
bash examples/02_bulk.sh
bash examples/03_search.sh
curl -s http://localhost:9200/_cluster/health?pretty| Field | Value |
|---|---|
| URL | http://localhost:9200 |
| Index | books |
| Auth | disabled in this lab |
| Kibana | not included; add Kibana if you want a UI |
| File | What it shows |
|---|---|
docker-compose.yml |
Engine, ports, and persistent volume. |
.github/workflows/compose-check.yml |
Validates the Compose file on every push. |
examples/01_create_index.sh |
Create an index with explicit mappings. |
examples/02_bulk.sh |
Bulk-index three documents with the NDJSON API. |
examples/03_search.sh |
Full-text search, a filter, and a terms aggregation. |
- Add a
summaryfield with a custom analyzer and compare phrase vs. match queries. - Use
_cat/indices?vand_cat/shards?vto inspect the cluster. - Add a second document with the same author and run a
termsaggregation. - Delete the index and recreate it with a different number of shards.
- Security is disabled for local simplicity. Never expose port 9200 publicly in this state.
- The JVM heap is capped at 512 MB so the container fits on a laptop.
- Elasticsearch 8 uses HTTPS and authentication by default; this lab overrides both.
- Data persists in the
es-datavolume.docker compose down -vdeletes it.
This lab publishes its ports on 127.0.0.1 only. To use it from another country, do not open the database port to the internet. Pick one:
- VPS + private tunnel: run the lab on a small Ubuntu VPS, keep the port closed, and connect through WireGuard or
ssh -L. - Managed service: use a managed free tier for this engine and point the same examples at its connection string.
- HTTP UI only: if the engine has a web UI, put it behind Caddy with TLS and basic auth.
The shared checklist, provider map, and commands are in REMOTE-ACCESS.md.
docker compose down -v-v also removes the named volume, so the next start is a clean slate.
Part of the database-labs collection: 26 database engines, one index.
MIT (c) 2026 Arya Fatthurahman. See LICENSE.