pub struct ElasticHelper {
    pub client: Elasticsearch,
    pub index_name: String,
}
Expand description

A wrapper around an Elasticsearch client to make common operations easier and more consistent.

Fields

client: Elasticsearch

The ES client this helper users.

index_name: String

The search index this helper targets.

Implementations

Create a new ElasticHelper that connects to the server specified in settings and uses the index specified in [index_name].

Errors

If the settings to connect to Elasticsearch are not valid, the creation process may fail.

Check that the helper’s index exists.

Errors

If there is an HTTP error communication with ES.

Creates the helper’s index, assuming it doesn’t already exist.

Errors

If the index already exists, or if there is an HTTP error communication with ES.

Ensure that the helper’s index exists, creating it if needed.

Errors

If there is an HTTP error communication with ES.

Add a document to the helper’s index. The ID of the document will be set based on the HelperIndexable::doc_id method.

Errors

If there is an HTTP error communication with ES, or if there is a problem serializing the document.

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