Elasticsearch ist eine verteilte Such- und Analyse-Engine.
Grundlegende Konzepte¶
- Index – Sammlung von Dokumenten (wie eine Tabelle)
- Document – JSON-Objekt (wie eine Zeile)
- Mapping – Schema (Feldtypen)
- Shard – horizontale Aufteilung des Index
CRUD¶
Der vollstaendige Leitfaden zu Elasticsearch¶
PUT /products/_doc/1 { “name”: “Laptop”, “price”: 1000 }
Suche¶
GET /products/_search { “query”: { “match”: { “name”: “laptop” } } }
Loeschen¶
DELETE /products/_doc/1
Query DSL¶
GET /products/_search {
“query”: {
“bool”: {
“must”: [{ “match”: { “name”: “laptop” } }],
“filter”: [{ “range”: { “price”: { “lte”: 2000 } } }]
}
}
}
Aggregationen¶
GET /orders/_search {
“size”: 0,
“aggs”: {
“by_status”: { “terms”: { “field”: “status” } },
“avg_total”: { “avg”: { “field”: “total” } }
}
}
Anwendungsfaelle¶
- Volltextsuche (E-Commerce, Dokumente)
- Log-Aggregation (ELK Stack)
- Metriken und Analytics
- Auto-Complete und Suggestions
- Geospatiale Suche
ELK Stack¶
Elasticsearch (Storage + Suche) + Logstash (Ingestion) + Kibana (Visualisierung). Alternative: Elasticsearch + Vector + Grafana.
Tipp¶
Elasticsearch ist leistungsstark, aber ressourcenhungrig. Fuer einfache Anwendungsfaelle erwaegen Sie PostgreSQL-Volltextsuche.