Struct merino_wikipedia::ElasticHelper
source · [−]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
sourceimpl ElasticHelper
impl ElasticHelper
sourcepub fn new<S: Into<String>>(
es_settings: &ElasticsearchSettings,
index_name: S
) -> Result<Self>
pub fn new<S: Into<String>>(
es_settings: &ElasticsearchSettings,
index_name: S
) -> Result<Self>
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.
sourcepub async fn index_exists(&self) -> Result<bool>
pub async fn index_exists(&self) -> Result<bool>
sourcepub async fn index_create(&self) -> Result<()>
pub async fn index_create(&self) -> Result<()>
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.
sourcepub async fn index_ensure_exists(&self) -> Result<()>
pub async fn index_ensure_exists(&self) -> Result<()>
Ensure that the helper’s index exists, creating it if needed.
Errors
If there is an HTTP error communication with ES.
sourcepub async fn doc_add<T>(&self, doc: T) -> Result<()> where
T: HelperIndexable,
pub async fn doc_add<T>(&self, doc: T) -> Result<()> where
T: HelperIndexable,
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
impl !RefUnwindSafe for ElasticHelper
impl Send for ElasticHelper
impl Sync for ElasticHelper
impl Unpin for ElasticHelper
impl !UnwindSafe for ElasticHelper
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more