← All insightsAutomation

Automating Elasticsearch from scratch

CodeWizard Academy · 9 August 2025 · 3 min read · Intermediate

Anything you do to Elasticsearch twice should be automated. This walks the path from a manual install to a repeatable, pipeline-driven setup.

1. Install it reproducibly

bash
docker run -p 9200:9200 -e discovery.type=single-node \
  -e xpack.security.enabled=false docker.elastic.co/elasticsearch/elasticsearch:8.15.0

2. Describe the desired state

Create an index with an explicit mapping.

bash
curl -X PUT localhost:9200/logs -H 'Content-Type: application/json' -d '{
  "mappings": { "properties": {
    "@timestamp": { "type": "date" },
    "level": { "type": "keyword" },
    "message": { "type": "text" }
  } }
}'

3. Run it from CI

Provide Elasticsearch as a CI service.

yaml
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.15.0
    env: { discovery.type: single-node, xpack.security.enabled: 'false' }
    ports: ['9200:9200']

Want senior help putting Elasticsearch to work - or a team bootcamp on it? CodeWizard runs Israel's largest DevOps community and embeds named senior engineers with a transparent hours log. Book a free consult or explore the Academy.

Like where this is going?

Get hands-on help from the engineers who write these posts.

Book a free consult