bulk

edit
client.bulk([params, [callback]])

Perform many index/delete operations in a single API call.

Check the API Conventions and the elasticsearch docs for more information pertaining to this method.

Perform three operations in a single request.

client.bulk({
  body: [
    // action description
    { index:  { _index: 'myindex', _type: 'mytype', _id: 1 } },
     // the document to index
    { title: 'foo' },
    // action description
    { update: { _index: 'myindex', _type: 'mytype', _id: 2 } },
    // the document to update
    { doc: { title: 'foo' } },
    // action description
    { delete: { _index: 'myindex', _type: 'mytype', _id: 3 } },
    // no document needed for this delete
  ]
}, function (err, resp) {
  // ...
});

Params

waitForActiveShards

String — Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to all for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)

refresh

String — If true then refresh the effected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false (the default) then do nothing with refreshes.

Options
  • "true"
  • "false"
  • "wait_for"
  • ""

routing

String — Specific routing value

timeout

DurationString — Explicit operation timeout

type

String — Default document type for items which don’t provide one

fields

String, String[], Boolean — Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request

_source

String, String[], Boolean — True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request

_sourceExclude

String, String[], Boolean — Default list of fields to exclude from the returned _source field, can be overridden on each sub-request

_sourceInclude

String, String[], Boolean — Default list of fields to extract and return from the _source field, can be overridden on each sub-request

pipeline

String — The pipeline id to preprocess incoming documents with

index

String — Default index for items which don’t provide one

body

Object[], JSONLines — The request body, as either an array of objects or new-line delimited JSON objects. See the elasticsearch docs for details about what can be specified here.

back to top