[−][src]Struct elasticsearch::BulkOperation
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
impl<B> BulkOperation<B> where
B: Serialize,
[src]
B: Serialize,
pub fn create<S>(id: S, source: B) -> BulkCreateOperation<B> where
S: Into<String>,
[src]
S: Into<String>,
Creates a new instance of a bulk create operation
pub fn index(source: B) -> BulkIndexOperation<B>
[src]
Creates a new instance of a bulk index operation
pub fn delete<S>(id: S) -> BulkDeleteOperation<B> where
S: Into<String>,
[src]
S: Into<String>,
Creates a new instance of a bulk delete operation
pub fn update<S>(id: S, source: B) -> BulkUpdateOperation<B> where
S: Into<String>,
[src]
S: Into<String>,
Creates a new instance of a bulk update operation
Trait Implementations
impl<B> Body for BulkOperation<B> where
B: Serialize,
[src]
B: Serialize,
fn write(&self, bytes: &mut BytesMut) -> Result<(), Error>
[src]
fn bytes(&self) -> Option<Bytes>
[src]
impl<B> From<BulkCreateOperation<B>> for BulkOperation<B>
[src]
fn from(b: BulkCreateOperation<B>) -> Self
[src]
impl<B> From<BulkDeleteOperation<B>> for BulkOperation<B>
[src]
fn from(b: BulkDeleteOperation<B>) -> Self
[src]
impl<B> From<BulkIndexOperation<B>> for BulkOperation<B>
[src]
fn from(b: BulkIndexOperation<B>) -> Self
[src]
impl<B> From<BulkUpdateOperation<B>> for BulkOperation<B>
[src]
fn from(b: BulkUpdateOperation<B>) -> Self
[src]
Auto Trait Implementations
impl<B> RefUnwindSafe for BulkOperation<B> where
B: RefUnwindSafe,
B: RefUnwindSafe,
impl<B> Send for BulkOperation<B> where
B: Send,
B: Send,
impl<B> Sync for BulkOperation<B> where
B: Sync,
B: Sync,
impl<B> Unpin for BulkOperation<B> where
B: Unpin,
B: Unpin,
impl<B> UnwindSafe for BulkOperation<B> where
B: UnwindSafe,
B: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,