Struct elastic::client::requests::RequestBuilder
[−]
[src]
pub struct RequestBuilder<'a, TRequest> { /* fields omitted */ }
A builder for a raw request.
This structure wraps up a concrete REST API request type and lets you adjust parameters before sending it.
Methods
impl<'a, TDocument, TBody> RequestBuilder<'a, SearchRequestBuilder<TDocument, TBody>> where
TDocument: DeserializeOwned,
TBody: IntoBody,
[src]
TDocument: DeserializeOwned,
TBody: IntoBody,
Search request builder
A request builder for a Search query.
Call Client.search
to get a RequestBuilder
for a search request.
fn index<I>(self, index: I) -> Self where
I: Into<Index<'static>>,
I: Into<Index<'static>>,
Set the indices for the search request.
If no index is specified then _all
will be used.
fn ty<I>(self, ty: Option<I>) -> Self where
I: Into<Type<'static>>,
I: Into<Type<'static>>,
Set the types for the search request.
fn body<TNewBody>(
self,
body: TNewBody
) -> RequestBuilder<'a, SearchRequestBuilder<TDocument, TNewBody>> where
TNewBody: IntoBody,
self,
body: TNewBody
) -> RequestBuilder<'a, SearchRequestBuilder<TDocument, TNewBody>> where
TNewBody: IntoBody,
Set the body for the search request.
If no body is specified then an empty query will be used.
fn send(self) -> Result<SearchResponse<TDocument>>
Send the search request.
impl<'a, TDocument> RequestBuilder<'a, GetRequestBuilder<TDocument>> where
TDocument: DeserializeOwned + DocumentType,
[src]
TDocument: DeserializeOwned + DocumentType,
Get document builder
A request builder for a Get Document request.
Call Client.get_document
to get a RequestBuilder
for a get document request.
fn ty<I>(self, ty: I) -> Self where
I: Into<Type<'static>>,
I: Into<Type<'static>>,
Set the type for the get request.
fn send(self) -> Result<GetResponse<TDocument>>
Send the get request.
impl<'a, TDocument> RequestBuilder<'a, IndexRequestBuilder<TDocument>> where
TDocument: Serialize,
[src]
TDocument: Serialize,
Index document builder
A request builder for an Index request.
Call Client.index_document
to get a RequestBuilder
for an index request.
fn ty<I>(self, ty: I) -> Self where
I: Into<Type<'static>>,
I: Into<Type<'static>>,
Set the type for the index request.
fn send(self) -> Result<IndexResponse>
Send the index request.
impl<'a, TDocument> RequestBuilder<'a, PutMappingRequestBuilder<TDocument>> where
TDocument: DocumentType,
[src]
TDocument: DocumentType,
Put mapping builder
A request builder for a Put Mapping request.
Call Client.put_mapping
to get a RequestBuilder
for a put mapping request.
fn ty<I>(self, ty: I) -> Self where
I: Into<Type<'static>>,
I: Into<Type<'static>>,
Set the type for the put mapping request.
fn send(self) -> Result<CommandResponse>
Send the put mapping request.
impl<'a, TBody> RequestBuilder<'a, CreateIndexRequestBuilder<TBody>> where
TBody: IntoBody,
[src]
TBody: IntoBody,
Create index builder
A request builder for a Create Index request.
Call Client.create_index
to get a RequestBuilder
for a create index request.
fn body<TNewBody>(
self,
body: TNewBody
) -> RequestBuilder<'a, CreateIndexRequestBuilder<TNewBody>> where
TNewBody: IntoBody,
self,
body: TNewBody
) -> RequestBuilder<'a, CreateIndexRequestBuilder<TNewBody>> where
TNewBody: IntoBody,
Set the body for the search request.
If no body is specified then an empty query will be used.
fn send(self) -> Result<CommandResponse>
Send the create index request.
impl<'a, TRequest> RequestBuilder<'a, TRequest>
[src]
fn params<F>(self, builder: F) -> Self where
F: Fn(RequestParams) -> RequestParams,
F: Fn(RequestParams) -> RequestParams,
Override the parameters for this request.
This method will clone the RequestParams
on the Client
and pass
them to the closure.
Examples
Add a url param to force an index refresh:
let builder = client.request(get_req()) .params(|params| params.url_param("refresh", true));
The params
method is available for any request builder.
impl<'a, TRequest, TBody> RequestBuilder<'a, RawRequestBuilder<TRequest, TBody>> where
TRequest: Into<HttpRequest<'static, TBody>>,
TBody: IntoBody,
[src]
TRequest: Into<HttpRequest<'static, TBody>>,
TBody: IntoBody,
Raw request builder
A request builder for a raw request type.
Call Client.request
to get a RequestBuilder
for a raw request.
fn send(self) -> Result<ResponseBuilder>
Send this request and return the response.
This method consumes the RequestBuilder
and returns a ResponseBuilder
that can be used to parse the response.
Examples
Send a raw request and parse it to a concrete response type:
let response = client.request(get_req()) .send() .and_then(into_response::<SearchResponse<Value>>) .unwrap();