Type Definition elastic::client::requests::document_index::IndexRequestBuilder
[−]
[src]
type IndexRequestBuilder<TSender, TDocument> = RequestBuilder<TSender, IndexRequestInner<TDocument>>;
An index request builder that can be configured before sending.
Call Client.document_index
to get an IndexRequest
.
The send
method will either send the request synchronously or asynchronously, depending on the Client
it was created from.
Methods
impl<TSender, TDocument> IndexRequestBuilder<TSender, TDocument> where
TSender: Sender,
[src]
TSender: Sender,
Builder methods
Configure a IndexRequestBuilder
before sending it.
pub fn ty<I>(self, ty: I) -> Self where
I: Into<Type<'static>>,
[src]
I: Into<Type<'static>>,
Set the type for the index request.
impl<TDocument> IndexRequestBuilder<SyncSender, TDocument> where
TDocument: Serialize,
[src]
TDocument: Serialize,
pub fn send(self) -> Result<IndexResponse>
[src]
Send a IndexRequestBuilder
synchronously using a SyncClient
.
This will block the current thread until a response arrives and is deserialised.
Examples
Index a document with an id of 1
:
let doc = MyType { id: 1, title: String::from("A title"), timestamp: Date::now() }; let response = client.document_index(index("myindex"), id(doc.id), doc) .send()?; assert!(response.created());
impl<TDocument> IndexRequestBuilder<AsyncSender, TDocument> where
TDocument: Serialize + Send + 'static,
[src]
TDocument: Serialize + Send + 'static,
pub fn send(self) -> Pending
[src]
Send a IndexRequestBuilder
asynchronously using an AsyncClient
.
This will return a future that will resolve to the deserialised index response.
Examples
Index a document with an id of 1
:
let doc = MyType { id: 1, title: String::from("A title"), timestamp: Date::now() }; let future = client.document_index(index("myindex"), id(doc.id), doc) .send(); future.and_then(|response| { assert!(response.created()); Ok(()) });