pub struct BulkOperation<B> { /* private fields */ }
Expand description

A bulk operation consists of a header that indicates the bulk action and the related metadata for the action, and an optional source document.

A collection of bulk operations can be sent to the Bulk API in the body of the API call.

For serializing a collection of bulk operations that model the source document of each bulk operation using different structs, take a look at BulkOperations.

Example

Using serde_json’s json! macro to constuct serde_json::Value from JSON literals, for the source document of each bulk operation

let mut ops: Vec<BulkOperation<Value>> = Vec::with_capacity(4);
ops.push(BulkOperation::index(json!({
        "user": "kimchy",
        "post_date": "2009-11-15T00:00:00Z",
        "message": "Trying out Elasticsearch, so far so good?"
    }))
    .id("1")
    .pipeline("process_tweet")
    .into()
);
ops.push(BulkOperation::create("2", json!({
        "user": "forloop",
        "post_date": "2020-01-08T00:00:00Z",
        "message": "Indexing with the rust client, yeah!"
    }))
    .pipeline("process_tweet")
    .into()
);
ops.push(BulkOperation::update("3", json!({
        "doc": {
            "message": "Tweets are _meant_ to be immutable!"
        },
        "doc_as_upsert": true
    }))
    .into()
);
ops.push(BulkOperation::delete("4")
    .index("old_tweets")
    .into()
);

let bulk_response = client.bulk(BulkParts::Index("tweets"))
    .body(ops)
    .send()
    .await?;

Implementations

Creates a new instance of a bulk create operation

Creates a new instance of a bulk index operation

Creates a new instance of a bulk delete operation

Creates a new instance of a bulk update operation

Trait Implementations

Write to a buffer that will be written to the request stream
An existing immutable buffer that can be used to avoid having to write to another buffer that will then be written to the request stream. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more