Massenindizierung und die Bulk API
Indizieren Sie Tausende Dokumente effizient mit der Bulk API und lernen Sie, mit Teilfehlern umzugehen.
Massenindizierung und die Bulk API ist eine kostenlose Elasticsearch & Full Text Search Systems-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Elasticsearch & Full Text Search Systems-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Elasticsearch & Full Text Search Systems-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
Why Bulk
Indexing documents one HTTP request at a time is slow. The Bulk API packs many operations into a single request, dramatically improving throughput.
The NDJSON Format
Bulk requests use newline-delimited JSON: each action line is followed by its source line (for index/create/update). Every line ends with a newline, including the last.
A Basic Bulk Request
Here two documents are indexed in one call.
POST /products/_bulk
{ "index": { "_id": "1" } }
{ "name": "Keyboard", "price": 40 }
{ "index": { "_id": "2" } }
{ "name": "Mouse", "price": 20 }Supported Actions
Bulk supports four actions:
index— create or replacecreate— fail if the id existsupdate— partial updatedelete— no source line needed
Mixing Actions
A single bulk body can mix actions and even target different indices via the action metadata.
POST /_bulk
{ "delete": { "_index": "products", "_id": "3" } }
{ "update": { "_index": "products", "_id": "1" } }
{ "doc": { "price": 45 } }Partial Failures
Crucially, the bulk request itself returns 200 OK even if some items fail. You must inspect the errors flag and per-item status.
// response
{ "errors": true, "items": [ { "index": { "status": 201 } },
{ "index": { "status": 409 } } ] }Choosing a Batch Size
There is no perfect number, but 1,000 to 5,000 documents (or a few megabytes) per bulk request is a good starting range. Measure and adjust for your data.
Tuning for Heavy Loads
For huge initial loads, temporarily disable the refresh interval and reduce replicas, then restore them afterward.
PUT /products/_settings
{ "index": { "refresh_interval": "-1",
"number_of_replicas": 0 } }Restore After Load
Once the bulk load finishes, re-enable refresh and replicas so the data becomes searchable and durable.
PUT /products/_settings
{ "index": { "refresh_interval": "1s",
"number_of_replicas": 1 } }Retrying Failures
A status of 429 (too many requests) means the cluster is overloaded. Retry only the failed items with exponential backoff, not the whole batch.
Client Helpers
Official clients provide bulk helpers that chunk, send, and retry automatically, so you rarely build NDJSON by hand in production.
Quick Check
A bulk request returns HTTP 200. Is everything fine?
Recap
You learned the Bulk API: the NDJSON format, the four actions, why partial failures need per-item inspection, sensible batch sizes, load-time tuning of refresh and replicas, and retrying 429s with backoff.
Häufig gestellte Fragen
Ist die Lektion „Massenindizierung und die Bulk API“ kostenlos?
Ja — der vollständige Text von „Massenindizierung und die Bulk API“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Elasticsearch & Full Text Search Systems-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Elasticsearch & Full Text Search Systems-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Massenindizierung und die Bulk API“?
Indizieren Sie Tausende Dokumente effizient mit der Bulk API und lernen Sie, mit Teilfehlern umzugehen. Du übst Elasticsearch & Full Text Search Systems mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Elasticsearch & Full Text Search Systems zu starten?
Keine Vorkenntnisse erforderlich. Elasticsearch & Full Text Search Systems auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Massenindizierung und die Bulk API“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Elasticsearch & Full Text Search Systems-Lektion Code schreiben und ausführen?
Ja. Jede Elasticsearch & Full Text Search Systems-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Dokumente in Elasticsearch indexieren
- CRUD-Operationen mit Dokumenten
- Grundlagen von Mappings und Datentypen
- Massenindizierung und die Bulk API