Company
Contact Us

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.

ParameterTypeDescription
pipelineStringThe pipeline ID for preprocessing documents.
refreshEnumWhether 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_aliasBooleanSet to true to require that all actions target an index alias rather than an index. Default is false.
routingStringRoutes the request to the specified shard.
timeoutTimeHow long to wait for the request to return. Default 1m.
typeString(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_shardsStringSpecifies 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.
© 2021-2024 Mach5 Software, Inc. All rights reserved

When you visit or interact with our sites, services or tools, we or our authorised service providers may use cookies for storing information to help provide you with a better, faster and safer experience and for marketing purposes.