0Pricing
Elasticsearch & Full Text Search Systems · レッスン

一括インデックス作成とBulk API

Bulk APIを使って数千件のドキュメントを効率的にインデックスし、一部失敗への対処方法を学びます。

「一括インデックス作成とBulk API」はCoddyKit上の無料Elasticsearch & Full Text Search Systemsレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはElasticsearch & Full Text Search Systems学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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.

よくある質問

「一括インデックス作成とBulk API」レッスンは無料ですか?

はい。「一括インデックス作成とBulk API」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Elasticsearch & Full Text Search Systemsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Elasticsearch & Full Text Search Systemsコースには全4レッスンが含まれています。

「一括インデックス作成とBulk API」で何を学びますか?

Bulk APIを使って数千件のドキュメントを効率的にインデックスし、一部失敗への対処方法を学びます。 ブラウザで直接実行するハンズオンコードでElasticsearch & Full Text Search Systemsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Elasticsearch & Full Text Search Systemsを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのElasticsearch & Full Text Search Systemsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「一括インデックス作成とBulk API」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このElasticsearch & Full Text Search Systemsレッスンでコードを書いて実行できますか?

はい。すべてのElasticsearch & Full Text Search Systemsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. Elasticsearchへのドキュメントのインデックス登録
  2. ドキュメントによるCRUD操作
  3. マッピングとデータ型の基礎
  4. 一括インデックス作成とBulk API
← Elasticsearch & Full Text Search Systemsに戻る