📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Elasticsearch Bulk Operations

Bulk Operations

5 min read
Use the Bulk API to index, update, and delete thousands of documents in a single HTTP request.

Bulk API

# Bulk insert / update / delete in one request
POST /_bulk
{ "index": { "_index": "posts", "_id": "1" } }
{ "title": "Docker Guide", "author": "alice" }
{ "index": { "_index": "posts", "_id": "2" } }
{ "title": "K8s Basics", "author": "bob" }
{ "update": { "_index": "posts", "_id": "1" } }
{ "doc": { "views": 100 } }
{ "delete": { "_index": "posts", "_id": "3" } }

# Python client bulk insert
from elasticsearch import Elasticsearch
from elasticsearch.helpers import bulk

es = Elasticsearch()
docs = [{"_index":"posts","_id":i,"title":"Post " + str(i)} for i in range(1000)]
bulk(es, docs)

# Bulk with scroll for large exports
GET /posts/_search?scroll=2m
{ "size": 500, "query": { "match_all": {} } }