Home/Engineer/Databases/Getting Started with Elastic…
DatabasesIntermediateUbuntuDebianCentOSelasticsearchkibana

Getting Started with Elasticsearch — Installation, Indexes, Queries, and Connecting Kibana

A hands-on introduction to search engine fundamentals: installing Elasticsearch, creating indexes and performing document CRUD, match/term/range queries, aggregations, and connecting Kibana.

Contents
  1. Installation (Ubuntu, Docker recommended)
  2. Index Management
  3. Document CRUD
  4. Search Queries
  5. Aggregations
  6. Configuring a Korean Analyzer
Bash
# Quick start with Docker Compose
cat > docker-compose.yml << 'EOF'
version: '3.8'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.13.0
    environment:
      - discovery.type=single-node
      - xpack.security.enabled=false
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    ports:
      - "9200:9200"
    volumes:
      - esdata:/usr/share/elasticsearch/data

  kibana:
    image: docker.elastic.co/kibana/kibana:8.13.0
    ports:
      - "5601:5601"
    environment:
      - ELASTICSEARCH_HOSTS=http://elasticsearch:9200

volumes:
  esdata:
EOF

docker compose up -d

# Check status
curl http://localhost:9200

Index Management

Bash
# Create an index (explicit mapping)
curl -X PUT http://localhost:9200/products \
  -H 'Content-Type: application/json' -d '{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "properties": {
      "name":        { "type": "text", "analyzer": "standard" },
      "price":       { "type": "float" },
      "category":    { "type": "keyword" },
      "stock":       { "type": "integer" },
      "createdAt":   { "type": "date" },
      "description": { "type": "text" }
    }
  }
}'

# List indexes
curl http://localhost:9200/_cat/indices?v

# Delete an index
curl -X DELETE http://localhost:9200/products

Document CRUD

Bash
# Add a document
curl -X POST http://localhost:9200/products/_doc \
  -H 'Content-Type: application/json' -d '{
 "name": " Pro 15",
  "price": 1500000,
  "category": "electronics",
  "stock": 50,
  "createdAt": "2025-05-27"
}'

# Add or update with a specified ID
curl -X PUT http://localhost:9200/products/_doc/1 \
  -H 'Content-Type: application/json' -d '{
 "name": " ",
  "price": 35000,
  "category": "accessories",
  "stock": 200
}'

# Get a document
curl http://localhost:9200/products/_doc/1

# Partial update
curl -X POST http://localhost:9200/products/_update/1 \
  -H 'Content-Type: application/json' -d '{
  "doc": { "price": 32000, "stock": 180 }
}'

# Delete a document
curl -X DELETE http://localhost:9200/products/_doc/1

Search Queries

Bash
# match — full-text search (analyzed)
curl -X GET http://localhost:9200/products/_search \
  -H 'Content-Type: application/json' -d '{
  "query": {
 "match": { "name": "" }
  }
}'

# term — exact value match (keyword type)
curl -X GET http://localhost:9200/products/_search \
  -H 'Content-Type: application/json' -d '{
  "query": {
    "term": { "category": "electronics" }
  }
}'

# range — range query
curl -X GET http://localhost:9200/products/_search \
  -H 'Content-Type: application/json' -d '{
  "query": {
    "range": {
      "price": { "gte": 100000, "lte": 2000000 }
    }
  }
}'

# bool — compound query
curl -X GET http://localhost:9200/products/_search \
  -H 'Content-Type: application/json' -d '{
  "query": {
    "bool": {
 "must": [{ "match": { "name": "" } }],
      "filter": [{ "term":  { "category": "electronics" } }],
      "must_not": [{ "range": { "stock": { "lte": 0 } } }]
    }
  },
  "sort": [{ "price": "asc" }],
  "from": 0,
  "size": 10
}'

Aggregations

Bash
curl -X GET http://localhost:9200/products/_search \
  -H 'Content-Type: application/json' -d '{
  "size": 0,
  "aggs": {
    "by_category": {
      "terms": { "field": "category", "size": 10 }
    },
    "avg_price": {
      "avg": { "field": "price" }
    },
    "price_range": {
      "range": {
        "field": "price",
        "ranges": [
          { "to": 50000 },
          { "from": 50000, "to": 500000 },
          { "from": 500000 }
        ]
      }
    }
  }
}'

Configuring a Korean Analyzer

Bash
# Install the nori plugin (Docker)
docker exec -it elasticsearch \
  bin/elasticsearch-plugin install analysis-nori

# Create an index with the nori analyzer
curl -X PUT http://localhost:9200/korean-products \
  -H 'Content-Type: application/json' -d '{
  "settings": {
    "analysis": {
      "analyzer": {
        "korean": {
          "type": "nori"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "name": { "type": "text", "analyzer": "korean" }
    }
  }
}'
#elasticsearch#kibana
Editorial note

AI tools may assist drafting. Check the evidence in each guide for whether commands were run and which environment was used. Confirm the current docs for your version before applying instructions, and email us about errors. email us

Topic-related official docs (auto-linked · not per-claim sources)Elasticsearch 공식 가이드 ↗

Questions & answers

Ask a question about this guide. We'll review and reply.