Catatan Seekor Elasticsearch

Elasticsearch adalah search engine berbasis Lucene yang dirancang untuk distributed, full-text search dan analytics.

Fundamental

Basic Concepts

  • Index: Collection of documents (similar to database table)

  • Document: JSON object stored in an index

  • Shard: Subset of an index for horizontal scaling

  • Node: Single server instance

  • Cluster: Collection of nodes

Index Management

// Create Index
PUT /my_index
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "analyzer": "standard"
      },
      "content": {
        "type": "text",
        "analyzer": "standard"
      },
      "created_at": {
        "type": "date"
      }
    }
  }
}

// Get Index Info
GET /my_index

// Delete Index
DELETE /my_index

Document Operations

Search Queries

Advanced Queries

Aggregations

Mapping & Analysis

Field Types

Analyzers

Performance & Optimization

Index Settings

Query Optimization

Monitoring & Management

Cluster Health

Reindex API

Best Practices

Index Design

  • Use appropriate number of shards (1 shard per 25-50GB)

  • Use aliases for zero-downtime reindexing

  • Set appropriate refresh intervals

  • Use bulk API for multiple operations

Query Optimization

  • Use source filtering to reduce network transfer

  • Use search_after for deep pagination

  • Avoid wildcard queries at the beginning of terms

  • Use appropriate analyzers for your use case

Monitoring

  • Monitor cluster health regularly

  • Set up alerts for cluster status

  • Monitor query performance

  • Regular index optimization

Tools & Integrations

Kibana

  • Web interface for Elasticsearch

  • Visualization and dashboard creation

  • Index management

  • Query development

Logstash

  • Data processing pipeline

  • Input/output plugins

  • Filtering and transformation

  • Integration with Elasticsearch

Beats

  • Lightweight data shippers

  • Filebeat, Metricbeat, etc.

  • Direct integration with Elasticsearch

  • Minimal resource usage

Last updated