Bulk
Introduced 1.0 {: .label .label-purple }
The bulk operation lets you add, update, or delete many documents in a single request. Compared to individual OpenSearch indexing requests, the bulk operation has significant performance benefits. Whenever practical, we recommend batching indexing operations into bulk requests.
Example
POST _bulk { "delete": { "_index": "movies", "_id": "tt2229499" } } { "index": { "_index": "movies", "_id": "tt1979320" } } { "title": "Rush", "year": 2013 } { "create": { "_index": "movies", "_id": "tt1392214" } } { "title": "Prisoners", "year": 2013 } { "update": { "_index": "movies", "_id": "tt0816711" } } { "doc" : { "title": "World War Z" } }
Path and HTTP methods
POST _bulk POST <index>/_bulk
Specifying the index in the path means you don't need to include it in the request body.
OpenSearch also accepts PUT requests to the _bulk
path, but we highly recommend using POST. The accepted usage of PUT---adding or replacing a single resource at a given path---doesn't make sense for bulk requests.
URL parameters
All bulk URL parameters are optional.
Parameter | Type | Description | |||
---|---|---|---|---|---|
pipeline | String | The pipeline ID for preprocessing documents. | |||
refresh | Enum | Whether to refresh the affected shards after performing the indexing operations. Default is false . true makes the changes show up in search results immediately, but hurts cluster performance. wait_for waits for a refresh. Requests take longer to return, but cluster performance doesn't suffer. | |||
require_alias | Boolean | Set to true to require that all actions target an index alias rather than an index. Default is false . | |||
routing | String | Routes the request to the specified shard. | |||
timeout | Time | How long to wait for the request to return. Default 1m . | |||
type | String | (Deprecated) The default document type for documents that don't specify a type. Default is _doc . We highly recommend ignoring this parameter and using a type of _doc for all indices. | |||
wait_for_active_shards | String | Specifies the number of active shards that must be available before OpenSearch processes the bulk request. Default is 1 (only the primary shard). Set to all or a positive integer. Values greater than 1 require replicas. For example, if you specify a value of 3, the index must have two replicas distributed across two additional nodes for the request to succeed. | |||