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 OpenSearch, 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§
Source§impl<B> BulkOperation<B>where
B: Serialize,
impl<B> BulkOperation<B>where
B: Serialize,
Sourcepub fn create<S>(id: S, source: B) -> BulkCreateOperation<B>
pub fn create<S>(id: S, source: B) -> BulkCreateOperation<B>
Creates a new instance of a bulk create operation
Sourcepub fn create_without_id(source: B) -> BulkCreateOperation<B>
pub fn create_without_id(source: B) -> BulkCreateOperation<B>
Creates a new instance of bulk create operation without an explicit id
Sourcepub fn index(source: B) -> BulkIndexOperation<B>
pub fn index(source: B) -> BulkIndexOperation<B>
Creates a new instance of a bulk index operation
Sourcepub fn delete<S>(id: S) -> BulkDeleteOperation<B>
pub fn delete<S>(id: S) -> BulkDeleteOperation<B>
Creates a new instance of a bulk delete operation
Sourcepub fn update<S>(id: S, source: B) -> BulkUpdateOperation<B>
pub fn update<S>(id: S, source: B) -> BulkUpdateOperation<B>
Creates a new instance of a bulk update operation
Trait Implementations§
Source§impl<B> Body for BulkOperation<B>where
B: Serialize,
impl<B> Body for BulkOperation<B>where
B: Serialize,
Source§impl<B> From<BulkCreateOperation<B>> for BulkOperation<B>
impl<B> From<BulkCreateOperation<B>> for BulkOperation<B>
Source§fn from(b: BulkCreateOperation<B>) -> Self
fn from(b: BulkCreateOperation<B>) -> Self
Source§impl<B> From<BulkDeleteOperation<B>> for BulkOperation<B>
impl<B> From<BulkDeleteOperation<B>> for BulkOperation<B>
Source§fn from(b: BulkDeleteOperation<B>) -> Self
fn from(b: BulkDeleteOperation<B>) -> Self
Source§impl<B> From<BulkIndexOperation<B>> for BulkOperation<B>
impl<B> From<BulkIndexOperation<B>> for BulkOperation<B>
Source§fn from(b: BulkIndexOperation<B>) -> Self
fn from(b: BulkIndexOperation<B>) -> Self
Source§impl<B> From<BulkUpdateOperation<B>> for BulkOperation<B>
impl<B> From<BulkUpdateOperation<B>> for BulkOperation<B>
Source§fn from(b: BulkUpdateOperation<B>) -> Self
fn from(b: BulkUpdateOperation<B>) -> Self
Auto Trait Implementations§
impl<B> Freeze for BulkOperation<B>where
B: Freeze,
impl<B> RefUnwindSafe for BulkOperation<B>where
B: RefUnwindSafe,
impl<B> Send for BulkOperation<B>where
B: Send,
impl<B> Sync for BulkOperation<B>where
B: Sync,
impl<B> Unpin for BulkOperation<B>where
B: Unpin,
impl<B> UnwindSafe for BulkOperation<B>where
B: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more