pub struct Bulker { /* private fields */ }Expand description
Bulker is a helper struct to make bulk requests to OpenSearch.
Implementations§
Source§impl Bulker
impl Bulker
Sourcepub fn new(
os_client: Arc<OsClient>,
bulk_size: u32,
max_concurrent_connections: u32,
) -> (JoinHandle<()>, Bulker)
pub fn new( os_client: Arc<OsClient>, bulk_size: u32, max_concurrent_connections: u32, ) -> (JoinHandle<()>, Bulker)
Spawn an extraction service on a separate thread and return an extraction instance to interact with it
pub fn statistics(&self) -> BulkerStatistic
Sourcepub async fn index<T: Serialize>(
&self,
index: &str,
body: &T,
id: Option<String>,
) -> Result<(), Error>
pub async fn index<T: Serialize>( &self, index: &str, body: &T, id: Option<String>, ) -> Result<(), Error>
Sends a bulk index request to OpenSearch with the specified index, id and document body.
§Arguments
index- A string slice that holds the name of the index.id- An optional string slice that holds the id of the document.body- A reference to a serializable document body.
§Returns
Returns () on success, or an Error on failure.
Sourcepub async fn create<T: Serialize>(
&self,
index: &str,
id: &str,
body: &T,
) -> Result<(), Error>
pub async fn create<T: Serialize>( &self, index: &str, id: &str, body: &T, ) -> Result<(), Error>
Sends a bulk create request to the OpenSearch cluster with the specified index, id and body.
§Arguments
index- A string slice that holds the name of the index.id- A string slice that holds the id of the document.body- A generic typeTthat holds the body of the document to be created.
§Returns
Returns () on success, or an Error on failure.
Sourcepub async fn update(
&self,
index: &str,
id: &str,
body: &UpdateActionBody,
) -> Result<(), Error>
pub async fn update( &self, index: &str, id: &str, body: &UpdateActionBody, ) -> Result<(), Error>
Asynchronously updates a document in bulk.
§Arguments
index- A string slice that holds the name of the index.id- A string slice that holds the ID of the document to update.body- AnUpdateActionstruct that holds the update action to perform.
§Returns
Returns a Result containing a serde_json::Value on success, or an
Error on failure.
pub async fn flush(&self)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bulker
impl !RefUnwindSafe for Bulker
impl Send for Bulker
impl Sync for Bulker
impl Unpin for Bulker
impl !UnwindSafe for Bulker
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
Mutably borrows from an owned value. Read more