Struct elastic_responses::bulk::BulkErrorsResponse [] [src]

pub struct BulkErrorsResponse<TIndex = String, TType = String, TId = String> { /* fields omitted */ }

Response for a bulk request.

This type only accumulates bulk items that failed. It can be more efficient if you only care about errors. Individual bulk items are ErrorItem and can be iterated over.

Examples

Send a bulk request and iterate through the errors:

let response: BulkErrorsResponse = do_request();

// Do something with failed items
for item in response {
    match item.action() {
        Action::Delete => (), // Ignore failed deletes
        _ => println!("err: {:?}", item) 
    }
}

Use iter to iterate over individual errors without taking ownership of them:

let response: BulkErrorsResponse = do_request();

// Do something with errors for index `myindex`
let item_iter = response.iter()
                        .filter(|o| o.index() == "myindex");

for item in item_iter {
    println!("err: {:?}", item);
}

Taking BulkErrorsResponse as an argument

The BulkErrorsResponse type has three default generic parameters for the index, type and id fields. If you need to accept a BulkErrorsResponse as a function argument, you should specify these generics. Otherwise the function will only accept a default BulkErrorsResponse:

// Do: Supports any BulkErrorsResponse
fn takes_any_response<TIndex, TType, TId>(res: BulkErrorsResponse<TIndex, TType, TId>) { 

}

// Don't: Only supports default BulkErrorsResponse
fn takes_default_response(res: BulkErrorsResponse) {

}

Methods

impl<TIndex, TType, TId> BulkErrorsResponse<TIndex, TType, TId>
[src]

[src]

Time in milliseconds it took for Elasticsearch to process the request.

[src]

Returns true if all bulk items succeeded.

[src]

Returns true if any bulk itemss failed.

[src]

Iterate through the bulk item errors.

Items in this iterator all all errors that occurred while handling the bulk request.

Examples

Iterate through the individual items in a BulkErrorsResponse:

let response: BulkErrorsResponse = do_request();
    
// Iterate through all items
for item in response.iter() {
    // Do something with failed items
    println!("err: {:?}", item)
}

Trait Implementations

impl<TIndex: Debug, TType: Debug, TId: Debug> Debug for BulkErrorsResponse<TIndex, TType, TId>
[src]

[src]

Formats the value using the given formatter.

impl<TIndex: Clone, TType: Clone, TId: Clone> Clone for BulkErrorsResponse<TIndex, TType, TId>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<TIndex, TType, TId> IntoIterator for BulkErrorsResponse<TIndex, TType, TId>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<TIndex, TType, TId> IsOk for BulkErrorsResponse<TIndex, TType, TId>
[src]

[src]

Inspect the http response to determine whether or not it succeeded.