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]

Builder methods

Configure a SearchRequestBuilder before sending it.

[src]

Set the indices for the search request.

If no index is specified then _all will be used.

[src]

Set the types for the search request.

[src]

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]

[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]

[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(())
});