0Pricing
Elasticsearch & Full Text Search Systems · Lekcja

Indeksowanie zbiorcze i Bulk API

Zindeksują Państwo efektywnie tysiące dokumentów za pomocą Bulk API i nauczą się obsługiwać częściowe niepowodzenia.

Indeksowanie zbiorcze i Bulk API to bezpłatna lekcja Elasticsearch & Full Text Search Systems na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Elasticsearch & Full Text Search Systems, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Elasticsearch & Full Text Search Systems zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

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 replace
  • create — fail if the id exists
  • update — partial update
  • delete — 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.

Często zadawane pytania

Czy lekcja „Indeksowanie zbiorcze i Bulk API” jest bezpłatna?

Tak — pełny tekst „Indeksowanie zbiorcze i Bulk API” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Elasticsearch & Full Text Search Systems, przejdź na CoddyKit PRO. Kurs Elasticsearch & Full Text Search Systems zawiera 4 lekcji w sumie.

Co nauczysz się w „Indeksowanie zbiorcze i Bulk API”?

Zindeksują Państwo efektywnie tysiące dokumentów za pomocą Bulk API i nauczą się obsługiwać częściowe niepowodzenia. Ćwiczysz Elasticsearch & Full Text Search Systems z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Elasticsearch & Full Text Search Systems?

Nie wymagamy żadnego doświadczenia. Elasticsearch & Full Text Search Systems w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.

Ile czasu zajmuje lekcja „Indeksowanie zbiorcze i Bulk API”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Elasticsearch & Full Text Search Systems?

Tak. Każda lekcja Elasticsearch & Full Text Search Systems zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Indeksowanie dokumentów w Elasticsearch
  2. Operacje CRUD na dokumentach
  3. Podstawy mapowania i typów danych
  4. Indeksowanie zbiorcze i Bulk API
← Powrót do Elasticsearch & Full Text Search Systems