Elasticsearch is a distributed, RESTful search and analytics engine. Part of the Elastic Stack, it enables fast full-text search, log analytics, and real-time application monitoring at scale.
📑 Table of Contents
Key Features
- Full-Text Search: Advanced text analysis and relevance
- Distributed: Horizontal scaling and replication
- RESTful API: JSON over HTTP interface
- Aggregations: Complex analytics queries
- Real-Time: Near-instant data availability
Installation
Install Elasticsearch on Ubuntu:
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elasticsearch-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-8.x.list
sudo apt update
sudo apt install elasticsearch
sudo systemctl enable elasticsearch
Usage Examples
Elasticsearch operations:
# Index a document
curl -X POST "localhost:9200/products/_doc" -H "Content-Type: application/json" -d'
{
"name": "Laptop",
"description": "High performance laptop for developers"
}'
# Search documents
curl -X GET "localhost:9200/products/_search?q=laptop"
# Aggregation query
curl -X GET "localhost:9200/orders/_search" -d'
{
"aggs": {
"sales_by_month": {
"date_histogram": { "field": "date", "interval": "month" }
}
}
}'
Benefits
Elasticsearch delivers blazing-fast search and analytics. Its distributed nature ensures high availability while the REST API enables easy integration.
Was this article helpful?