Type Definition elastic::client::requests::search::SearchRequestBuilder
[−]
[src]
type SearchRequestBuilder<TSender, TDocument, TBody> = RequestBuilder<TSender, SearchRequestInner<TDocument, TBody>>;
A search request builder that can be configured before sending.
Call Client.search
to get a SearchRequestBuilder
.
The send
method will either send the request synchronously or asynchronously, depending on the Client
it was created from.
Methods
impl<TSender, TDocument, TBody> SearchRequestBuilder<TSender, TDocument, TBody> where
TSender: Sender,
[src]
TSender: Sender,
Builder methods
Configure a SearchRequestBuilder
before sending it.
fn index<I>(self, index: I) -> Self where
I: Into<Index<'static>>,
[src]
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>>,
[src]
I: Into<Type<'static>>,
Set the types for the search request.
fn body<TNewBody>(
self,
body: TNewBody
) -> SearchRequestBuilder<TSender, TDocument, TNewBody> where
TNewBody: Into<TSender::Body>,
[src]
self,
body: TNewBody
) -> SearchRequestBuilder<TSender, TDocument, TNewBody> where
TNewBody: Into<TSender::Body>,
Set the body for the search request.
If no body is specified then an empty query will be used.
impl<TDocument, TBody> SearchRequestBuilder<SyncSender, TDocument, TBody> where
TDocument: DeserializeOwned,
TBody: Into<<SyncSender as Sender>::Body>,
[src]
TDocument: DeserializeOwned,
TBody: Into<<SyncSender as Sender>::Body>,
fn send(self) -> Result<SearchResponse<TDocument>>
[src]
Send a SearchRequestBuilder
synchronously using a SyncClient
.
This will block the current thread until a response arrives and is deserialised.
Examples
Run a simple Query String query for a DocumentType
called MyType
:
let response = client.search::<MyType>() .index("myindex") .send()?; // Iterate through the hits (of type `MyType`) for hit in response.hits() { println!("{:?}", hit); }
impl<TDocument, TBody> SearchRequestBuilder<AsyncSender, TDocument, TBody> where
TDocument: DeserializeOwned + Send + 'static,
TBody: Into<<AsyncSender as Sender>::Body>,
[src]
TDocument: DeserializeOwned + Send + 'static,
TBody: Into<<AsyncSender as Sender>::Body>,
fn send(self) -> Pending<TDocument>
[src]
Send a SearchRequestBuilder
asynchronously using an AsyncClient
.
This will return a future that will resolve to the deserialised search response.
Examples
Run a simple Query String query for a DocumentType
called MyType
:
let future = client.search::<MyType>() .index("myindex") .send(); future.and_then(|response| { // Iterate through the hits (of type `MyType`) for hit in response.hits() { println!("{:?}", hit); } Ok(()) });