Skip to content

Commit b155e33

Browse files
russcamsrikwit
andcommitted
Making changes to main and Build error in parsing response (#92)
This commit updates doc tests in README and lib.rs to use main as the fn name Co-authored-by: srikwit <4140019+srikwit@users.noreply.github.com> (cherry picked from commit 29f1c33)
1 parent 52aa039 commit b155e33

File tree

10 files changed

+58
-82
lines changed

10 files changed

+58
-82
lines changed

README.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ a JSON body of `{"query":{"match_all":{}}}`
185185
use elasticsearch::{Elasticsearch, Error, SearchParts};
186186
use serde_json::{json, Value};
187187
188-
async fn run() -> Result<(), Error> {
189-
188+
#[tokio::main]
189+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
190190
let client = Elasticsearch::default();
191-
191+
192192
// make a search API call
193193
let search_response = client
194194
.search(SearchParts::None)
@@ -200,14 +200,14 @@ async fn run() -> Result<(), Error> {
200200
.allow_no_indices(true)
201201
.send()
202202
.await?;
203-
203+
204204
// get the HTTP response status code
205205
let status_code = search_response.status_code();
206-
206+
207207
// read the response body. Consumes search_response
208-
let response_body = search_response.json::<Value>().await?;
209-
210-
// read fields from the response body
208+
let response_body = search_response.json::<Value>().await?;
209+
210+
// read fields from the response body
211211
let took = response_body["took"].as_i64().unwrap();
212212
213213
Ok(())
@@ -225,18 +225,19 @@ and beta APIs
225225
```rust,no_run
226226
use elasticsearch::{http::Method, Elasticsearch, Error, SearchParts};
227227
use http::HeaderMap;
228-
use serde_json::{json, Value};
229-
use url::Url;
228+
use serde_json::Value;
230229
231-
async fn run() -> Result<(), Error> {
230+
#[tokio::main]
231+
async fn main() -> Result<(), Box<dyn std::error::Error>> {
232232
let client = Elasticsearch::default();
233233
let body = b"{\"query\":{\"match_all\":{}}}";
234234
let response = client
235-
.send(Method::Post,
235+
.send(
236+
Method::Post,
236237
SearchParts::Index(&["tweets"]).url().as_ref(),
237238
HeaderMap::new(),
238239
Option::<&Value>::None,
239-
Some(body.as_ref())
240+
Some(body.as_ref()),
240241
)
241242
.await?;
242243
Ok(())

elasticsearch/docs/Elasticsearch.fn.scroll.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ then fetch the next set of hits using the `_scroll_id` returned in
55
the response. Once no more hits are returned, clear the scroll.
66

77
```rust,norun
8-
# use elasticsearch::{Elasticsearch, SearchParts, ScrollParts, ClearScrollParts};
8+
# use elasticsearch::{Elasticsearch, Error, SearchParts, ScrollParts, ClearScrollParts};
99
# use serde_json::{json, Value};
10-
# async fn run() -> Result<(), Box<dyn std::error::Error>> {
11-
# let client = Elasticsearch::default();
10+
# async fn doc() -> Result<(), Box<dyn std::error::Error>> {
11+
let client = Elasticsearch::default();
12+
1213
fn print_hits(hits: &[Value]) {
1314
for hit in hits {
1415
println!(

elasticsearch/docs/Indices.fn.create.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
Create an index with a mapping
44

55
```rust,norun
6-
# use elasticsearch::{Elasticsearch, indices::IndicesCreateParts};
6+
# use elasticsearch::{Elasticsearch, Error, indices::IndicesCreateParts};
77
# use serde_json::{json, Value};
8-
# async fn run() -> Result<(), Box<dyn std::error::Error>> {
9-
# let client = Elasticsearch::default();
8+
# async fn doc() -> Result<(), Box<dyn std::error::Error>> {
9+
let client = Elasticsearch::default();
1010
let response = client
1111
.indices()
1212
.create(IndicesCreateParts::Index("test_index"))

elasticsearch/docs/Indices.fn.put_mapping.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ Put a mapping into an existing index, assuming the index does not have a mapping
44
or that any properties specified do not conflict with existing properties
55

66
```rust,norun
7-
# use elasticsearch::{Elasticsearch, indices::IndicesPutMappingParts};
7+
# use elasticsearch::{Elasticsearch, Error, indices::IndicesPutMappingParts};
88
# use serde_json::{json, Value};
9-
# async fn run() -> Result<(), Box<dyn std::error::Error>> {
10-
# let client = Elasticsearch::default();
9+
# async fn doc() -> Result<(), Box<dyn std::error::Error>> {
10+
let client = Elasticsearch::default();
1111
let response = client
1212
.indices()
1313
.put_mapping(IndicesPutMappingParts::Index(&["test_index"]))

elasticsearch/src/cat/mod.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
//! and accept headers, returning plain text responses
1111
//!
1212
//! ```rust,no_run
13-
//! # use elasticsearch;
1413
//! # use elasticsearch::{Elasticsearch, Error, SearchParts};
1514
//! # use url::Url;
1615
//! # use elasticsearch::auth::Credentials;
1716
//! # use serde_json::{json, Value};
18-
//! # async fn run() -> Result<(), Error> {
17+
//! # async fn doc() -> Result<(), Box<dyn std::error::Error>> {
1918
//! # let client = Elasticsearch::default();
2019
//! let response = client
2120
//! .cat()
@@ -33,12 +32,11 @@
3332
//! JSON responses can be returned from Cat APIs either by using `.format("json")`
3433
//!
3534
//! ```rust,no_run
36-
//! # use elasticsearch;
3735
//! # use elasticsearch::{Elasticsearch, Error, SearchParts};
3836
//! # use url::Url;
3937
//! # use elasticsearch::auth::Credentials;
4038
//! # use serde_json::{json, Value};
41-
//! # async fn run() -> Result<(), Error> {
39+
//! # async fn doc() -> Result<(), Box<dyn std::error::Error>> {
4240
//! # let client = Elasticsearch::default();
4341
//! let response = client
4442
//! .cat()
@@ -55,12 +53,10 @@
5553
//! Or by setting an accept header using `.headers()`
5654
//!
5755
//! ```rust,no_run
58-
//! # use elasticsearch;
5956
//! # use elasticsearch::{Elasticsearch, Error, SearchParts, http::headers::{HeaderValue, DEFAULT_ACCEPT, ACCEPT}};
6057
//! # use url::Url;
61-
//! # use elasticsearch::auth::Credentials;
6258
//! # use serde_json::{json, Value};
63-
//! # async fn run() -> Result<(), Error> {
59+
//! # async fn doc() -> Result<(), Box<dyn std::error::Error>> {
6460
//! # let client = Elasticsearch::default();
6561
//! let response = client
6662
//! .cat()
@@ -79,12 +75,10 @@
7975
//! The column headers to return can be controlled with `.h()`
8076
//!
8177
//! ```rust,no_run
82-
//! # use elasticsearch;
8378
//! # use elasticsearch::{Elasticsearch, Error, SearchParts};
8479
//! # use url::Url;
85-
//! # use elasticsearch::auth::Credentials;
8680
//! # use serde_json::{json, Value};
87-
//! # async fn run() -> Result<(), Error> {
81+
//! # async fn doc() -> Result<(), Box<dyn std::error::Error>> {
8882
//! # let client = Elasticsearch::default();
8983
//! let response = client
9084
//! .cat()
@@ -98,6 +92,5 @@
9892
//! # }
9993
//! ```
10094
//!
101-
//!
10295
10396
pub use super::generated::namespace_clients::cat::*;

elasticsearch/src/cert.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub use reqwest::Certificate;
3232
# use std::fs::File;
3333
# use std::io::Read;
3434
# use url::Url;
35-
# async fn run() -> Result<(), Error> {
35+
# async fn doc() -> Result<(), Box<dyn std::error::Error>> {
3636
let url = Url::parse("https://example.com")?;
3737
let conn_pool = SingleNodeConnectionPool::new(url);
3838
@@ -71,7 +71,7 @@ let _response = client.ping().send().await?;
7171
# use std::fs::File;
7272
# use std::io::Read;
7373
# use url::Url;
74-
# async fn run() -> Result<(), Error> {
74+
# async fn doc() -> Result<(), Box<dyn std::error::Error>> {
7575
let url = Url::parse("https://example.com")?;
7676
let conn_pool = SingleNodeConnectionPool::new(url);
7777
@@ -105,7 +105,7 @@ let _response = client.ping().send().await?;
105105
/// # use std::fs::File;
106106
/// # use std::io::Read;
107107
/// # use url::Url;
108-
/// # async fn run() -> Result<(), Error> {
108+
/// # async fn doc() -> Result<(), Box<dyn std::error::Error>> {
109109
/// let url = Url::parse("https://example.com")?;
110110
/// let conn_pool = SingleNodeConnectionPool::new(url);
111111
/// let transport = TransportBuilder::new(conn_pool)

elasticsearch/src/generated/namespace_clients/indices.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7722,7 +7722,7 @@ impl<'a> Indices<'a> {
77227722
pub fn close<'b>(&'a self, parts: IndicesCloseParts<'b>) -> IndicesClose<'a, 'b, ()> {
77237723
IndicesClose::new(&self.client, parts)
77247724
}
7725-
#[doc = "[Indices Create API](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/indices-create-index.html)\n\nCreates an index with optional settings and mappings.\n\n# Examples\n\nCreate an index with a mapping\n\n```rust,norun\n# use elasticsearch::{Elasticsearch, indices::IndicesCreateParts};\n# use serde_json::{json, Value};\n# async fn run() -> Result<(), Box<dyn std::error::Error>> { \n# let client = Elasticsearch::default();\nlet response = client\n .indices()\n .create(IndicesCreateParts::Index(\"test_index\"))\n .body(json!({\n \"mappings\" : {\n \"properties\" : {\n \"field1\" : { \"type\" : \"text\" }\n }\n }\n }))\n .send()\n .await?;\n \n# Ok(())\n# }\n```"]
7725+
#[doc = "[Indices Create API](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/indices-create-index.html)\n\nCreates an index with optional settings and mappings.\n\n# Examples\n\nCreate an index with a mapping\n\n```rust,norun\n# use elasticsearch::{Elasticsearch, Error, indices::IndicesCreateParts};\n# use serde_json::{json, Value};\n# async fn doc() -> Result<(), Box<dyn std::error::Error>> {\nlet client = Elasticsearch::default();\nlet response = client\n .indices()\n .create(IndicesCreateParts::Index(\"test_index\"))\n .body(json!({\n \"mappings\" : {\n \"properties\" : {\n \"field1\" : { \"type\" : \"text\" }\n }\n }\n }))\n .send()\n .await?;\n \n# Ok(())\n# }\n```"]
77267726
pub fn create<'b>(&'a self, parts: IndicesCreateParts<'b>) -> IndicesCreate<'a, 'b, ()> {
77277727
IndicesCreate::new(&self.client, parts)
77287728
}
@@ -7842,7 +7842,7 @@ impl<'a> Indices<'a> {
78427842
pub fn put_alias<'b>(&'a self, parts: IndicesPutAliasParts<'b>) -> IndicesPutAlias<'a, 'b, ()> {
78437843
IndicesPutAlias::new(&self.client, parts)
78447844
}
7845-
#[doc = "[Indices Put Mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/indices-put-mapping.html)\n\nUpdates the index mappings.\n\n# Examples\n\nPut a mapping into an existing index, assuming the index does not have a mapping, \nor that any properties specified do not conflict with existing properties\n\n```rust,norun\n# use elasticsearch::{Elasticsearch, indices::IndicesPutMappingParts};\n# use serde_json::{json, Value};\n# async fn run() -> Result<(), Box<dyn std::error::Error>> { \n# let client = Elasticsearch::default();\nlet response = client\n .indices()\n .put_mapping(IndicesPutMappingParts::Index(&[\"test_index\"]))\n .body(json!({\n \"properties\" : {\n \"field1\" : { \"type\" : \"text\" }\n }\n }))\n .send()\n .await?;\n \n# Ok(())\n# }\n```"]
7845+
#[doc = "[Indices Put Mapping API](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/indices-put-mapping.html)\n\nUpdates the index mappings.\n\n# Examples\n\nPut a mapping into an existing index, assuming the index does not have a mapping, \nor that any properties specified do not conflict with existing properties\n\n```rust,norun\n# use elasticsearch::{Elasticsearch, Error, indices::IndicesPutMappingParts};\n# use serde_json::{json, Value};\n# async fn doc() -> Result<(), Box<dyn std::error::Error>> {\nlet client = Elasticsearch::default();\nlet response = client\n .indices()\n .put_mapping(IndicesPutMappingParts::Index(&[\"test_index\"]))\n .body(json!({\n \"properties\" : {\n \"field1\" : { \"type\" : \"text\" }\n }\n }))\n .send()\n .await?;\n \n# Ok(())\n# }\n```"]
78467846
pub fn put_mapping<'b>(
78477847
&'a self,
78487848
parts: IndicesPutMappingParts<'b>,

elasticsearch/src/generated/root.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8501,7 +8501,7 @@ impl Elasticsearch {
85018501
) -> RenderSearchTemplate<'a, 'b, ()> {
85028502
RenderSearchTemplate::new(&self, parts)
85038503
}
8504-
#[doc = "[Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-request-body.html#request-body-search-scroll)\n\nAllows to retrieve a large numbers of results from a single search request.\n\n# Examples\n\nTo initiate a scroll, make search API call with a specified `scroll` timeout,\nthen fetch the next set of hits using the `_scroll_id` returned in\nthe response. Once no more hits are returned, clear the scroll.\n\n```rust,norun\n# use elasticsearch::{Elasticsearch, SearchParts, ScrollParts, ClearScrollParts};\n# use serde_json::{json, Value};\n# async fn run() -> Result<(), Box<dyn std::error::Error>> { \n# let client = Elasticsearch::default();\nfn print_hits(hits: &[Value]) {\n for hit in hits {\n println!(\n \"id: '{}', source: '{}', score: '{}'\",\n hit[\"_id\"].as_str().unwrap(),\n hit[\"_source\"],\n hit[\"_score\"].as_f64().unwrap()\n );\n }\n}\n\nlet scroll = \"1m\";\nlet mut response = client\n .search(SearchParts::Index(&[\"tweets\"]))\n .scroll(scroll)\n .body(json!({\n \"query\": {\n \"match\": {\n \"body\": {\n \"query\": \"Elasticsearch rust\",\n \"operator\": \"AND\"\n }\n }\n }\n }))\n .send()\n .await?;\n\nlet mut response_body = response.json::<Value>().await?;\nlet mut scroll_id = response_body[\"_scroll_id\"].as_str().unwrap();\nlet mut hits = response_body[\"hits\"][\"hits\"].as_array().unwrap();\n\nprint_hits(hits);\n\nwhile hits.len() > 0 {\n response = client\n .scroll(ScrollParts::None)\n .body(json!({\n \"scroll\": scroll,\n \"scroll_id\": scroll_id\n }))\n .send()\n .await?;\n\n response_body = response.json::<Value>().await?;\n scroll_id = response_body[\"_scroll_id\"].as_str().unwrap();\n hits = response_body[\"hits\"][\"hits\"].as_array().unwrap();\n print_hits(hits);\n}\n\nresponse = client\n .clear_scroll(ClearScrollParts::None)\n .body(json!({\n \"scroll_id\": scroll_id\n }))\n .send()\n .await?;\n \n# Ok(())\n# }\n```"]
8504+
#[doc = "[Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-request-body.html#request-body-search-scroll)\n\nAllows to retrieve a large numbers of results from a single search request.\n\n# Examples\n\nTo initiate a scroll, make search API call with a specified `scroll` timeout,\nthen fetch the next set of hits using the `_scroll_id` returned in\nthe response. Once no more hits are returned, clear the scroll.\n\n```rust,norun\n# use elasticsearch::{Elasticsearch, Error, SearchParts, ScrollParts, ClearScrollParts};\n# use serde_json::{json, Value};\n# async fn doc() -> Result<(), Box<dyn std::error::Error>> {\nlet client = Elasticsearch::default();\n\nfn print_hits(hits: &[Value]) {\n for hit in hits {\n println!(\n \"id: '{}', source: '{}', score: '{}'\",\n hit[\"_id\"].as_str().unwrap(),\n hit[\"_source\"],\n hit[\"_score\"].as_f64().unwrap()\n );\n }\n}\n\nlet scroll = \"1m\";\nlet mut response = client\n .search(SearchParts::Index(&[\"tweets\"]))\n .scroll(scroll)\n .body(json!({\n \"query\": {\n \"match\": {\n \"body\": {\n \"query\": \"Elasticsearch rust\",\n \"operator\": \"AND\"\n }\n }\n }\n }))\n .send()\n .await?;\n\nlet mut response_body = response.json::<Value>().await?;\nlet mut scroll_id = response_body[\"_scroll_id\"].as_str().unwrap();\nlet mut hits = response_body[\"hits\"][\"hits\"].as_array().unwrap();\n\nprint_hits(hits);\n\nwhile hits.len() > 0 {\n response = client\n .scroll(ScrollParts::None)\n .body(json!({\n \"scroll\": scroll,\n \"scroll_id\": scroll_id\n }))\n .send()\n .await?;\n\n response_body = response.json::<Value>().await?;\n scroll_id = response_body[\"_scroll_id\"].as_str().unwrap();\n hits = response_body[\"hits\"][\"hits\"].as_array().unwrap();\n print_hits(hits);\n}\n\nresponse = client\n .clear_scroll(ClearScrollParts::None)\n .body(json!({\n \"scroll_id\": scroll_id\n }))\n .send()\n .await?;\n \n# Ok(())\n# }\n```"]
85058505
pub fn scroll<'a, 'b>(&'a self, parts: ScrollParts<'b>) -> Scroll<'a, 'b, ()> {
85068506
Scroll::new(&self, parts)
85078507
}

elasticsearch/src/lib.rs

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,10 @@
8888
//! To create a client to make API calls to Elasticsearch running on `http://localhost:9200`
8989
//!
9090
//! ```rust,no_run
91-
//! # use elasticsearch::{Error, Elasticsearch};
92-
//! # fn run() {
91+
//! # use elasticsearch::Elasticsearch;
9392
//! let client = Elasticsearch::default();
94-
//! # }
9593
//! ```
94+
//!
9695
//! Alternatively, you can create a client to make API calls against Elasticsearch running on a
9796
//! specific [url::Url]
9897
//!
@@ -101,7 +100,7 @@
101100
//! # Error, Elasticsearch,
102101
//! # http::transport::{Transport, SingleNodeConnectionPool}
103102
//! # };
104-
//! # fn run() -> Result<(), Error> {
103+
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
105104
//! let transport = Transport::single_node("https://example.com")?;
106105
//! let client = Elasticsearch::new(transport);
107106
//! # Ok(())
@@ -119,7 +118,7 @@
119118
//! # http::transport::Transport,
120119
//! # };
121120
//! # use url::Url;
122-
//! # fn run() -> Result<(), Error> {
121+
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
123122
//! let cloud_id = "cluster_name:Y2xvdWQtZW5kcG9pbnQuZXhhbXBsZSQzZGFkZjgyM2YwNTM4ODQ5N2VhNjg0MjM2ZDkxOGExYQ==";
124123
//! let credentials = Credentials::Basic("<username>".into(), "<password>".into());
125124
//! let transport = Transport::cloud(cloud_id, credentials)?;
@@ -139,7 +138,7 @@
139138
//! # http::transport::{TransportBuilder,SingleNodeConnectionPool},
140139
//! # };
141140
//! # use url::Url;
142-
//! # fn run() -> Result<(), Error> {
141+
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
143142
//! let url = Url::parse("https://example.com")?;
144143
//! let conn_pool = SingleNodeConnectionPool::new(url);
145144
//! let transport = TransportBuilder::new(conn_pool).disable_proxy().build()?;
@@ -157,12 +156,11 @@
157156
//! The following makes an API call to the cat indices API
158157
//!
159158
//! ```rust,no_run
160-
//! # use elasticsearch;
161-
//! # use elasticsearch::{Elasticsearch, Error, cat::CatIndicesParts};
159+
//! # use elasticsearch::{auth::Credentials, Elasticsearch, Error, cat::CatIndicesParts};
162160
//! # use url::Url;
163-
//! # use elasticsearch::auth::Credentials;
164161
//! # use serde_json::{json, Value};
165-
//! # async fn run() -> Result<(), Error> {
162+
//! # #[tokio::main]
163+
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
166164
//! # let client = Elasticsearch::default();
167165
//! let response = client
168166
//! .cat()
@@ -187,12 +185,11 @@
187185
//! Indexing a single document can be achieved with the index API
188186
//!
189187
//! ```rust,no_run
190-
//! # use elasticsearch;
191-
//! # use elasticsearch::{Elasticsearch, Error, SearchParts, IndexParts};
188+
//! # use elasticsearch::{auth::Credentials, Elasticsearch, Error, SearchParts, IndexParts};
192189
//! # use url::Url;
193-
//! # use elasticsearch::auth::Credentials;
194190
//! # use serde_json::{json, Value};
195-
//! # async fn run() -> Result<(), Error> {
191+
//! # #[tokio::main]
192+
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
196193
//! # let client = Elasticsearch::default();
197194
//! let response = client
198195
//! .index(IndexParts::IndexId("tweets", "1"))
@@ -214,12 +211,11 @@
214211
//! to be sent in one API call
215212
//!
216213
//! ```rust,no_run
217-
//! # use elasticsearch;
218-
//! # use elasticsearch::{Elasticsearch, Error, IndexParts, BulkParts, http::request::JsonBody};
214+
//! # use elasticsearch::{auth::Credentials, Elasticsearch, Error, IndexParts, BulkParts, http::request::JsonBody};
219215
//! # use url::Url;
220-
//! # use elasticsearch::auth::Credentials;
221216
//! # use serde_json::{json, Value};
222-
//! # async fn run() -> Result<(), Error> {
217+
//! # #[tokio::main]
218+
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
223219
//! # let client = Elasticsearch::default();
224220
//! let mut body: Vec<JsonBody<_>> = Vec::with_capacity(4);
225221
//!
@@ -258,12 +254,11 @@
258254
//! `{"query":{"match":{"message":"Elasticsearch"}}}`
259255
//!
260256
//! ```rust,no_run
261-
//! # use elasticsearch;
262-
//! # use elasticsearch::{Elasticsearch, Error, SearchParts};
257+
//! # use elasticsearch::{auth::Credentials, Elasticsearch, Error, SearchParts};
263258
//! # use url::Url;
264-
//! # use elasticsearch::auth::Credentials;
265259
//! # use serde_json::{json, Value};
266-
//! # async fn run() -> Result<(), Error> {
260+
//! # #[tokio::main]
261+
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
267262
//! # let client = Elasticsearch::default();
268263
//! let response = client
269264
//! .search(SearchParts::Index(&["tweets"]))
@@ -306,14 +301,11 @@
306301
//! [Elasticsearch::send] can be used
307302
//!
308303
//! ```rust,no_run
309-
//! # use elasticsearch;
310-
//! # use elasticsearch::{Elasticsearch, Error, SearchParts};
304+
//! # use elasticsearch::{auth::Credentials, http::{Method,headers::HeaderMap}, Elasticsearch, Error, SearchParts};
311305
//! # use url::Url;
312-
//! # use elasticsearch::auth::Credentials;
313306
//! # use serde_json::{json, Value};
314-
//! # use http::HeaderMap;
315-
//! # use elasticsearch::http::Method;
316-
//! # async fn run() -> Result<(), Error> {
307+
//! # #[tokio::main]
308+
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
317309
//! # let client = Elasticsearch::default();
318310
//! let body = b"{\"query\":{\"match_all\":{}}}";
319311
//!

0 commit comments

Comments
 (0)