Skip to main content
This guide gets you from zero to a running Elasticsearch instance, an indexed document, and a search result. It uses the start-local script, which starts Elasticsearch and Kibana in Docker with a single command.
The start-local setup is intended for local development and testing only. HTTPS is disabled and basic authentication is used. Do not use this setup in production.

Prerequisites

1

Start Elasticsearch and Kibana

Run the start-local script. It creates an elastic-start-local directory, writes a .env file with credentials, and starts both services via Docker Compose.
curl -fsSL https://elastic.co/start-local | sh
When the script finishes, you will see output similar to:
Elasticsearch is running at http://localhost:9200
Kibana is running at http://localhost:5601

Username: elastic
Password: <generated-password>
The generated password is also written to elastic-start-local/.env as ES_LOCAL_PASSWORD. The .env file also contains an API key in ES_LOCAL_API_KEY.
Load the environment variables before running the curl examples below:
source elastic-start-local/.env
export ES_LOCAL_PASSWORD
2

Verify Elasticsearch is running

Confirm the node is up and responding:
curl -u elastic:$ES_LOCAL_PASSWORD http://localhost:9200
You should receive a JSON response with the cluster name, node name, and version:
{
  "name": "es01",
  "cluster_name": "docker-cluster",
  "version": {
    "number": "8.x.x",
    ...
  },
  "tagline": "You Know, for Search"
}
3

Index a document

Add a document to the my-index index. Elasticsearch creates the index automatically if it does not exist and assigns the document an ID.
curl -u elastic:$ES_LOCAL_PASSWORD \
  -X POST "http://localhost:9200/my-index/_doc" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Elasticsearch quickstart",
    "body": "Distributed search and analytics at scale.",
    "category": "documentation",
    "timestamp": "2024-01-01T00:00:00Z"
  }'
The response includes the assigned _id and a result field set to created:
{
  "_index": "my-index",
  "_id": "abc123",
  "_version": 1,
  "result": "created"
}
4

Run a search query

Search for documents where the body field matches distributed:
curl -u elastic:$ES_LOCAL_PASSWORD \
  -X GET "http://localhost:9200/my-index/_search" \
  -H "Content-Type: application/json" \
  -d '{
    "query": {
      "match": {
        "body": "distributed"
      }
    }
  }'
The hits.hits array contains matching documents with relevance scores:
{
  "hits": {
    "total": { "value": 1, "relation": "eq" },
    "hits": [
      {
        "_index": "my-index",
        "_id": "abc123",
        "_score": 0.6931471,
        "_source": {
          "title": "Elasticsearch quickstart",
          "body": "Distributed search and analytics at scale.",
          "category": "documentation",
          "timestamp": "2024-01-01T00:00:00Z"
        }
      }
    ]
  }
}
5

Run an ES|QL query

ES|QL is Elasticsearch’s piped query language. Use it for filtering, aggregating, and transforming data with a SQL-like syntax.
curl -u elastic:$ES_LOCAL_PASSWORD \
  -X POST "http://localhost:9200/_query" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "FROM my-index | WHERE category == \"documentation\" | KEEP title, body, timestamp | SORT timestamp DESC | LIMIT 10"
  }'
ES|QL returns results in a columnar format:
{
  "columns": [
    { "name": "title", "type": "text" },
    { "name": "body", "type": "text" },
    { "name": "timestamp", "type": "date" }
  ],
  "values": [
    ["Elasticsearch quickstart", "Distributed search and analytics at scale.", "2024-01-01T00:00:00.000Z"]
  ]
}

Next steps

Installation

Deploy Elasticsearch on Linux, macOS, Windows, or with Docker Compose for production-like setups.

Core concepts

Understand indices, shards, mappings, and cluster architecture.

Search with Query DSL

Explore the full Query DSL for boolean queries, filters, aggregations, and more.

ES|QL

Learn the piped ES|QL language for analytics and data transformation.

Build docs developers (and LLMs) love