Elasticsearch & Full Text Search Systems · درس

الفهرسة الدفعية وواجهة Bulk API

فهرس آلاف المستندات بكفاءة باستخدام Bulk API، وتعلّم كيفية التعامل مع حالات الفشل الجزئية.

الدرس 4 من 413 خطوة

الفهرسة الدفعية وواجهة Bulk API درس مجاني في Elasticsearch & Full Text Search Systems على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في 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.

البدء مجانًا

تعلم Elasticsearch & Full Text Search Systems مع معلم ذكاء اصطناعي — مجانًا

اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.

الدورات
12
الدروس
48

الأسئلة الشائعة

هل درس «الفهرسة الدفعية وواجهة Bulk API» مجاني؟

نعم — نص درس «الفهرسة الدفعية وواجهة Bulk API» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Elasticsearch & Full Text Search Systems، انتقل إلى CoddyKit PRO. تتضمن دورة Elasticsearch & Full Text Search Systems 4 دروس في المجموع.

ماذا ستتعلم في «الفهرسة الدفعية وواجهة Bulk API»؟

فهرس آلاف المستندات بكفاءة باستخدام Bulk API، وتعلّم كيفية التعامل مع حالات الفشل الجزئية. تتمرن على Elasticsearch & Full Text Search Systems مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Elasticsearch & Full Text Search Systems؟

لا تُشترط خبرة سابقة. Elasticsearch & Full Text Search Systems على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «الفهرسة الدفعية وواجهة Bulk API»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Elasticsearch & Full Text Search Systems هذا؟

نعم. كل درس في Elasticsearch & Full Text Search Systems يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. فهرسة المستندات في Elasticsearch
  2. عمليات CRUD باستخدام المستندات
  3. أساسيات التخطيط وأنواع البيانات
  4. الفهرسة الدفعية وواجهة Bulk API
← العودة إلى Elasticsearch & Full Text Search Systems