Skip to content

About

Run Elasticsearch 8 in Docker, create an index, bulk-load documents, and run full-text and filtered queries.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Arya Fatthurahman

Elasticsearch Lab

Run Elasticsearch 8 in Docker, create an index, bulk-load documents, and run full-text and filtered queries.

Database: Elasticsearch Category: Search engine Runs in Docker License: MIT compose-check

What this lab is

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.

Quickstart

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

Connection details

Field Value
URL http://localhost:9200
Index books
Auth disabled in this lab
Kibana not included; add Kibana if you want a UI

Examples

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.

Exercises

  1. Add a summary field with a custom analyzer and compare phrase vs. match queries.
  2. Use _cat/indices?v and _cat/shards?v to inspect the cluster.
  3. Add a second document with the same author and run a terms aggregation.
  4. Delete the index and recreate it with a different number of shards.

Notes and limits

  • 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-data volume. docker compose down -v deletes it.

Run it from anywhere

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.

Cleanup

docker compose down -v

-v also removes the named volume, so the next start is a clean slate.

References


Part of the database-labs collection: 26 database engines, one index.

License

MIT (c) 2026 Arya Fatthurahman. See LICENSE.

About

Run Elasticsearch 8 in Docker, create an index, bulk-load documents, and run full-text and filtered queries.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors