Skip to content

Commit 52c74a4

Browse files
committed
Fix doctests
1 parent 2fbcdd1 commit 52c74a4

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

api_generator/docs/functions/Elasticsearch.msearch.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ for the search requests in the body. The body accepts a
66

77
```rust,no_run
88
# use elasticsearch::{Elasticsearch, Error, MsearchParts};
9+
# use elasticsearch::http::request::JsonBody;
910
# use serde_json::{json, Value};
1011
# async fn doc() -> Result<(), Box<dyn std::error::Error>> {
1112
let client = Elasticsearch::default();
@@ -37,13 +38,11 @@ let msearch_response = client
3738
let json: Value = msearch_response.json().await?;
3839
3940
// iterate over the responses
40-
for response in json["responses"]
41-
.as_array()
42-
.into_iter()
41+
for response in json["responses"].as_array().unwrap()
4342
{
4443
print_hits(response["hits"]["hits"].as_array().unwrap());
4544
}
4645
4746
# Ok(())
4847
# }
49-
```
48+
```

elasticsearch/src/root/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9617,7 +9617,7 @@ impl Elasticsearch {
96179617
pub fn mget<'a, 'b>(&'a self, parts: MgetParts<'b>) -> Mget<'a, 'b, ()> {
96189618
Mget::new(self.transport(), parts)
96199619
}
9620-
#[doc = "[Msearch API](https://www.elastic.co/guide/en/elasticsearch/reference/8.15/search-multi-search.html)\n\nAllows to execute several search operations in one request.\n\n# Examples\n\nTo make a multi-search request, specify the headers and bodies\nfor the search requests in the body. The body accepts a\n`Vec<T>` where `T` implements the [Body] trait.\n\n```rust,no_run\n# use elasticsearch::{Elasticsearch, Error, MsearchParts};\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 msearch_response = client\n .msearch(MsearchParts::None)\n .body::<JsonBody<Value>>(vec![\n json!({\"index\":\"cat_food\"}).into(),\n json!({\"query\":{\"term\":{\"name\":{\"term\":\"Whiskers\"}}}}).into(),\n json!({\"index\":\"cat_food\"}).into(),\n json!({\"query\":{\"term\":{\"name\":{\"term\":\"Chicken\"}}}}).into(),\n json!({\"index\":\"cat_food\"}).into(),\n json!({\"query\":{\"term\":{\"name\":{\"term\":\"Turkey\"}}}}).into(),\n ])\n .send()\n .await?;\n\nlet json: Value = msearch_response.json().await?;\n\n// iterate over the responses\nfor response in json[\"responses\"]\n .as_array()\n .into_iter()\n{\n print_hits(response[\"hits\"][\"hits\"].as_array().unwrap());\n}\n \n# Ok(())\n# }\n```"]
9620+
#[doc = "[Msearch API](https://www.elastic.co/guide/en/elasticsearch/reference/8.15/search-multi-search.html)\n\nAllows to execute several search operations in one request.\n\n# Examples\n\nTo make a multi-search request, specify the headers and bodies\nfor the search requests in the body. The body accepts a\n`Vec<T>` where `T` implements the [Body] trait.\n\n```rust,no_run\n# use elasticsearch::{Elasticsearch, Error, MsearchParts};\n# use elasticsearch::http::request::JsonBody;\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 msearch_response = client\n .msearch(MsearchParts::None)\n .body::<JsonBody<Value>>(vec![\n json!({\"index\":\"cat_food\"}).into(),\n json!({\"query\":{\"term\":{\"name\":{\"term\":\"Whiskers\"}}}}).into(),\n json!({\"index\":\"cat_food\"}).into(),\n json!({\"query\":{\"term\":{\"name\":{\"term\":\"Chicken\"}}}}).into(),\n json!({\"index\":\"cat_food\"}).into(),\n json!({\"query\":{\"term\":{\"name\":{\"term\":\"Turkey\"}}}}).into(),\n ])\n .send()\n .await?;\n\nlet json: Value = msearch_response.json().await?;\n\n// iterate over the responses\nfor response in json[\"responses\"].as_array().unwrap()\n{\n print_hits(response[\"hits\"][\"hits\"].as_array().unwrap());\n}\n \n# Ok(())\n# }\n```\n"]
96219621
pub fn msearch<'a, 'b>(&'a self, parts: MsearchParts<'b>) -> Msearch<'a, 'b, ()> {
96229622
Msearch::new(self.transport(), parts)
96239623
}

0 commit comments

Comments
 (0)