[][src]Type Definition elastic::client::requests::document_get::GetRequestBuilder

type GetRequestBuilder<TSender, TDocument> = RequestBuilder<TSender, GetRequestInner<TDocument>>;

A get document request builder that can be configured before sending.

Call Client.document_get to get a GetRequestBuilder. The send method will either send the request synchronously or asynchronously, depending on the Client it was created from.

Methods

impl<TSender, TDocument> GetRequestBuilder<TSender, TDocument> where
    TSender: Sender
[src]

Builder methods

Configure a GetRequestBuilder before sending it.

pub fn index(self, index: impl Into<Index<'static>>) -> Self[src]

Set the index for the get request.

pub fn ty(self, ty: impl Into<Type<'static>>) -> Self[src]

Set the type for the get request.

impl<TDocument> GetRequestBuilder<SyncSender, TDocument> where
    TDocument: DeserializeOwned
[src]

pub fn send(self) -> Result<GetResponse<TDocument>>[src]

Send a GetRequestBuilder synchronously using a SyncClient.

This will block the current thread until a response arrives and is deserialised.

Examples

Get a DocumentType called MyType with an id of 1:

let response = client.document::<MyType>()
                     .get(1)
                     .send()?;

if let Some(doc) = response.into_document() {
    println!("{:?}", doc);
}

impl<TDocument> GetRequestBuilder<AsyncSender, TDocument> where
    TDocument: DeserializeOwned + Send + 'static, 
[src]

pub fn send(self) -> Pending<TDocument>[src]

Send a GetRequestBuilder asynchronously using an AsyncClient.

This will return a future that will resolve to the deserialised get document response.

Examples

Get a DocumentType called MyType with an id of 1:

let future = client.document::<MyType>()
                   .get(1)
                   .send();

future.and_then(|response| {
    if let Some(doc) = response.into_document() {
        println!("{:?}", doc);
    }

    Ok(())
});