Skip to main content

opensearch_client/client/
mod.rs

1use std::collections::HashMap;
2/*
3 * opensearch-client
4 *
5 * Rust Client for OpenSearch
6 *
7 * The version of the OpenAPI document: 3.1.0
8 * Contact: alberto.paro@gmail.com
9 * Generated by Paro OpenAPI Generator
10 */
11
12use futures::stream::{self, StreamExt};
13use std::error;
14use std::fmt;
15use tokio::task::JoinHandle;
16pub mod auth_middleware;
17pub mod credentials;
18use crate::bulk::*;
19use crate::bulker::Bulker;
20use crate::bulker::BulkerBuilder;
21use crate::common;
22use crate::common::*;
23use bon::bon;
24use futures::Stream;
25use opensearch_dsl::Query;
26use opensearch_dsl::SortCollection;
27use serde::de::DeserializeOwned;
28use serde::Serialize;
29use thiserror::Error;
30use url::Url;
31
32pub trait Request {
33    type Response: DeserializeOwned + Send + Sync;
34    fn method(&self) -> reqwest::Method;
35    fn path(&self) -> Result<String, Error>;
36    fn body(&self) -> Result<Option<String>, Error>;
37    fn query_args(&self) -> Result<Option<HashMap<String, String>>, Error>;
38    fn url(&self, base_url: &Url) -> Result<Url, Error> {
39        let mut url = base_url.clone();
40        url.set_path(&self.path()?);
41        if let Some(query_args) = self.query_args()? {
42            url.query_pairs_mut()
43                .clear()
44                .extend_pairs(query_args.iter());
45        }
46        Ok(url)
47    }
48}
49
50#[derive(Debug, Clone)]
51pub struct ResponseContent {
52    pub status: reqwest::StatusCode,
53    pub content: String,
54}
55
56impl fmt::Display for ResponseContent {
57    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58        write!(
59            f,
60            "ResponseContent {{ status: {}, content: {} }}",
61            self.status, self.content
62        )
63    }
64}
65
66#[derive(Debug, Error)]
67pub enum Error {
68    #[error("Document Already Exists: ({0},{1})")]
69    DocumentAlreadyExistsError(String, String),
70    #[error("Not found: ({0},{1})")]
71    DocumentNotFoundError(String, String),
72    /// An expected response code whose deserialization failed.
73    #[error(transparent)]
74    InvalidResponsePayload(#[from] reqwest::Error),
75    /// A server error either due to the data, or with the connection.
76    #[error(transparent)]
77    CommunicationError(#[from] reqwest_middleware::Error),
78    #[error(transparent)]
79    Serde(#[from] serde_json::Error),
80    /// An invalid URL was provided.
81    #[error(transparent)]
82    UrlParseError(#[from] url::ParseError),
83    #[error(transparent)]
84    Io(#[from] std::io::Error),
85    /// There is an error in provided credentials.
86    #[error("Credential error: {0}")]
87    CredentialsConfigError(String),
88    #[error("ApiError: {0}")]
89    ApiError(ResponseContent),
90    #[error("UnexpectedStatusCode: {0}")]
91    UnexpectedStatusCode(reqwest::StatusCode),
92    #[error("Internal Error: {0}")]
93    InternalError(String),
94}
95
96#[cfg(feature = "loco")]
97impl From<Error> for loco_rs::prelude::Error {
98    fn from(err: Error) -> Self {
99        use axum::http::StatusCode;
100        use loco_rs::controller::ErrorDetail;
101        use loco_rs::prelude::Error as LocoError;
102        match err {
103            Error::DocumentAlreadyExistsError(_, _) => LocoError::InternalServerError,
104            Error::DocumentNotFoundError(index, id) => LocoError::CustomError(
105                StatusCode::NOT_FOUND,
106                ErrorDetail::new("Error", &format!("Document not found: ({}, {})", index, id)),
107            ),
108            _ => LocoError::CustomError(
109                StatusCode::INTERNAL_SERVER_ERROR,
110                ErrorDetail::new("OpenSearch Error", &err.to_string()),
111            ),
112        }
113    }
114}
115pub fn urlencode<T: AsRef<str>>(s: T) -> String {
116    ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
117}
118
119pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
120    if let serde_json::Value::Object(object) = value {
121        let mut params = vec![];
122
123        for (key, value) in object {
124            match value {
125                serde_json::Value::Object(_) => params.append(&mut parse_deep_object(
126                    &format!("{}[{}]", prefix, key),
127                    value,
128                )),
129                serde_json::Value::Array(array) => {
130                    for (i, value) in array.iter().enumerate() {
131                        params.append(&mut parse_deep_object(
132                            &format!("{}[{}][{}]", prefix, key, i),
133                            value,
134                        ));
135                    }
136                }
137                serde_json::Value::String(s) => {
138                    params.push((format!("{}[{}]", prefix, key), s.clone()))
139                }
140                _ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
141            }
142        }
143
144        return params;
145    }
146
147    unimplemented!("Only objects are supported with style=deepObject")
148}
149
150/// Internal use only
151/// A content type supported by this client.
152#[allow(dead_code)]
153pub enum ContentType {
154    Json,
155    Text,
156    Unsupported(String),
157}
158
159impl From<&str> for ContentType {
160    fn from(content_type: &str) -> Self {
161        if content_type.starts_with("application") && content_type.contains("json") {
162            return Self::Json;
163        } else if content_type.starts_with("text/plain") {
164            return Self::Text;
165        } else {
166            return Self::Unsupported(content_type.to_string());
167        }
168    }
169}
170
171pub mod configuration;
172
173use std::sync::Arc;
174
175use crate::ConfigurationBuilder;
176
177#[derive(Clone)]
178pub struct OsClient {
179    configuration: Arc<crate::Configuration>,
180    // common_api: crate::common::CommonApi,
181    #[cfg(feature = "asynchronous_search")]
182    asynchronous_search_api: Arc<crate::asynchronous_search::AsynchronousSearchApi>,
183    #[cfg(feature = "cat")]
184    cat_api: Arc<crate::cat::CatApi>,
185    #[cfg(feature = "cluster")]
186    cluster_api: Arc<crate::cluster::ClusterApiClient>,
187    #[cfg(feature = "dangling_indices")]
188    dangling_indices_api: Arc<crate::dangling_indices::DanglingIndicesApi>,
189    #[cfg(feature = "indices")]
190    indices_api: Arc<crate::indices::IndicesApiClient>,
191    #[cfg(feature = "ingest")]
192    ingest_api: Arc<crate::ingest::IngestApiClient>,
193    #[cfg(feature = "insights")]
194    insights_api: Arc<crate::insights::InsightsApi>,
195    #[cfg(feature = "ism")]
196    ism_api: Arc<crate::ism::IsmApi>,
197    #[cfg(feature = "knn")]
198    knn_api: Arc<crate::knn::KnnApi>,
199    #[cfg(feature = "ml")]
200    ml_api: Arc<crate::ml::MlApiClient>,
201    #[cfg(feature = "nodes")]
202    nodes_api: Arc<crate::nodes::NodesApi>,
203    #[cfg(feature = "notifications")]
204    notifications_api: Arc<crate::notifications::NotificationsApi>,
205    #[cfg(feature = "observability")]
206    observability_api: Arc<crate::observability::ObservabilityApi>,
207    #[cfg(feature = "ppl")]
208    ppl_api: Arc<crate::ppl::PplApi>,
209    #[cfg(feature = "remote_store")]
210    remote_store_api: Arc<crate::remote_store::RemoteStoreApi>,
211    #[cfg(feature = "replication")]
212    replication_api: Arc<crate::replication::ReplicationApi>,
213    #[cfg(feature = "rollups")]
214    rollups_api: Arc<crate::rollups::RollupsApi>,
215    #[cfg(feature = "security")]
216    security_api: Arc<crate::security::SecurityApi>,
217    #[cfg(feature = "snapshot")]
218    snapshot_api: Arc<crate::snapshot::SnapshotApi>,
219    #[cfg(feature = "sql")]
220    sql_api: Arc<crate::sql::SqlApi>,
221    #[cfg(feature = "tasks")]
222    tasks_api: Arc<crate::tasks::TasksApi>,
223    #[cfg(feature = "transforms")]
224    transforms_api: Arc<crate::transforms::TransformsApi>,
225}
226
227#[bon]
228impl OsClient {
229    pub fn new(configuration: Arc<crate::Configuration>) -> Self {
230        Self {
231            configuration: configuration.clone(),
232            #[cfg(feature = "asynchronous_search")]
233            asynchronous_search_api: Arc::new(
234                asynchronous_search::AsynchronousSearchApiClient::new(configuration.clone()),
235            ),
236            #[cfg(feature = "cat")]
237            cat_api: Arc::new(crate::cat::CatApiClient::new(configuration.clone())),
238            // common_api: Arc::new(crate::common::CommonApi::new(configuration.clone())),
239            #[cfg(feature = "cluster")]
240            cluster_api: Arc::new(crate::cluster::ClusterApiClient::new(configuration.clone())),
241            #[cfg(feature = "dangling_indices")]
242            dangling_indices_api: Arc::new(crate::dangling_indices::DanglingIndicesApiClient::new(
243                configuration.clone(),
244            )),
245            #[cfg(feature = "indices")]
246            indices_api: Arc::new(crate::indices::IndicesApiClient::new(configuration.clone())),
247            #[cfg(feature = "ingest")]
248            ingest_api: Arc::new(crate::ingest::IngestApiClient::new(configuration.clone())),
249            #[cfg(feature = "insights")]
250            insights_api: Arc::new(crate::insights::InsightsApiClient::new(
251                configuration.clone(),
252            )),
253            #[cfg(feature = "ism")]
254            ism_api: Arc::new(crate::ism::IsmApiClient::new(configuration.clone())),
255            #[cfg(feature = "knn")]
256            knn_api: Arc::new(crate::knn::KnnApiClient::new(configuration.clone())),
257            #[cfg(feature = "ml")]
258            ml_api: Arc::new(crate::ml::MlApiClient::new(configuration.clone())),
259            #[cfg(feature = "nodes")]
260            nodes_api: Arc::new(crate::nodes::NodesApiClient::new(configuration.clone())),
261            #[cfg(feature = "notifications")]
262            notifications_api: Arc::new(notifications::NotificationsApiClient::new(
263                configuration.clone(),
264            )),
265            #[cfg(feature = "observability")]
266            observability_api: Arc::new(observability::ObservabilityApiClient::new(
267                configuration.clone(),
268            )),
269            #[cfg(feature = "ppl")]
270            ppl_api: Arc::new(crate::ppl::PplApiClient::new(configuration.clone())),
271            #[cfg(feature = "remote_store")]
272            remote_store_api: Arc::new(remote_store::RemoteStoreApiClient::new(
273                configuration.clone(),
274            )),
275            #[cfg(feature = "replication")]
276            replication_api: Arc::new(replication::ReplicationApiClient::new(
277                configuration.clone(),
278            )),
279            #[cfg(feature = "rollups")]
280            rollups_api: Arc::new(crate::rollups::RollupsApiClient::new(configuration.clone())),
281            #[cfg(feature = "security")]
282            security_api: Arc::new(crate::security::SecurityApiClient::new(
283                configuration.clone(),
284            )),
285            #[cfg(feature = "snapshot")]
286            snapshot_api: Arc::new(crate::snapshot::SnapshotApiClient::new(
287                configuration.clone(),
288            )),
289            #[cfg(feature = "sql")]
290            sql_api: Arc::new(crate::sql::SqlApiClient::new(configuration.clone())),
291            #[cfg(feature = "tasks")]
292            tasks_api: Arc::new(crate::tasks::TasksApiClient::new(configuration.clone())),
293            #[cfg(feature = "transforms")]
294            transforms_api: Arc::new(crate::transforms::TransformsApiClient::new(
295                configuration.clone(),
296            )),
297        }
298    }
299    pub fn from_environment() -> Result<OsClient, Error> {
300        let accept_invalid_certificates: bool = match std::env::var("OPENSEARCH_SSL_VERIFY") {
301            Ok(value) => value.eq_ignore_ascii_case("false"),
302            Err(_) => false,
303        };
304        let user: String = match std::env::var("OPENSEARCH_USER") {
305            Ok(user) => user,
306            Err(_) => "admin".into(),
307        };
308        let password: String = match std::env::var("OPENSEARCH_PASSWORD") {
309            Ok(password) => password,
310            Err(_) => "admin".into(),
311        };
312
313        let server = match std::env::var("OPENSEARCH_URL") {
314            Ok(server) => server,
315            Err(_) => "https://localhost:9200".into(),
316        };
317
318        let mut builder = ConfigurationBuilder::new().base_url(Url::parse(&server)?);
319        if accept_invalid_certificates {
320            builder = builder.accept_invalid_certificates(true);
321        }
322        builder = builder.basic_auth(user, password);
323
324        if let Ok(max_bulk_size) = std::env::var("OPENSEARCH_MAX_BULK_SIZE") {
325            match max_bulk_size.parse::<u32>() {
326                Ok(max_bulk_size) => builder = builder.max_bulk_size(max_bulk_size),
327                Err(_) => {
328                    tracing::info!("Invalid value for OPENSEARCH_MAX_BULK_SIZE, using default")
329                }
330            }
331        };
332
333        Ok(builder.build())
334    }
335
336    #[cfg(feature = "quickwit")]
337    pub fn from_quickwit_environment() -> Result<OsClient, Error> {
338        let accept_invalid_certificates: bool = match std::env::var("QUICKWIT_SSL_VERIFY") {
339            Ok(value) => value.eq_ignore_ascii_case("false"),
340            Err(_) => false,
341        };
342
343        let mut server = match std::env::var("QUICKWIT_URL") {
344            Ok(server) => server,
345            Err(_) => "http://localhost:7280".into(),
346        };
347        // api/v1/_elastic
348        if !server.ends_with("/api/v1/_elastic") {
349            server.push_str("/api/v1/_elastic");
350        }
351
352        let mut builder = ConfigurationBuilder::new().base_url(Url::parse(&server)?);
353        if accept_invalid_certificates {
354            builder = builder.accept_invalid_certificates(true);
355        }
356
357        if let Ok(max_bulk_size) = std::env::var("QUICKWIT_MAX_BULK_SIZE") {
358            match max_bulk_size.parse::<u32>() {
359                Ok(max_bulk_size) => builder = builder.max_bulk_size(max_bulk_size),
360                Err(_) => info!("Invalid value for QUICKWIT_MAX_BULK_SIZE, using default"),
361            }
362        };
363
364        Ok(builder.build())
365    }
366
367    // pub fn core(&self) -> &crate::common::CommonApi {
368    //     &self.common_api
369    // }
370
371    #[cfg(feature = "indices")]
372    pub fn indices(&self) -> &crate::indices::IndicesApiClient {
373        &self.indices_api
374    }
375    #[cfg(feature = "cluster")]
376    pub fn cluster(&self) -> &crate::cluster::ClusterApiClient {
377        &self.cluster_api
378    }
379    #[cfg(feature = "asynchronous_search")]
380    pub fn asynchronous_search(&self) -> &crate::asynchronous_search::AsynchronousSearchApi {
381        &self.asynchronous_search_api
382    }
383    #[cfg(feature = "cat")]
384    pub fn cat(&self) -> &crate::cat::CatApi {
385        &self.cat_api
386    }
387    #[cfg(feature = "dangling_indices")]
388    pub fn dangling_indices(&self) -> &crate::dangling_indices::DanglingIndicesApi {
389        &self.dangling_indices_api
390    }
391    #[cfg(feature = "ingest")]
392    pub fn ingest(&self) -> &crate::ingest::IngestApiClient {
393        &self.ingest_api
394    }
395    #[cfg(feature = "insights")]
396    pub fn insights(&self) -> &crate::insights::InsightsApi {
397        &self.insights_api
398    }
399    #[cfg(feature = "ism")]
400    pub fn ism(&self) -> &crate::ism::IsmApi {
401        &self.ism_api
402    }
403    #[cfg(feature = "knn")]
404    pub fn knn(&self) -> &crate::knn::KnnApi {
405        &self.knn_api
406    }
407    #[cfg(feature = "ml")]
408    pub fn ml(&self) -> &crate::ml::MlApiClient {
409        &self.ml_api
410    }
411    #[cfg(feature = "nodes")]
412    pub fn nodes(&self) -> &crate::nodes::NodesApi {
413        &self.nodes_api
414    }
415    #[cfg(feature = "notifications")]
416    pub fn notifications(&self) -> &crate::notifications::NotificationsApi {
417        &self.notifications_api
418    }
419    #[cfg(feature = "observability")]
420    pub fn observability(&self) -> &crate::observability::ObservabilityApi {
421        &self.observability_api
422    }
423    #[cfg(feature = "ppl")]
424    pub fn ppl(&self) -> &crate::ppl::PplApi {
425        &self.ppl_api
426    }
427    #[cfg(feature = "remote_store")]
428    pub fn remote_store(&self) -> &crate::remote_store::RemoteStoreApi {
429        &self.remote_store_api
430    }
431    #[cfg(feature = "replication")]
432    pub fn replication(&self) -> &crate::replication::ReplicationApi {
433        &self.replication_api
434    }
435    #[cfg(feature = "rollups")]
436    pub fn rollups(&self) -> &crate::rollups::RollupsApi {
437        &self.rollups_api
438    }
439    #[cfg(feature = "security")]
440    pub fn security(&self) -> &crate::security::SecurityApi {
441        &self.security_api
442    }
443    #[cfg(feature = "snapshot")]
444    pub fn snapshot(&self) -> &crate::snapshot::SnapshotApi {
445        &self.snapshot_api
446    }
447    #[cfg(feature = "sql")]
448    pub fn sql(&self) -> &crate::sql::SqlApi {
449        &self.sql_api
450    }
451    #[cfg(feature = "tasks")]
452    pub fn tasks(&self) -> &crate::tasks::TasksApi {
453        &self.tasks_api
454    }
455    #[cfg(feature = "transforms")]
456    pub fn transforms(&self) -> &crate::transforms::TransformsApi {
457        &self.transforms_api
458    }
459
460    #[cfg(feature = "tools")]
461    pub fn tools(&self) -> crate::tools::Tools {
462        crate::tools::Tools::new(Arc::new(self.clone()))
463    }
464
465    ///
466    /// Deletes a script.
467    #[builder(on(String, into))]
468    pub async fn delete_script(
469        &self,
470        cluster_manager_timeout: Option<String>,
471        master_timeout: Option<String>,
472        timeout: Option<String>,
473        error_trace: Option<bool>,
474        filter_path: Option<common::FilterPath>,
475        human: Option<bool>,
476        id: String,
477        pretty: Option<bool>,
478        source: Option<String>,
479    ) -> Result<crate::common::AcknowledgedResponseBase, Error> {
480        let local_var_configuration = &self.configuration;
481
482        let local_var_client = &local_var_configuration.client;
483
484        let local_var_uri_str = format!(
485            "{}_scripts/{id}",
486            local_var_configuration.base_path,
487            id = id
488        );
489        let mut local_var_req_builder =
490            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
491
492        if let Some(ref local_var_str) = cluster_manager_timeout {
493            local_var_req_builder = local_var_req_builder
494                .query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
495        }
496        if let Some(ref local_var_str) = master_timeout {
497            local_var_req_builder =
498                local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
499        }
500        if let Some(ref local_var_str) = filter_path {
501            local_var_req_builder =
502                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
503        }
504        if let Some(ref local_var_str) = source {
505            local_var_req_builder =
506                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
507        }
508        if let Some(ref local_var_str) = timeout {
509            local_var_req_builder =
510                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
511        }
512        if let Some(ref local_var_str) = human {
513            local_var_req_builder =
514                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
515        }
516        if let Some(ref local_var_str) = pretty {
517            local_var_req_builder =
518                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
519        }
520        if let Some(ref local_var_str) = error_trace {
521            local_var_req_builder =
522                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
523        }
524
525        let local_var_req = local_var_req_builder.build()?;
526        let local_var_resp = local_var_client.execute(local_var_req).await?;
527
528        let local_var_status = local_var_resp.status();
529        let local_var_content = local_var_resp.text().await?;
530
531        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
532            serde_json::from_str(&local_var_content).map_err(Error::from)
533        } else {
534            let local_var_error = ResponseContent {
535                status: local_var_status,
536                content: local_var_content,
537            };
538            Err(Error::ApiError(local_var_error))
539        }
540    }
541    ///
542    /// Returns information and statistics about terms in the fields of a particular document.
543    #[builder(on(String, into))]
544    pub async fn termvectors(
545        &self,
546        /// Define parameters and or supply a document to get termvectors for. See documentation.
547        termvectors: common::Termvectors,
548        /// No description available
549        error_trace: Option<bool>,
550        /// No description available
551        field_statistics: Option<bool>,
552        /// No description available
553        fields: Option<common::Fields>,
554        /// No description available
555        filter_path: Option<common::FilterPath>,
556        /// No description available
557        human: Option<bool>,
558        /// No description available
559        id: String,
560        /// No description available
561        index: String,
562        /// No description available
563        offsets: Option<bool>,
564        /// No description available
565        payloads: Option<bool>,
566        /// No description available
567        positions: Option<bool>,
568        /// No description available
569        preference: Option<String>,
570        /// No description available
571        pretty: Option<bool>,
572        /// No description available
573        realtime: Option<bool>,
574        /// No description available
575        routing: Option<common::Routing>,
576        /// No description available
577        source: Option<String>,
578        /// No description available
579        term_statistics: Option<bool>,
580        /// No description available
581        version: Option<i32>,
582        /// No description available
583        version_type: Option<String>,
584    ) -> Result<crate::common::TermvectorsResponse, Error> {
585        let local_var_configuration = &self.configuration;
586
587        let local_var_client = &local_var_configuration.client;
588
589        let local_var_uri_str = format!(
590            "{}{index}/_termvectors/{id}",
591            local_var_configuration.base_path,
592            index = index,
593            id = id
594        );
595        let mut local_var_req_builder =
596            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
597
598        if let Some(ref local_var_str) = positions {
599            local_var_req_builder =
600                local_var_req_builder.query(&[("positions", &local_var_str.to_string())]);
601        }
602        if let Some(ref local_var_str) = routing {
603            local_var_req_builder =
604                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
605        }
606        if let Some(ref local_var_str) = error_trace {
607            local_var_req_builder =
608                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
609        }
610        if let Some(ref local_var_str) = filter_path {
611            local_var_req_builder =
612                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
613        }
614        if let Some(ref local_var_str) = fields {
615            local_var_req_builder =
616                local_var_req_builder.query(&[("fields", &local_var_str.to_string())]);
617        }
618        if let Some(ref local_var_str) = preference {
619            local_var_req_builder =
620                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
621        }
622        if let Some(ref local_var_str) = version_type {
623            local_var_req_builder =
624                local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
625        }
626        if let Some(ref local_var_str) = pretty {
627            local_var_req_builder =
628                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
629        }
630        if let Some(ref local_var_str) = offsets {
631            local_var_req_builder =
632                local_var_req_builder.query(&[("offsets", &local_var_str.to_string())]);
633        }
634        if let Some(ref local_var_str) = term_statistics {
635            local_var_req_builder =
636                local_var_req_builder.query(&[("term_statistics", &local_var_str.to_string())]);
637        }
638        if let Some(ref local_var_str) = version {
639            local_var_req_builder =
640                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
641        }
642        if let Some(ref local_var_str) = field_statistics {
643            local_var_req_builder =
644                local_var_req_builder.query(&[("field_statistics", &local_var_str.to_string())]);
645        }
646        if let Some(ref local_var_str) = human {
647            local_var_req_builder =
648                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
649        }
650        if let Some(ref local_var_str) = source {
651            local_var_req_builder =
652                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
653        }
654        if let Some(ref local_var_str) = realtime {
655            local_var_req_builder =
656                local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
657        }
658        if let Some(ref local_var_str) = payloads {
659            local_var_req_builder =
660                local_var_req_builder.query(&[("payloads", &local_var_str.to_string())]);
661        }
662
663        local_var_req_builder = local_var_req_builder.json(&termvectors);
664
665        let local_var_req = local_var_req_builder.build()?;
666        let local_var_resp = local_var_client.execute(local_var_req).await?;
667
668        let local_var_status = local_var_resp.status();
669        let local_var_content = local_var_resp.text().await?;
670
671        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
672            serde_json::from_str(&local_var_content).map_err(Error::from)
673        } else {
674            let local_var_error = ResponseContent {
675                status: local_var_status,
676                content: local_var_content,
677            };
678            Err(Error::ApiError(local_var_error))
679        }
680    }
681    ///
682    /// Returns basic information about the cluster.
683    #[builder(on(String, into))]
684    pub async fn info(
685        &self,
686        /// No description available
687        error_trace: Option<bool>,
688        /// No description available
689        filter_path: Option<common::FilterPath>,
690        /// No description available
691        human: Option<bool>,
692        /// No description available
693        pretty: Option<bool>,
694        /// No description available
695        source: Option<String>,
696    ) -> Result<crate::common::InfoResponse, Error> {
697        let local_var_configuration = &self.configuration;
698
699        let local_var_client = &local_var_configuration.client;
700
701        let local_var_uri_str = format!("{}", local_var_configuration.base_path);
702        let mut local_var_req_builder =
703            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
704
705        if let Some(ref local_var_str) = filter_path {
706            local_var_req_builder =
707                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
708        }
709        if let Some(ref local_var_str) = error_trace {
710            local_var_req_builder =
711                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
712        }
713        if let Some(ref local_var_str) = source {
714            local_var_req_builder =
715                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
716        }
717        if let Some(ref local_var_str) = human {
718            local_var_req_builder =
719                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
720        }
721        if let Some(ref local_var_str) = pretty {
722            local_var_req_builder =
723                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
724        }
725
726        let local_var_req = local_var_req_builder.build()?;
727        let local_var_resp = local_var_client.execute(local_var_req).await?;
728
729        let local_var_status = local_var_resp.status();
730        let local_var_content = local_var_resp.text().await?;
731
732        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
733            serde_json::from_str(&local_var_content).map_err(Error::from)
734        } else {
735            let local_var_error = ResponseContent {
736                status: local_var_status,
737                content: local_var_content,
738            };
739            Err(Error::ApiError(local_var_error))
740        }
741    }
742    ///
743    /// Returns information about the indexes and shards that a search request would be executed against.
744    #[builder(on(String, into))]
745    pub async fn search_shards(
746        &self,
747        /// No description available
748        allow_no_indices: Option<bool>,
749        /// No description available
750        error_trace: Option<bool>,
751        /// No description available
752        filter_path: Option<common::FilterPath>,
753        /// No description available
754        human: Option<bool>,
755        /// No description available
756        ignore_unavailable: Option<bool>,
757        /// No description available
758        local: Option<bool>,
759        /// No description available
760        preference: Option<String>,
761        /// No description available
762        pretty: Option<bool>,
763        /// No description available
764        routing: Option<common::Routing>,
765        /// No description available
766        source: Option<String>,
767        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
768        expand_wildcards: Option<common::ExpandWildcards>,
769    ) -> Result<crate::common::SearchShardsResponse, Error> {
770        let local_var_configuration = &self.configuration;
771
772        let local_var_client = &local_var_configuration.client;
773
774        let local_var_uri_str = format!("{}_search_shards", local_var_configuration.base_path);
775        let mut local_var_req_builder =
776            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
777
778        if let Some(ref local_var_str) = source {
779            local_var_req_builder =
780                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
781        }
782        if let Some(ref local_var_str) = expand_wildcards {
783            local_var_req_builder =
784                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
785        }
786        if let Some(ref local_var_str) = preference {
787            local_var_req_builder =
788                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
789        }
790        if let Some(ref local_var_str) = local {
791            local_var_req_builder =
792                local_var_req_builder.query(&[("local", &local_var_str.to_string())]);
793        }
794        if let Some(ref local_var_str) = filter_path {
795            local_var_req_builder =
796                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
797        }
798        if let Some(ref local_var_str) = allow_no_indices {
799            local_var_req_builder =
800                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
801        }
802        if let Some(ref local_var_str) = human {
803            local_var_req_builder =
804                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
805        }
806        if let Some(ref local_var_str) = pretty {
807            local_var_req_builder =
808                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
809        }
810        if let Some(ref local_var_str) = routing {
811            local_var_req_builder =
812                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
813        }
814        if let Some(ref local_var_str) = ignore_unavailable {
815            local_var_req_builder =
816                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
817        }
818        if let Some(ref local_var_str) = error_trace {
819            local_var_req_builder =
820                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
821        }
822
823        let local_var_req = local_var_req_builder.build()?;
824        let local_var_resp = local_var_client.execute(local_var_req).await?;
825
826        let local_var_status = local_var_resp.status();
827        let local_var_content = local_var_resp.text().await?;
828
829        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
830            serde_json::from_str(&local_var_content).map_err(Error::from)
831        } else {
832            let local_var_error = ResponseContent {
833                status: local_var_status,
834                content: local_var_content,
835            };
836            Err(Error::ApiError(local_var_error))
837        }
838    }
839    ///
840    /// Creates or updates a script.
841    #[builder(on(String, into))]
842    pub async fn put_script(
843        &self,
844        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
845        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
846        cluster_manager_timeout: Option<String>,
847        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
848        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
849        master_timeout: Option<String>,
850        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
851        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
852        timeout: Option<String>,
853        /// No description available
854        context: Option<String>,
855        /// No description available
856        error_trace: Option<bool>,
857        /// No description available
858        filter_path: Option<common::FilterPath>,
859        /// No description available
860        human: Option<bool>,
861        /// No description available
862        id: String,
863        /// No description available
864        pretty: Option<bool>,
865        /// No description available
866        source: Option<String>,
867        /// The document
868        put_script: common::PutScript,
869    ) -> Result<crate::common::AcknowledgedResponseBase, Error> {
870        let local_var_configuration = &self.configuration;
871
872        let local_var_client = &local_var_configuration.client;
873
874        let local_var_uri_str = format!(
875            "{}_scripts/{id}/{context}",
876            local_var_configuration.base_path,
877            id = id,
878            context = context.clone().unwrap_or_else(|| "painless".to_string())
879        );
880        let mut local_var_req_builder =
881            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
882
883        if let Some(ref local_var_str) = pretty {
884            local_var_req_builder =
885                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
886        }
887        if let Some(local_var_str) = context {
888            local_var_req_builder =
889                local_var_req_builder.query(&[("context", &local_var_str.to_string())]);
890        }
891        if let Some(ref local_var_str) = source {
892            local_var_req_builder =
893                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
894        }
895        if let Some(ref local_var_str) = human {
896            local_var_req_builder =
897                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
898        }
899        if let Some(ref local_var_str) = master_timeout {
900            local_var_req_builder =
901                local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
902        }
903        if let Some(ref local_var_str) = timeout {
904            local_var_req_builder =
905                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
906        }
907        if let Some(ref local_var_str) = error_trace {
908            local_var_req_builder =
909                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
910        }
911        if let Some(ref local_var_str) = filter_path {
912            local_var_req_builder =
913                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
914        }
915        if let Some(ref local_var_str) = cluster_manager_timeout {
916            local_var_req_builder = local_var_req_builder
917                .query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
918        }
919
920        local_var_req_builder = local_var_req_builder.json(&put_script);
921
922        let local_var_req = local_var_req_builder.build()?;
923        let local_var_resp = local_var_client.execute(local_var_req).await?;
924
925        let local_var_status = local_var_resp.status();
926        let local_var_content = local_var_resp.text().await?;
927
928        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
929            serde_json::from_str(&local_var_content).map_err(Error::from)
930        } else {
931            let local_var_error = ResponseContent {
932                status: local_var_status,
933                content: local_var_content,
934            };
935            Err(Error::ApiError(local_var_error))
936        }
937    }
938    ///
939    /// Allows to evaluate the quality of ranked search results over a set of typical search queries.
940    #[builder(on(String, into))]
941    pub async fn rank_eval(
942        &self,
943        /// No description available
944        allow_no_indices: Option<bool>,
945        /// No description available
946        error_trace: Option<bool>,
947        /// No description available
948        filter_path: Option<common::FilterPath>,
949        /// No description available
950        human: Option<bool>,
951        /// No description available
952        ignore_unavailable: Option<bool>,
953        /// No description available
954        index: String,
955        /// No description available
956        pretty: Option<bool>,
957        /// No description available
958        search_type: Option<common::SearchType>,
959        /// No description available
960        source: Option<String>,
961        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
962        expand_wildcards: Option<common::ExpandWildcards>,
963        /// The ranking evaluation search definition, including search requests, document ratings and ranking metric definition.
964        rank_eval: common::RankEval,
965    ) -> Result<crate::common::RankEvalResponse, Error> {
966        let local_var_configuration = &self.configuration;
967
968        let local_var_client = &local_var_configuration.client;
969
970        let local_var_uri_str = format!(
971            "{}{index}/_rank_eval",
972            local_var_configuration.base_path,
973            index = index
974        );
975        let mut local_var_req_builder =
976            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
977
978        if let Some(ref local_var_str) = allow_no_indices {
979            local_var_req_builder =
980                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
981        }
982        if let Some(ref local_var_str) = expand_wildcards {
983            local_var_req_builder =
984                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
985        }
986        if let Some(ref local_var_str) = search_type {
987            local_var_req_builder =
988                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
989        }
990        if let Some(ref local_var_str) = pretty {
991            local_var_req_builder =
992                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
993        }
994        if let Some(ref local_var_str) = human {
995            local_var_req_builder =
996                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
997        }
998        if let Some(ref local_var_str) = ignore_unavailable {
999            local_var_req_builder =
1000                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
1001        }
1002        if let Some(ref local_var_str) = error_trace {
1003            local_var_req_builder =
1004                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
1005        }
1006        if let Some(ref local_var_str) = source {
1007            local_var_req_builder =
1008                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
1009        }
1010        if let Some(ref local_var_str) = filter_path {
1011            local_var_req_builder =
1012                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
1013        }
1014
1015        local_var_req_builder = local_var_req_builder.json(&rank_eval);
1016
1017        let local_var_req = local_var_req_builder.build()?;
1018        let local_var_resp = local_var_client.execute(local_var_req).await?;
1019
1020        let local_var_status = local_var_resp.status();
1021        let local_var_content = local_var_resp.text().await?;
1022
1023        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1024            serde_json::from_str(&local_var_content).map_err(Error::from)
1025        } else {
1026            let local_var_error = ResponseContent {
1027                status: local_var_status,
1028                content: local_var_content,
1029            };
1030            Err(Error::ApiError(local_var_error))
1031        }
1032    }
1033    ///
1034    /// Returns information about why a specific matches (or doesn't match) a query.
1035    #[builder(on(String, into))]
1036    pub async fn explain(
1037        &self,
1038        /// No description available
1039        source_excludes: Option<common::SourceExcludes>,
1040        /// No description available
1041        source_includes: Option<common::SourceIncludes>,
1042        /// No description available
1043        analyze_wildcard: Option<bool>,
1044        /// No description available
1045        analyzer: Option<String>,
1046        /// No description available
1047        default_operator: Option<String>,
1048        /// No description available
1049        df: Option<String>,
1050        /// No description available
1051        error_trace: Option<bool>,
1052        /// No description available
1053        filter_path: Option<common::FilterPath>,
1054        /// No description available
1055        human: Option<bool>,
1056        /// No description available
1057        id: String,
1058        /// No description available
1059        index: String,
1060        /// No description available
1061        lenient: Option<bool>,
1062        /// No description available
1063        preference: Option<String>,
1064        /// No description available
1065        pretty: Option<bool>,
1066        /// No description available
1067        q: Option<String>,
1068        /// No description available
1069        routing: Option<common::Routing>,
1070        /// No description available
1071        source: Option<String>,
1072        /// No description available
1073        stored_fields: Option<common::StoredFields>,
1074        /// The query definition using the Query DSL
1075        explain: common::Explain,
1076    ) -> Result<crate::common::ExplainResponse, Error> {
1077        let local_var_configuration = &self.configuration;
1078
1079        let local_var_client = &local_var_configuration.client;
1080
1081        let local_var_uri_str = format!(
1082            "{}{index}/_explain/{id}",
1083            local_var_configuration.base_path,
1084            index = index,
1085            id = id
1086        );
1087        let mut local_var_req_builder =
1088            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1089
1090        if let Some(ref local_var_str) = source {
1091            local_var_req_builder =
1092                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
1093        }
1094        if let Some(ref local_var_str) = default_operator {
1095            local_var_req_builder =
1096                local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
1097        }
1098        if let Some(ref local_var_str) = df {
1099            local_var_req_builder =
1100                local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
1101        }
1102        if let Some(ref local_var_str) = human {
1103            local_var_req_builder =
1104                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
1105        }
1106        if let Some(ref local_var_str) = source_includes {
1107            local_var_req_builder =
1108                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
1109        }
1110        if let Some(ref local_var_str) = lenient {
1111            local_var_req_builder =
1112                local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
1113        }
1114        if let Some(ref local_var_str) = routing {
1115            local_var_req_builder =
1116                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
1117        }
1118        if let Some(ref local_var_str) = preference {
1119            local_var_req_builder =
1120                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
1121        }
1122        if let Some(ref local_var_str) = stored_fields {
1123            local_var_req_builder =
1124                local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
1125        }
1126        if let Some(ref local_var_str) = pretty {
1127            local_var_req_builder =
1128                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
1129        }
1130        if let Some(ref local_var_str) = source_excludes {
1131            local_var_req_builder =
1132                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
1133        }
1134        if let Some(ref local_var_str) = error_trace {
1135            local_var_req_builder =
1136                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
1137        }
1138        if let Some(ref local_var_str) = filter_path {
1139            local_var_req_builder =
1140                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
1141        }
1142        if let Some(ref local_var_str) = q {
1143            local_var_req_builder =
1144                local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
1145        }
1146        if let Some(ref local_var_str) = analyzer {
1147            local_var_req_builder =
1148                local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
1149        }
1150        if let Some(ref local_var_str) = analyze_wildcard {
1151            local_var_req_builder =
1152                local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
1153        }
1154
1155        local_var_req_builder = local_var_req_builder.json(&explain);
1156
1157        let local_var_req = local_var_req_builder.build()?;
1158        let local_var_resp = local_var_client.execute(local_var_req).await?;
1159
1160        let local_var_status = local_var_resp.status();
1161        let local_var_content = local_var_resp.text().await?;
1162
1163        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1164            serde_json::from_str(&local_var_content).map_err(Error::from)
1165        } else {
1166            let local_var_error = ResponseContent {
1167                status: local_var_status,
1168                content: local_var_content,
1169            };
1170            Err(Error::ApiError(local_var_error))
1171        }
1172    }
1173    ///
1174    /// Returns a script.
1175    #[builder(on(String, into))]
1176    pub async fn get_script(
1177        &self,
1178        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
1179        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
1180        cluster_manager_timeout: Option<String>,
1181        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
1182        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
1183        master_timeout: Option<String>,
1184        /// No description available
1185        error_trace: Option<bool>,
1186        /// No description available
1187        filter_path: Option<common::FilterPath>,
1188        /// No description available
1189        human: Option<bool>,
1190        /// No description available
1191        id: String,
1192        /// No description available
1193        pretty: Option<bool>,
1194        /// No description available
1195        source: Option<String>,
1196    ) -> Result<crate::common::GetScriptResponse, Error> {
1197        let local_var_configuration = &self.configuration;
1198
1199        let local_var_client = &local_var_configuration.client;
1200
1201        let local_var_uri_str = format!(
1202            "{}_scripts/{id}",
1203            local_var_configuration.base_path,
1204            id = id
1205        );
1206        let mut local_var_req_builder =
1207            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
1208
1209        if let Some(ref local_var_str) = cluster_manager_timeout {
1210            local_var_req_builder = local_var_req_builder
1211                .query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
1212        }
1213        if let Some(ref local_var_str) = master_timeout {
1214            local_var_req_builder =
1215                local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
1216        }
1217        if let Some(ref local_var_str) = pretty {
1218            local_var_req_builder =
1219                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
1220        }
1221        if let Some(ref local_var_str) = filter_path {
1222            local_var_req_builder =
1223                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
1224        }
1225        if let Some(ref local_var_str) = source {
1226            local_var_req_builder =
1227                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
1228        }
1229        if let Some(ref local_var_str) = human {
1230            local_var_req_builder =
1231                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
1232        }
1233        if let Some(ref local_var_str) = error_trace {
1234            local_var_req_builder =
1235                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
1236        }
1237
1238        let local_var_req = local_var_req_builder.build()?;
1239        let local_var_resp = local_var_client.execute(local_var_req).await?;
1240
1241        let local_var_status = local_var_resp.status();
1242        let local_var_content = local_var_resp.text().await?;
1243
1244        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1245            serde_json::from_str(&local_var_content).map_err(Error::from)
1246        } else {
1247            let local_var_error = ResponseContent {
1248                status: local_var_status,
1249                content: local_var_content,
1250            };
1251            Err(Error::ApiError(local_var_error))
1252        }
1253    }
1254    ///
1255    /// Allows to use the Mustache language to pre-render a search definition.
1256    #[builder(on(String, into))]
1257    pub async fn render_search_template(
1258        &self,
1259        /// No description available
1260        error_trace: Option<bool>,
1261        /// No description available
1262        filter_path: Option<common::FilterPath>,
1263        /// No description available
1264        human: Option<bool>,
1265        /// No description available
1266        id: String,
1267        /// No description available
1268        pretty: Option<bool>,
1269        /// No description available
1270        source: Option<String>,
1271        /// The search definition template and its parameters.
1272        render_search_template: common::RenderSearchTemplate,
1273    ) -> Result<crate::common::RenderSearchTemplateResponse, Error> {
1274        let local_var_configuration = &self.configuration;
1275
1276        let local_var_client = &local_var_configuration.client;
1277
1278        let local_var_uri_str = format!(
1279            "{}_render/template/{id}",
1280            local_var_configuration.base_path,
1281            id = id
1282        );
1283        let mut local_var_req_builder =
1284            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1285
1286        if let Some(ref local_var_str) = human {
1287            local_var_req_builder =
1288                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
1289        }
1290        if let Some(ref local_var_str) = source {
1291            local_var_req_builder =
1292                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
1293        }
1294        if let Some(ref local_var_str) = pretty {
1295            local_var_req_builder =
1296                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
1297        }
1298        if let Some(ref local_var_str) = filter_path {
1299            local_var_req_builder =
1300                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
1301        }
1302        if let Some(ref local_var_str) = error_trace {
1303            local_var_req_builder =
1304                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
1305        }
1306
1307        local_var_req_builder = local_var_req_builder.json(&render_search_template);
1308
1309        let local_var_req = local_var_req_builder.build()?;
1310        let local_var_resp = local_var_client.execute(local_var_req).await?;
1311
1312        let local_var_status = local_var_resp.status();
1313        let local_var_content = local_var_resp.text().await?;
1314
1315        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1316            serde_json::from_str(&local_var_content).map_err(Error::from)
1317        } else {
1318            let local_var_error = ResponseContent {
1319                status: local_var_status,
1320                content: local_var_content,
1321            };
1322            Err(Error::ApiError(local_var_error))
1323        }
1324    }
1325    ///
1326    /// Allows to copy documents from one index to another, optionally filtering the source
1327    /// documents by a query, changing the destination index settings, or fetching the
1328    /// documents from a remote cluster.
1329    #[builder(on(String, into))]
1330    pub async fn reindex(
1331        &self,
1332        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
1333        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
1334        scroll: Option<String>,
1335        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
1336        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
1337        timeout: Option<String>,
1338        /// Maximum number of documents to process. By default, all documents.
1339        max_docs: Option<i32>,
1340        /// No description available
1341        error_trace: Option<bool>,
1342        /// No description available
1343        filter_path: Option<common::FilterPath>,
1344        /// No description available
1345        human: Option<bool>,
1346        /// No description available
1347        pretty: Option<bool>,
1348        /// No description available
1349        refresh: Option<common::Refresh>,
1350        /// No description available
1351        requests_per_second: Option<f64>,
1352        /// No description available
1353        require_alias: Option<bool>,
1354        /// No description available
1355        source: Option<String>,
1356        /// No description available
1357        wait_for_completion: Option<bool>,
1358        /// The search definition using the Query DSL and the prototype for the index request.
1359        reindex: common::Reindex,
1360        /// The slice configuration used to parallelize a process.
1361        slices: Option<common::Slices>,
1362        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
1363        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
1364    ) -> Result<crate::common::ReindexOKJson, Error> {
1365        let local_var_configuration = &self.configuration;
1366
1367        let local_var_client = &local_var_configuration.client;
1368
1369        let local_var_uri_str = format!("{}_reindex", local_var_configuration.base_path);
1370        let mut local_var_req_builder =
1371            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1372
1373        if let Some(ref local_var_str) = refresh {
1374            local_var_req_builder =
1375                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
1376        }
1377        if let Some(ref local_var_str) = wait_for_active_shards {
1378            local_var_req_builder = local_var_req_builder
1379                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
1380        }
1381        if let Some(ref local_var_str) = wait_for_completion {
1382            local_var_req_builder =
1383                local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
1384        }
1385        if let Some(ref local_var_str) = filter_path {
1386            local_var_req_builder =
1387                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
1388        }
1389        if let Some(ref local_var_str) = pretty {
1390            local_var_req_builder =
1391                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
1392        }
1393        if let Some(ref local_var_str) = max_docs {
1394            local_var_req_builder =
1395                local_var_req_builder.query(&[("max_docs", &local_var_str.to_string())]);
1396        }
1397        if let Some(ref local_var_str) = requests_per_second {
1398            local_var_req_builder =
1399                local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
1400        }
1401        if let Some(ref local_var_str) = scroll {
1402            local_var_req_builder =
1403                local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
1404        }
1405        if let Some(ref local_var_str) = error_trace {
1406            local_var_req_builder =
1407                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
1408        }
1409        if let Some(ref local_var_str) = human {
1410            local_var_req_builder =
1411                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
1412        }
1413        if let Some(ref local_var_str) = source {
1414            local_var_req_builder =
1415                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
1416        }
1417        if let Some(ref local_var_str) = slices {
1418            local_var_req_builder =
1419                local_var_req_builder.query(&[("slices", &local_var_str.to_string())]);
1420        }
1421        if let Some(ref local_var_str) = timeout {
1422            local_var_req_builder =
1423                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
1424        }
1425        if let Some(ref local_var_str) = require_alias {
1426            local_var_req_builder =
1427                local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
1428        }
1429
1430        local_var_req_builder = local_var_req_builder.json(&reindex);
1431
1432        let local_var_req = local_var_req_builder.build()?;
1433        let local_var_resp = local_var_client.execute(local_var_req).await?;
1434
1435        let local_var_status = local_var_resp.status();
1436        let local_var_content = local_var_resp.text().await?;
1437
1438        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1439            serde_json::from_str(&local_var_content).map_err(Error::from)
1440        } else {
1441            let local_var_error = ResponseContent {
1442                status: local_var_status,
1443                content: local_var_content,
1444            };
1445            Err(Error::ApiError(local_var_error))
1446        }
1447    }
1448    ///
1449    /// Returns information about whether a document source exists in an index.
1450    #[builder(on(String, into))]
1451    pub async fn exists_source(
1452        &self,
1453        /// No description available
1454        source_excludes: Option<common::SourceExcludes>,
1455        /// No description available
1456        source_includes: Option<common::SourceIncludes>,
1457        /// No description available
1458        error_trace: Option<bool>,
1459        /// No description available
1460        filter_path: Option<common::FilterPath>,
1461        /// No description available
1462        human: Option<bool>,
1463        /// No description available
1464        id: String,
1465        /// No description available
1466        index: String,
1467        /// No description available
1468        preference: Option<String>,
1469        /// No description available
1470        pretty: Option<bool>,
1471        /// No description available
1472        realtime: Option<bool>,
1473        /// No description available
1474        refresh: Option<common::Refresh>,
1475        /// No description available
1476        routing: Option<common::Routing>,
1477        /// No description available
1478        source: Option<String>,
1479        /// No description available
1480        version: Option<i32>,
1481        /// No description available
1482        version_type: Option<String>,
1483    ) -> Result<ExistsSourceSuccess, Error> {
1484        let local_var_configuration = &self.configuration;
1485
1486        let local_var_client = &local_var_configuration.client;
1487
1488        let local_var_uri_str = format!(
1489            "{}{index}/_source/{id}",
1490            local_var_configuration.base_path,
1491            index = index,
1492            id = id
1493        );
1494        let mut local_var_req_builder =
1495            local_var_client.request(reqwest::Method::HEAD, local_var_uri_str.as_str());
1496
1497        if let Some(ref local_var_str) = source_excludes {
1498            local_var_req_builder =
1499                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
1500        }
1501        if let Some(ref local_var_str) = source_includes {
1502            local_var_req_builder =
1503                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
1504        }
1505        if let Some(ref local_var_str) = refresh {
1506            local_var_req_builder =
1507                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
1508        }
1509        if let Some(ref local_var_str) = version {
1510            local_var_req_builder =
1511                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
1512        }
1513        if let Some(ref local_var_str) = pretty {
1514            local_var_req_builder =
1515                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
1516        }
1517        if let Some(ref local_var_str) = routing {
1518            local_var_req_builder =
1519                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
1520        }
1521        if let Some(ref local_var_str) = preference {
1522            local_var_req_builder =
1523                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
1524        }
1525        if let Some(ref local_var_str) = realtime {
1526            local_var_req_builder =
1527                local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
1528        }
1529        if let Some(ref local_var_str) = human {
1530            local_var_req_builder =
1531                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
1532        }
1533        if let Some(ref local_var_str) = filter_path {
1534            local_var_req_builder =
1535                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
1536        }
1537        if let Some(ref local_var_str) = error_trace {
1538            local_var_req_builder =
1539                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
1540        }
1541        if let Some(ref local_var_str) = version_type {
1542            local_var_req_builder =
1543                local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
1544        }
1545        if let Some(ref local_var_str) = source {
1546            local_var_req_builder =
1547                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
1548        }
1549
1550        let local_var_req = local_var_req_builder.build()?;
1551        let local_var_resp = local_var_client.execute(local_var_req).await?;
1552
1553        let local_var_status = local_var_resp.status();
1554        let local_var_content = local_var_resp.text().await?;
1555
1556        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1557            serde_json::from_str(&local_var_content).map_err(Error::from)
1558        } else {
1559            let local_var_error = ResponseContent {
1560                status: local_var_status,
1561                content: local_var_content,
1562            };
1563            Err(Error::ApiError(local_var_error))
1564        }
1565    }
1566    ///
1567    /// Deletes documents matching the provided query.
1568    #[builder(on(String, into))]
1569    pub async fn delete_by_query(
1570        &self,
1571        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
1572        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
1573        scroll: Option<String>,
1574        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
1575        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
1576        search_timeout: Option<String>,
1577        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
1578        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
1579        timeout: Option<String>,
1580        /// Deprecated, use `max_docs` instead.
1581        size: Option<i32>,
1582        /// No description available
1583        source_excludes: Option<Vec<String>>,
1584        /// No description available
1585        source_includes: Option<Vec<String>>,
1586        /// No description available
1587        allow_no_indices: Option<bool>,
1588        /// No description available
1589        analyze_wildcard: Option<bool>,
1590        /// No description available
1591        analyzer: Option<String>,
1592        /// No description available
1593        conflicts: Option<String>,
1594        /// No description available
1595        default_operator: Option<String>,
1596        /// No description available
1597        df: Option<String>,
1598        /// No description available
1599        error_trace: Option<bool>,
1600        /// No description available
1601        filter_path: Option<common::FilterPath>,
1602        /// No description available
1603        from: Option<i32>,
1604        /// No description available
1605        human: Option<bool>,
1606        /// No description available
1607        ignore_unavailable: Option<bool>,
1608        /// No description available
1609        index: String,
1610        /// No description available
1611        lenient: Option<bool>,
1612        /// No description available
1613        max_docs: Option<i32>,
1614        /// No description available
1615        preference: Option<String>,
1616        /// No description available
1617        pretty: Option<bool>,
1618        /// No description available
1619        q: Option<String>,
1620        /// No description available
1621        refresh: Option<common::Refresh>,
1622        /// No description available
1623        request_cache: Option<bool>,
1624        /// No description available
1625        requests_per_second: Option<f64>,
1626        /// No description available
1627        routing: Option<common::Routing>,
1628        /// No description available
1629        scroll_size: Option<i32>,
1630        /// No description available
1631        search_type: Option<common::SearchType>,
1632        /// No description available
1633        sort: Option<Vec<String>>,
1634        /// No description available
1635        source: Option<String>,
1636        /// No description available
1637        stats: Option<Vec<String>>,
1638        /// No description available
1639        terminate_after: Option<i32>,
1640        /// No description available
1641        version: Option<bool>,
1642        /// No description available
1643        wait_for_completion: Option<bool>,
1644        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
1645        expand_wildcards: Option<common::ExpandWildcards>,
1646        /// The search definition using the Query DSL
1647        delete_by_query: common::DeleteByQuery,
1648        /// The slice configuration used to parallelize a process.
1649        slices: Option<common::Slices>,
1650        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
1651        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
1652    ) -> Result<crate::common::DeleteByQueryOKJson, Error> {
1653        let local_var_configuration = &self.configuration;
1654
1655        let local_var_client = &local_var_configuration.client;
1656
1657        let local_var_uri_str = format!(
1658            "{}{index}/_delete_by_query",
1659            local_var_configuration.base_path,
1660            index = index
1661        );
1662        let mut local_var_req_builder =
1663            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
1664
1665        if let Some(ref local_var_str) = slices {
1666            local_var_req_builder =
1667                local_var_req_builder.query(&[("slices", &local_var_str.to_string())]);
1668        }
1669        if let Some(ref local_var_str) = stats {
1670            local_var_req_builder = match "multi" {
1671                "multi" => local_var_req_builder.query(
1672                    &local_var_str
1673                        .into_iter()
1674                        .map(|p| ("stats".to_owned(), p.to_string()))
1675                        .collect::<Vec<(std::string::String, std::string::String)>>(),
1676                ),
1677                _ => local_var_req_builder.query(&[(
1678                    "stats",
1679                    &local_var_str
1680                        .into_iter()
1681                        .map(|p| p.to_string())
1682                        .collect::<Vec<String>>()
1683                        .join(",")
1684                        .to_string(),
1685                )]),
1686            };
1687        }
1688        if let Some(ref local_var_str) = max_docs {
1689            local_var_req_builder =
1690                local_var_req_builder.query(&[("max_docs", &local_var_str.to_string())]);
1691        }
1692        if let Some(ref local_var_str) = wait_for_completion {
1693            local_var_req_builder =
1694                local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
1695        }
1696        if let Some(ref local_var_str) = source_includes {
1697            local_var_req_builder = match "multi" {
1698                "multi" => local_var_req_builder.query(
1699                    &local_var_str
1700                        .into_iter()
1701                        .map(|p| ("source_includes".to_owned(), p.to_string()))
1702                        .collect::<Vec<(std::string::String, std::string::String)>>(),
1703                ),
1704                _ => local_var_req_builder.query(&[(
1705                    "source_includes",
1706                    &local_var_str
1707                        .into_iter()
1708                        .map(|p| p.to_string())
1709                        .collect::<Vec<String>>()
1710                        .join(",")
1711                        .to_string(),
1712                )]),
1713            };
1714        }
1715        if let Some(ref local_var_str) = expand_wildcards {
1716            local_var_req_builder =
1717                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
1718        }
1719        if let Some(ref local_var_str) = routing {
1720            local_var_req_builder =
1721                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
1722        }
1723        if let Some(ref local_var_str) = search_type {
1724            local_var_req_builder =
1725                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
1726        }
1727        if let Some(ref local_var_str) = conflicts {
1728            local_var_req_builder =
1729                local_var_req_builder.query(&[("conflicts", &local_var_str.to_string())]);
1730        }
1731        if let Some(ref local_var_str) = source {
1732            local_var_req_builder =
1733                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
1734        }
1735        if let Some(ref local_var_str) = q {
1736            local_var_req_builder =
1737                local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
1738        }
1739        if let Some(ref local_var_str) = request_cache {
1740            local_var_req_builder =
1741                local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
1742        }
1743        if let Some(ref local_var_str) = preference {
1744            local_var_req_builder =
1745                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
1746        }
1747        if let Some(ref local_var_str) = refresh {
1748            local_var_req_builder =
1749                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
1750        }
1751        if let Some(ref local_var_str) = scroll {
1752            local_var_req_builder =
1753                local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
1754        }
1755        if let Some(ref local_var_str) = wait_for_active_shards {
1756            local_var_req_builder = local_var_req_builder
1757                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
1758        }
1759        if let Some(ref local_var_str) = analyzer {
1760            local_var_req_builder =
1761                local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
1762        }
1763        if let Some(ref local_var_str) = sort {
1764            local_var_req_builder = match "multi" {
1765                "multi" => local_var_req_builder.query(
1766                    &local_var_str
1767                        .into_iter()
1768                        .map(|p| ("sort".to_owned(), p.to_string()))
1769                        .collect::<Vec<(std::string::String, std::string::String)>>(),
1770                ),
1771                _ => local_var_req_builder.query(&[(
1772                    "sort",
1773                    &local_var_str
1774                        .into_iter()
1775                        .map(|p| p.to_string())
1776                        .collect::<Vec<String>>()
1777                        .join(",")
1778                        .to_string(),
1779                )]),
1780            };
1781        }
1782        if let Some(ref local_var_str) = filter_path {
1783            local_var_req_builder =
1784                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
1785        }
1786        if let Some(ref local_var_str) = df {
1787            local_var_req_builder =
1788                local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
1789        }
1790        if let Some(ref local_var_str) = ignore_unavailable {
1791            local_var_req_builder =
1792                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
1793        }
1794        if let Some(ref local_var_str) = timeout {
1795            local_var_req_builder =
1796                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
1797        }
1798        if let Some(ref local_var_str) = human {
1799            local_var_req_builder =
1800                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
1801        }
1802        if let Some(ref local_var_str) = size {
1803            local_var_req_builder =
1804                local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
1805        }
1806        if let Some(ref local_var_str) = pretty {
1807            local_var_req_builder =
1808                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
1809        }
1810        if let Some(ref local_var_str) = allow_no_indices {
1811            local_var_req_builder =
1812                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
1813        }
1814        if let Some(ref local_var_str) = scroll_size {
1815            local_var_req_builder =
1816                local_var_req_builder.query(&[("scroll_size", &local_var_str.to_string())]);
1817        }
1818        if let Some(ref local_var_str) = requests_per_second {
1819            local_var_req_builder =
1820                local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
1821        }
1822        if let Some(ref local_var_str) = error_trace {
1823            local_var_req_builder =
1824                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
1825        }
1826        if let Some(ref local_var_str) = analyze_wildcard {
1827            local_var_req_builder =
1828                local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
1829        }
1830        if let Some(ref local_var_str) = source_excludes {
1831            local_var_req_builder = match "multi" {
1832                "multi" => local_var_req_builder.query(
1833                    &local_var_str
1834                        .into_iter()
1835                        .map(|p| ("source_excludes".to_owned(), p.to_string()))
1836                        .collect::<Vec<(std::string::String, std::string::String)>>(),
1837                ),
1838                _ => local_var_req_builder.query(&[(
1839                    "source_excludes",
1840                    &local_var_str
1841                        .into_iter()
1842                        .map(|p| p.to_string())
1843                        .collect::<Vec<String>>()
1844                        .join(",")
1845                        .to_string(),
1846                )]),
1847            };
1848        }
1849        if let Some(ref local_var_str) = default_operator {
1850            local_var_req_builder =
1851                local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
1852        }
1853        if let Some(ref local_var_str) = from {
1854            local_var_req_builder =
1855                local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
1856        }
1857        if let Some(ref local_var_str) = version {
1858            local_var_req_builder =
1859                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
1860        }
1861        if let Some(ref local_var_str) = search_timeout {
1862            local_var_req_builder =
1863                local_var_req_builder.query(&[("search_timeout", &local_var_str.to_string())]);
1864        }
1865        if let Some(ref local_var_str) = terminate_after {
1866            local_var_req_builder =
1867                local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
1868        }
1869        if let Some(ref local_var_str) = lenient {
1870            local_var_req_builder =
1871                local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
1872        }
1873
1874        local_var_req_builder = local_var_req_builder.json(&delete_by_query);
1875
1876        let local_var_req = local_var_req_builder.build()?;
1877        let local_var_resp = local_var_client.execute(local_var_req).await?;
1878
1879        let local_var_status = local_var_resp.status();
1880        let local_var_content = local_var_resp.text().await?;
1881
1882        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
1883            serde_json::from_str(&local_var_content).map_err(Error::from)
1884        } else {
1885            let local_var_error = ResponseContent {
1886                status: local_var_status,
1887                content: local_var_content,
1888            };
1889            Err(Error::ApiError(local_var_error))
1890        }
1891    }
1892    ///
1893    /// Returns information about whether a document exists in an index.
1894    #[builder(on(String, into))]
1895    pub async fn exists(
1896        &self,
1897        /// No description available
1898        index: String,
1899        /// No description available
1900        id: String,
1901        /// No description available
1902        source_excludes: Option<common::SourceExcludes>,
1903        /// No description available
1904        source_includes: Option<common::SourceIncludes>,
1905        /// No description available
1906        error_trace: Option<bool>,
1907        /// No description available
1908        filter_path: Option<common::FilterPath>,
1909        /// No description available
1910        human: Option<bool>,
1911        /// No description available
1912        preference: Option<String>,
1913        /// No description available
1914        pretty: Option<bool>,
1915        /// No description available
1916        realtime: Option<bool>,
1917        /// No description available
1918        refresh: Option<common::Refresh>,
1919        /// No description available
1920        routing: Option<common::Routing>,
1921        /// No description available
1922        source: Option<String>,
1923        /// No description available
1924        stored_fields: Option<common::StoredFields>,
1925        /// No description available
1926        version: Option<i32>,
1927        /// No description available
1928        version_type: Option<String>,
1929    ) -> Result<ExistsSuccess, Error> {
1930        let local_var_configuration = &self.configuration;
1931
1932        let local_var_client = &local_var_configuration.client;
1933
1934        let local_var_uri_str = format!(
1935            "{}{index}/_doc/{id}",
1936            local_var_configuration.base_path,
1937            index = index,
1938            id = id
1939        );
1940        let mut local_var_req_builder =
1941            local_var_client.request(reqwest::Method::HEAD, local_var_uri_str.as_str());
1942
1943        if let Some(ref local_var_str) = stored_fields {
1944            local_var_req_builder =
1945                local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
1946        }
1947        if let Some(ref local_var_str) = pretty {
1948            local_var_req_builder =
1949                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
1950        }
1951        if let Some(ref local_var_str) = error_trace {
1952            local_var_req_builder =
1953                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
1954        }
1955        if let Some(ref local_var_str) = realtime {
1956            local_var_req_builder =
1957                local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
1958        }
1959        if let Some(ref local_var_str) = filter_path {
1960            local_var_req_builder =
1961                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
1962        }
1963        if let Some(ref local_var_str) = source_includes {
1964            local_var_req_builder =
1965                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
1966        }
1967        if let Some(ref local_var_str) = refresh {
1968            local_var_req_builder =
1969                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
1970        }
1971        if let Some(ref local_var_str) = human {
1972            local_var_req_builder =
1973                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
1974        }
1975        if let Some(ref local_var_str) = version_type {
1976            local_var_req_builder =
1977                local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
1978        }
1979        if let Some(ref local_var_str) = preference {
1980            local_var_req_builder =
1981                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
1982        }
1983        if let Some(ref local_var_str) = routing {
1984            local_var_req_builder =
1985                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
1986        }
1987        if let Some(ref local_var_str) = version {
1988            local_var_req_builder =
1989                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
1990        }
1991        if let Some(ref local_var_str) = source {
1992            local_var_req_builder =
1993                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
1994        }
1995        if let Some(ref local_var_str) = source_excludes {
1996            local_var_req_builder =
1997                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
1998        }
1999
2000        let local_var_req = local_var_req_builder.build()?;
2001        let local_var_resp = local_var_client.execute(local_var_req).await?;
2002
2003        let local_var_status = local_var_resp.status();
2004        let local_var_content = local_var_resp.text().await?;
2005
2006        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2007            serde_json::from_str(&local_var_content).map_err(Error::from)
2008        } else {
2009            let local_var_error = ResponseContent {
2010                status: local_var_status,
2011                content: local_var_content,
2012            };
2013            Err(Error::ApiError(local_var_error))
2014        }
2015    }
2016    ///
2017    /// Returns the information about the capabilities of fields among multiple indexes.
2018    #[builder(on(String, into))]
2019    pub async fn field_caps(
2020        &self,
2021        /// An index filter specified with the Query DSL
2022        field_caps: common::FieldCaps,
2023        /// No description available
2024        allow_no_indices: Option<bool>,
2025        /// No description available
2026        error_trace: Option<bool>,
2027        /// No description available
2028        fields: Option<common::Fields>,
2029        /// No description available
2030        filter_path: Option<common::FilterPath>,
2031        /// No description available
2032        human: Option<bool>,
2033        /// No description available
2034        ignore_unavailable: Option<bool>,
2035        /// No description available
2036        include_unmapped: Option<bool>,
2037        /// No description available
2038        index: String,
2039        /// No description available
2040        pretty: Option<bool>,
2041        /// No description available
2042        source: Option<String>,
2043        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
2044        expand_wildcards: Option<common::ExpandWildcards>,
2045    ) -> Result<crate::common::FieldCapsResponse, Error> {
2046        let local_var_configuration = &self.configuration;
2047
2048        let local_var_client = &local_var_configuration.client;
2049
2050        let local_var_uri_str = format!(
2051            "{}{index}/_field_caps",
2052            local_var_configuration.base_path,
2053            index = index
2054        );
2055        let mut local_var_req_builder =
2056            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2057
2058        if let Some(ref local_var_str) = error_trace {
2059            local_var_req_builder =
2060                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
2061        }
2062        if let Some(ref local_var_str) = ignore_unavailable {
2063            local_var_req_builder =
2064                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
2065        }
2066        if let Some(ref local_var_str) = allow_no_indices {
2067            local_var_req_builder =
2068                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
2069        }
2070        if let Some(ref local_var_str) = human {
2071            local_var_req_builder =
2072                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
2073        }
2074        if let Some(ref local_var_str) = include_unmapped {
2075            local_var_req_builder =
2076                local_var_req_builder.query(&[("include_unmapped", &local_var_str.to_string())]);
2077        }
2078        if let Some(ref local_var_str) = fields {
2079            local_var_req_builder =
2080                local_var_req_builder.query(&[("fields", &local_var_str.to_string())]);
2081        }
2082        if let Some(ref local_var_str) = pretty {
2083            local_var_req_builder =
2084                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
2085        }
2086        if let Some(ref local_var_str) = source {
2087            local_var_req_builder =
2088                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
2089        }
2090        if let Some(ref local_var_str) = filter_path {
2091            local_var_req_builder =
2092                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
2093        }
2094        if let Some(ref local_var_str) = expand_wildcards {
2095            local_var_req_builder =
2096                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
2097        }
2098
2099        local_var_req_builder = local_var_req_builder.json(&field_caps);
2100
2101        let local_var_req = local_var_req_builder.build()?;
2102        let local_var_resp = local_var_client.execute(local_var_req).await?;
2103
2104        let local_var_status = local_var_resp.status();
2105        let local_var_content = local_var_resp.text().await?;
2106
2107        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2108            serde_json::from_str(&local_var_content).map_err(Error::from)
2109        } else {
2110            let local_var_error = ResponseContent {
2111                status: local_var_status,
2112                content: local_var_content,
2113            };
2114            Err(Error::ApiError(local_var_error))
2115        }
2116    }
2117    ///
2118    /// Returns a document.
2119    #[builder(on(String, into))]
2120    pub async fn get(
2121        &self,
2122        /// No description available
2123        id: String,
2124        /// No description available
2125        index: String,
2126
2127        /// No description available
2128        source_excludes: Option<common::SourceExcludes>,
2129        /// No description available
2130        source_includes: Option<common::SourceIncludes>,
2131        /// No description available
2132        error_trace: Option<bool>,
2133        /// No description available
2134        filter_path: Option<common::FilterPath>,
2135        /// No description available
2136        human: Option<bool>,
2137        /// No description available
2138        preference: Option<String>,
2139        /// No description available
2140        pretty: Option<bool>,
2141        /// No description available
2142        realtime: Option<bool>,
2143        /// No description available
2144        refresh: Option<common::Refresh>,
2145        /// No description available
2146        routing: Option<common::Routing>,
2147        /// No description available
2148        source: Option<String>,
2149        /// No description available
2150        stored_fields: Option<common::StoredFields>,
2151        /// No description available
2152        version: Option<i32>,
2153        /// No description available
2154        version_type: Option<String>,
2155    ) -> Result<crate::core::get::GetResult, Error> {
2156        let local_var_configuration = &self.configuration;
2157
2158        let local_var_client = &local_var_configuration.client;
2159
2160        let local_var_uri_str = format!(
2161            "{}{index}/_doc/{id}",
2162            local_var_configuration.base_path,
2163            index = index,
2164            id = id
2165        );
2166        let mut local_var_req_builder =
2167            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
2168
2169        if let Some(ref local_var_str) = routing {
2170            local_var_req_builder =
2171                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
2172        }
2173        if let Some(ref local_var_str) = filter_path {
2174            local_var_req_builder =
2175                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
2176        }
2177        if let Some(ref local_var_str) = source_excludes {
2178            local_var_req_builder =
2179                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
2180        }
2181        if let Some(ref local_var_str) = source_includes {
2182            local_var_req_builder =
2183                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
2184        }
2185        if let Some(ref local_var_str) = refresh {
2186            local_var_req_builder =
2187                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
2188        }
2189        if let Some(ref local_var_str) = realtime {
2190            local_var_req_builder =
2191                local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
2192        }
2193        if let Some(ref local_var_str) = stored_fields {
2194            local_var_req_builder =
2195                local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
2196        }
2197        if let Some(ref local_var_str) = pretty {
2198            local_var_req_builder =
2199                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
2200        }
2201        if let Some(ref local_var_str) = version_type {
2202            local_var_req_builder =
2203                local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
2204        }
2205        if let Some(ref local_var_str) = version {
2206            local_var_req_builder =
2207                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
2208        }
2209        if let Some(ref local_var_str) = preference {
2210            local_var_req_builder =
2211                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
2212        }
2213        if let Some(ref local_var_str) = source {
2214            local_var_req_builder =
2215                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
2216        }
2217        if let Some(ref local_var_str) = human {
2218            local_var_req_builder =
2219                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
2220        }
2221        if let Some(ref local_var_str) = error_trace {
2222            local_var_req_builder =
2223                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
2224        }
2225
2226        let local_var_req = local_var_req_builder.build()?;
2227        let local_var_resp = local_var_client.execute(local_var_req).await?;
2228
2229        let local_var_status = local_var_resp.status();
2230        let local_var_content = local_var_resp.text().await?;
2231
2232        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2233            serde_json::from_str(&local_var_content).map_err(Error::from)
2234        } else {
2235            if local_var_status == reqwest::StatusCode::NOT_FOUND {
2236                return Err(Error::DocumentNotFoundError(index, id));
2237            } else {
2238                let local_var_error = ResponseContent {
2239                    status: local_var_status,
2240                    content: local_var_content,
2241                };
2242                Err(Error::ApiError(local_var_error))
2243            }
2244        }
2245    }
2246    ///
2247    /// Removes a document from the index.
2248    #[builder(on(String, into))]
2249    pub async fn delete(
2250        &self,
2251        /// No description available
2252        index: String,
2253        /// No description available
2254        id: String,
2255        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
2256        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
2257        timeout: Option<String>,
2258        /// No description available
2259        error_trace: Option<bool>,
2260        /// No description available
2261        filter_path: Option<common::FilterPath>,
2262        /// No description available
2263        human: Option<bool>,
2264        /// No description available
2265        if_primary_term: Option<i32>,
2266        /// No description available
2267        if_seq_no: Option<i32>,
2268        /// No description available
2269        pretty: Option<bool>,
2270        /// No description available
2271        refresh: Option<common::Refresh>,
2272        /// No description available
2273        routing: Option<common::Routing>,
2274        /// No description available
2275        source: Option<String>,
2276        /// No description available
2277        version: Option<i32>,
2278        /// No description available
2279        version_type: Option<String>,
2280        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
2281        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
2282    ) -> Result<DocumentDeleteResponse, Error> {
2283        let local_var_configuration = &self.configuration;
2284
2285        let local_var_client = &local_var_configuration.client;
2286
2287        let local_var_uri_str = format!(
2288            "{}{index}/_doc/{id}",
2289            local_var_configuration.base_path,
2290            id = id,
2291            index = index
2292        );
2293        let mut local_var_req_builder =
2294            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
2295
2296        if let Some(ref local_var_str) = refresh {
2297            local_var_req_builder =
2298                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
2299        }
2300        if let Some(ref local_var_str) = source {
2301            local_var_req_builder =
2302                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
2303        }
2304        if let Some(ref local_var_str) = error_trace {
2305            local_var_req_builder =
2306                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
2307        }
2308        if let Some(ref local_var_str) = if_seq_no {
2309            local_var_req_builder =
2310                local_var_req_builder.query(&[("if_seq_no", &local_var_str.to_string())]);
2311        }
2312        if let Some(ref local_var_str) = filter_path {
2313            local_var_req_builder =
2314                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
2315        }
2316        if let Some(ref local_var_str) = if_primary_term {
2317            local_var_req_builder =
2318                local_var_req_builder.query(&[("if_primary_term", &local_var_str.to_string())]);
2319        }
2320        if let Some(ref local_var_str) = routing {
2321            local_var_req_builder =
2322                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
2323        }
2324        if let Some(ref local_var_str) = wait_for_active_shards {
2325            local_var_req_builder = local_var_req_builder
2326                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
2327        }
2328        if let Some(ref local_var_str) = timeout {
2329            local_var_req_builder =
2330                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
2331        }
2332        if let Some(ref local_var_str) = version_type {
2333            local_var_req_builder =
2334                local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
2335        }
2336        if let Some(ref local_var_str) = human {
2337            local_var_req_builder =
2338                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
2339        }
2340        if let Some(ref local_var_str) = version {
2341            local_var_req_builder =
2342                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
2343        }
2344        if let Some(ref local_var_str) = pretty {
2345            local_var_req_builder =
2346                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
2347        }
2348
2349        let local_var_req = local_var_req_builder.build()?;
2350        let local_var_resp = local_var_client.execute(local_var_req).await?;
2351
2352        let local_var_status = local_var_resp.status();
2353        let local_var_content = local_var_resp.text().await?;
2354
2355        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2356            serde_json::from_str(&local_var_content).map_err(Error::from)
2357        } else {
2358            let local_var_error = ResponseContent {
2359                status: local_var_status,
2360                content: local_var_content,
2361            };
2362            Err(Error::ApiError(local_var_error))
2363        }
2364    }
2365    ///
2366    /// Returns multiple termvectors in one request.
2367    #[builder(on(String, into))]
2368    pub async fn mtermvectors(
2369        &self,
2370        /// Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.
2371        mtermvectors: common::Mtermvectors,
2372        /// No description available
2373        error_trace: Option<bool>,
2374        /// No description available
2375        field_statistics: Option<bool>,
2376        /// No description available
2377        fields: Option<common::Fields>,
2378        /// No description available
2379        filter_path: Option<common::FilterPath>,
2380        /// No description available
2381        human: Option<bool>,
2382        /// No description available
2383        ids: Option<Vec<String>>,
2384        /// No description available
2385        index: String,
2386        /// No description available
2387        offsets: Option<bool>,
2388        /// No description available
2389        payloads: Option<bool>,
2390        /// No description available
2391        positions: Option<bool>,
2392        /// No description available
2393        preference: Option<String>,
2394        /// No description available
2395        pretty: Option<bool>,
2396        /// No description available
2397        realtime: Option<bool>,
2398        /// No description available
2399        routing: Option<common::Routing>,
2400        /// No description available
2401        source: Option<String>,
2402        /// No description available
2403        term_statistics: Option<bool>,
2404        /// No description available
2405        version: Option<i32>,
2406        /// No description available
2407        version_type: Option<String>,
2408    ) -> Result<crate::common::MtermvectorsResponse, Error> {
2409        let local_var_configuration = &self.configuration;
2410
2411        let local_var_client = &local_var_configuration.client;
2412
2413        let local_var_uri_str = format!(
2414            "{}{index}/_mtermvectors",
2415            local_var_configuration.base_path,
2416            index = index
2417        );
2418        let mut local_var_req_builder =
2419            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2420
2421        if let Some(ref local_var_str) = human {
2422            local_var_req_builder =
2423                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
2424        }
2425        if let Some(ref local_var_str) = filter_path {
2426            local_var_req_builder =
2427                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
2428        }
2429        if let Some(ref local_var_str) = ids {
2430            local_var_req_builder = match "multi" {
2431                "multi" => local_var_req_builder.query(
2432                    &local_var_str
2433                        .into_iter()
2434                        .map(|p| ("ids".to_owned(), p.to_string()))
2435                        .collect::<Vec<(std::string::String, std::string::String)>>(),
2436                ),
2437                _ => local_var_req_builder.query(&[(
2438                    "ids",
2439                    &local_var_str
2440                        .into_iter()
2441                        .map(|p| p.to_string())
2442                        .collect::<Vec<String>>()
2443                        .join(",")
2444                        .to_string(),
2445                )]),
2446            };
2447        }
2448        if let Some(ref local_var_str) = error_trace {
2449            local_var_req_builder =
2450                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
2451        }
2452        if let Some(ref local_var_str) = pretty {
2453            local_var_req_builder =
2454                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
2455        }
2456        if let Some(ref local_var_str) = realtime {
2457            local_var_req_builder =
2458                local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
2459        }
2460        if let Some(ref local_var_str) = positions {
2461            local_var_req_builder =
2462                local_var_req_builder.query(&[("positions", &local_var_str.to_string())]);
2463        }
2464        if let Some(ref local_var_str) = payloads {
2465            local_var_req_builder =
2466                local_var_req_builder.query(&[("payloads", &local_var_str.to_string())]);
2467        }
2468        if let Some(ref local_var_str) = term_statistics {
2469            local_var_req_builder =
2470                local_var_req_builder.query(&[("term_statistics", &local_var_str.to_string())]);
2471        }
2472        if let Some(ref local_var_str) = fields {
2473            local_var_req_builder =
2474                local_var_req_builder.query(&[("fields", &local_var_str.to_string())]);
2475        }
2476        if let Some(ref local_var_str) = preference {
2477            local_var_req_builder =
2478                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
2479        }
2480        if let Some(ref local_var_str) = version {
2481            local_var_req_builder =
2482                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
2483        }
2484        if let Some(ref local_var_str) = field_statistics {
2485            local_var_req_builder =
2486                local_var_req_builder.query(&[("field_statistics", &local_var_str.to_string())]);
2487        }
2488        if let Some(ref local_var_str) = version_type {
2489            local_var_req_builder =
2490                local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
2491        }
2492        if let Some(ref local_var_str) = offsets {
2493            local_var_req_builder =
2494                local_var_req_builder.query(&[("offsets", &local_var_str.to_string())]);
2495        }
2496        if let Some(ref local_var_str) = source {
2497            local_var_req_builder =
2498                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
2499        }
2500        if let Some(ref local_var_str) = routing {
2501            local_var_req_builder =
2502                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
2503        }
2504
2505        local_var_req_builder = local_var_req_builder.json(&mtermvectors);
2506
2507        let local_var_req = local_var_req_builder.build()?;
2508        let local_var_resp = local_var_client.execute(local_var_req).await?;
2509
2510        let local_var_status = local_var_resp.status();
2511        let local_var_content = local_var_resp.text().await?;
2512
2513        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2514            serde_json::from_str(&local_var_content).map_err(Error::from)
2515        } else {
2516            let local_var_error = ResponseContent {
2517                status: local_var_status,
2518                content: local_var_content,
2519            };
2520            Err(Error::ApiError(local_var_error))
2521        }
2522    }
2523    ///
2524    /// Returns results matching a query.
2525    #[builder(on(String, into))]
2526    pub async fn search_with_index(
2527        &self,
2528        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
2529        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
2530        cancel_after_time_interval: Option<String>,
2531        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
2532        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
2533        scroll: Option<String>,
2534        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
2535        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
2536        timeout: Option<String>,
2537        /// Customizable sequence of processing stages applied to search queries.
2538        search_pipeline: Option<String>,
2539        /// Indicates whether `hit.matched_queries` should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false)
2540        include_named_queries_score: Option<bool>,
2541        /// No description available
2542        source_excludes: Option<common::SourceExcludes>,
2543        /// No description available
2544        source_includes: Option<common::SourceIncludes>,
2545        /// No description available
2546        allow_no_indices: Option<bool>,
2547        /// No description available
2548        allow_partial_search_results: Option<bool>,
2549        /// No description available
2550        analyze_wildcard: Option<bool>,
2551        /// No description available
2552        analyzer: Option<String>,
2553        /// No description available
2554        batched_reduce_size: Option<i32>,
2555        /// No description available
2556        ccs_minimize_roundtrips: Option<bool>,
2557        /// No description available
2558        default_operator: Option<String>,
2559        /// No description available
2560        df: Option<String>,
2561        /// No description available
2562        docvalue_fields: Option<common::DocvalueFields>,
2563        /// No description available
2564        error_trace: Option<bool>,
2565        /// No description available
2566        explain: Option<bool>,
2567        /// No description available
2568        filter_path: Option<common::FilterPath>,
2569        /// No description available
2570        from: Option<i32>,
2571        /// No description available
2572        human: Option<bool>,
2573        /// No description available
2574        ignore_throttled: Option<bool>,
2575        /// No description available
2576        ignore_unavailable: Option<bool>,
2577        /// No description available
2578        index: String,
2579        /// No description available
2580        lenient: Option<bool>,
2581        /// No description available
2582        max_concurrent_shard_requests: Option<i32>,
2583        /// No description available
2584        phase_took: Option<bool>,
2585        /// No description available
2586        pre_filter_shard_size: Option<i32>,
2587        /// No description available
2588        preference: Option<String>,
2589        /// No description available
2590        pretty: Option<bool>,
2591        /// No description available
2592        q: Option<String>,
2593        /// No description available
2594        request_cache: Option<bool>,
2595        /// No description available
2596        rest_total_hits_as_int: Option<bool>,
2597        /// No description available
2598        routing: Option<common::Routing>,
2599        /// No description available
2600        search_type: Option<common::SearchType>,
2601        /// No description available
2602        seq_no_primary_term: Option<bool>,
2603        /// No description available
2604        size: Option<i32>,
2605        /// No description available
2606        sort: Option<common::Sort>,
2607        /// No description available
2608        source: Option<String>,
2609        /// No description available
2610        stats: Option<Vec<String>>,
2611        /// No description available
2612        stored_fields: Option<common::StoredFields>,
2613        /// No description available
2614        suggest_mode: Option<String>,
2615        /// No description available
2616        suggest_size: Option<i32>,
2617        /// No description available
2618        suggest_text: Option<String>,
2619        /// No description available
2620        terminate_after: Option<i32>,
2621        /// No description available
2622        track_scores: Option<bool>,
2623        /// No description available
2624        typed_keys: Option<bool>,
2625        /// No description available
2626        version: Option<bool>,
2627        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
2628        expand_wildcards: Option<common::ExpandWildcards>,
2629        /// The number of hits matching the query. When `true`, the exact
2630        /// number of hits is returned at the cost of some performance. When `false`, the
2631        /// response does not include the total number of hits matching the query.
2632        /// Default is `10,000` hits.
2633        track_total_hits: Option<common::TrackTotalHits>,
2634        /// The path to a field or an array of paths. Some APIs support wildcards in the path, which allows you to select multiple fields.
2635        suggest_field: Option<String>,
2636        /// The search definition using the Query DSL
2637        search_with_index: common::SearchWithIndex,
2638    ) -> Result<SearchWithIndexSuccess, Error> {
2639        let local_var_configuration = &self.configuration;
2640
2641        let local_var_client = &local_var_configuration.client;
2642
2643        let local_var_uri_str = format!(
2644            "{}{index}/_search",
2645            local_var_configuration.base_path,
2646            index = index
2647        );
2648        let mut local_var_req_builder =
2649            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2650
2651        if let Some(ref local_var_str) = ignore_unavailable {
2652            local_var_req_builder =
2653                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
2654        }
2655        if let Some(ref local_var_str) = typed_keys {
2656            local_var_req_builder =
2657                local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
2658        }
2659        if let Some(ref local_var_str) = rest_total_hits_as_int {
2660            local_var_req_builder = local_var_req_builder
2661                .query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
2662        }
2663        if let Some(ref local_var_str) = max_concurrent_shard_requests {
2664            local_var_req_builder = local_var_req_builder
2665                .query(&[("max_concurrent_shard_requests", &local_var_str.to_string())]);
2666        }
2667        if let Some(ref local_var_str) = cancel_after_time_interval {
2668            local_var_req_builder = local_var_req_builder
2669                .query(&[("cancel_after_time_interval", &local_var_str.to_string())]);
2670        }
2671        if let Some(ref local_var_str) = docvalue_fields {
2672            local_var_req_builder =
2673                local_var_req_builder.query(&[("docvalue_fields", &local_var_str.to_string())]);
2674        }
2675        if let Some(ref local_var_str) = include_named_queries_score {
2676            local_var_req_builder = local_var_req_builder
2677                .query(&[("include_named_queries_score", &local_var_str.to_string())]);
2678        }
2679        if let Some(ref local_var_str) = timeout {
2680            local_var_req_builder =
2681                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
2682        }
2683        if let Some(ref local_var_str) = version {
2684            local_var_req_builder =
2685                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
2686        }
2687        if let Some(ref local_var_str) = explain {
2688            local_var_req_builder =
2689                local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
2690        }
2691        if let Some(ref local_var_str) = lenient {
2692            local_var_req_builder =
2693                local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
2694        }
2695        if let Some(ref local_var_str) = ccs_minimize_roundtrips {
2696            local_var_req_builder = local_var_req_builder
2697                .query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
2698        }
2699        if let Some(ref local_var_str) = search_type {
2700            local_var_req_builder =
2701                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
2702        }
2703        if let Some(ref local_var_str) = source_excludes {
2704            local_var_req_builder =
2705                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
2706        }
2707        if let Some(ref local_var_str) = sort {
2708            local_var_req_builder =
2709                local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
2710        }
2711        if let Some(ref local_var_str) = allow_partial_search_results {
2712            local_var_req_builder = local_var_req_builder
2713                .query(&[("allow_partial_search_results", &local_var_str.to_string())]);
2714        }
2715        if let Some(ref local_var_str) = suggest_mode {
2716            local_var_req_builder =
2717                local_var_req_builder.query(&[("suggest_mode", &local_var_str.to_string())]);
2718        }
2719        if let Some(ref local_var_str) = pretty {
2720            local_var_req_builder =
2721                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
2722        }
2723        if let Some(ref local_var_str) = filter_path {
2724            local_var_req_builder =
2725                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
2726        }
2727        if let Some(ref local_var_str) = track_scores {
2728            local_var_req_builder =
2729                local_var_req_builder.query(&[("track_scores", &local_var_str.to_string())]);
2730        }
2731        if let Some(ref local_var_str) = batched_reduce_size {
2732            local_var_req_builder =
2733                local_var_req_builder.query(&[("batched_reduce_size", &local_var_str.to_string())]);
2734        }
2735        if let Some(ref local_var_str) = request_cache {
2736            local_var_req_builder =
2737                local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
2738        }
2739        if let Some(ref local_var_str) = expand_wildcards {
2740            local_var_req_builder =
2741                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
2742        }
2743        if let Some(ref local_var_str) = analyzer {
2744            local_var_req_builder =
2745                local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
2746        }
2747        if let Some(ref local_var_str) = ignore_throttled {
2748            local_var_req_builder =
2749                local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
2750        }
2751        if let Some(ref local_var_str) = preference {
2752            local_var_req_builder =
2753                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
2754        }
2755        if let Some(ref local_var_str) = search_pipeline {
2756            local_var_req_builder =
2757                local_var_req_builder.query(&[("search_pipeline", &local_var_str.to_string())]);
2758        }
2759        if let Some(ref local_var_str) = suggest_text {
2760            local_var_req_builder =
2761                local_var_req_builder.query(&[("suggest_text", &local_var_str.to_string())]);
2762        }
2763        if let Some(ref local_var_str) = from {
2764            local_var_req_builder =
2765                local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
2766        }
2767        if let Some(ref local_var_str) = stored_fields {
2768            local_var_req_builder =
2769                local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
2770        }
2771        if let Some(ref local_var_str) = scroll {
2772            local_var_req_builder =
2773                local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
2774        }
2775        if let Some(ref local_var_str) = analyze_wildcard {
2776            local_var_req_builder =
2777                local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
2778        }
2779        if let Some(ref local_var_str) = pre_filter_shard_size {
2780            local_var_req_builder = local_var_req_builder
2781                .query(&[("pre_filter_shard_size", &local_var_str.to_string())]);
2782        }
2783        if let Some(ref local_var_str) = df {
2784            local_var_req_builder =
2785                local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
2786        }
2787        if let Some(ref local_var_str) = routing {
2788            local_var_req_builder =
2789                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
2790        }
2791        if let Some(ref local_var_str) = suggest_size {
2792            local_var_req_builder =
2793                local_var_req_builder.query(&[("suggest_size", &local_var_str.to_string())]);
2794        }
2795        if let Some(ref local_var_str) = track_total_hits {
2796            local_var_req_builder =
2797                local_var_req_builder.query(&[("track_total_hits", &local_var_str.to_string())]);
2798        }
2799        if let Some(ref local_var_str) = phase_took {
2800            local_var_req_builder =
2801                local_var_req_builder.query(&[("phase_took", &local_var_str.to_string())]);
2802        }
2803        if let Some(ref local_var_str) = stats {
2804            local_var_req_builder = match "multi" {
2805                "multi" => local_var_req_builder.query(
2806                    &local_var_str
2807                        .into_iter()
2808                        .map(|p| ("stats".to_owned(), p.to_string()))
2809                        .collect::<Vec<(std::string::String, std::string::String)>>(),
2810                ),
2811                _ => local_var_req_builder.query(&[(
2812                    "stats",
2813                    &local_var_str
2814                        .into_iter()
2815                        .map(|p| p.to_string())
2816                        .collect::<Vec<String>>()
2817                        .join(",")
2818                        .to_string(),
2819                )]),
2820            };
2821        }
2822        if let Some(ref local_var_str) = source_includes {
2823            local_var_req_builder =
2824                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
2825        }
2826        if let Some(ref local_var_str) = terminate_after {
2827            local_var_req_builder =
2828                local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
2829        }
2830        if let Some(ref local_var_str) = source {
2831            local_var_req_builder =
2832                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
2833        }
2834        if let Some(ref local_var_str) = suggest_field {
2835            local_var_req_builder =
2836                local_var_req_builder.query(&[("suggest_field", &local_var_str.to_string())]);
2837        }
2838        if let Some(ref local_var_str) = allow_no_indices {
2839            local_var_req_builder =
2840                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
2841        }
2842        if let Some(ref local_var_str) = q {
2843            local_var_req_builder =
2844                local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
2845        }
2846        if let Some(ref local_var_str) = size {
2847            local_var_req_builder =
2848                local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
2849        }
2850        if let Some(ref local_var_str) = default_operator {
2851            local_var_req_builder =
2852                local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
2853        }
2854        if let Some(ref local_var_str) = human {
2855            local_var_req_builder =
2856                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
2857        }
2858        if let Some(ref local_var_str) = error_trace {
2859            local_var_req_builder =
2860                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
2861        }
2862        if let Some(ref local_var_str) = seq_no_primary_term {
2863            local_var_req_builder =
2864                local_var_req_builder.query(&[("seq_no_primary_term", &local_var_str.to_string())]);
2865        }
2866
2867        local_var_req_builder = local_var_req_builder.json(&search_with_index);
2868
2869        let local_var_req = local_var_req_builder.build()?;
2870        let local_var_resp = local_var_client.execute(local_var_req).await?;
2871
2872        let local_var_status = local_var_resp.status();
2873        let local_var_content = local_var_resp.text().await?;
2874
2875        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2876            serde_json::from_str(&local_var_content).map_err(Error::from)
2877        } else {
2878            let local_var_error = ResponseContent {
2879                status: local_var_status,
2880                content: local_var_content,
2881            };
2882            Err(Error::ApiError(local_var_error))
2883        }
2884    }
2885    ///
2886    /// Allows to get multiple documents in one request.
2887    #[builder(on(String, into))]
2888    pub async fn mget(
2889        &self,
2890        /// No description available
2891        index: String,
2892        /// Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL.
2893        mget: common::Mget,
2894        /// No description available
2895        source_excludes: Option<common::SourceExcludes>,
2896        /// No description available
2897        source_includes: Option<common::SourceIncludes>,
2898        /// No description available
2899        error_trace: Option<bool>,
2900        /// No description available
2901        filter_path: Option<common::FilterPath>,
2902        /// No description available
2903        human: Option<bool>,
2904        /// No description available
2905        preference: Option<String>,
2906        /// No description available
2907        pretty: Option<bool>,
2908        /// No description available
2909        realtime: Option<bool>,
2910        /// No description available
2911        refresh: Option<common::Refresh>,
2912        /// No description available
2913        routing: Option<common::Routing>,
2914        /// No description available
2915        source: Option<String>,
2916        /// No description available
2917        stored_fields: Option<common::StoredFields>,
2918    ) -> Result<crate::common::MgetResponse, Error> {
2919        let local_var_configuration = &self.configuration;
2920
2921        let local_var_client = &local_var_configuration.client;
2922
2923        let local_var_uri_str = format!(
2924            "{}{index}/_mget",
2925            local_var_configuration.base_path,
2926            index = index
2927        );
2928        let mut local_var_req_builder =
2929            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
2930
2931        if let Some(ref local_var_str) = source {
2932            local_var_req_builder =
2933                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
2934        }
2935        if let Some(ref local_var_str) = error_trace {
2936            local_var_req_builder =
2937                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
2938        }
2939        if let Some(ref local_var_str) = filter_path {
2940            local_var_req_builder =
2941                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
2942        }
2943        if let Some(ref local_var_str) = realtime {
2944            local_var_req_builder =
2945                local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
2946        }
2947        if let Some(ref local_var_str) = stored_fields {
2948            local_var_req_builder =
2949                local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
2950        }
2951        if let Some(ref local_var_str) = source_excludes {
2952            local_var_req_builder =
2953                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
2954        }
2955        if let Some(ref local_var_str) = pretty {
2956            local_var_req_builder =
2957                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
2958        }
2959        if let Some(ref local_var_str) = refresh {
2960            local_var_req_builder =
2961                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
2962        }
2963        if let Some(ref local_var_str) = routing {
2964            local_var_req_builder =
2965                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
2966        }
2967        if let Some(ref local_var_str) = human {
2968            local_var_req_builder =
2969                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
2970        }
2971        if let Some(ref local_var_str) = source_includes {
2972            local_var_req_builder =
2973                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
2974        }
2975        if let Some(ref local_var_str) = preference {
2976            local_var_req_builder =
2977                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
2978        }
2979
2980        local_var_req_builder = local_var_req_builder.json(&mget);
2981
2982        let local_var_req = local_var_req_builder.build()?;
2983        let local_var_resp = local_var_client.execute(local_var_req).await?;
2984
2985        let local_var_status = local_var_resp.status();
2986        let local_var_content = local_var_resp.text().await?;
2987
2988        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
2989            serde_json::from_str(&local_var_content).map_err(Error::from)
2990        } else {
2991            let local_var_error = ResponseContent {
2992                status: local_var_status,
2993                content: local_var_content,
2994            };
2995            Err(Error::ApiError(local_var_error))
2996        }
2997    }
2998    ///
2999    /// Returns available script types, languages and contexts.
3000    #[builder(on(String, into))]
3001    pub async fn get_script_languages(
3002        &self,
3003        /// No description available
3004        error_trace: Option<bool>,
3005        /// No description available
3006        filter_path: Option<common::FilterPath>,
3007        /// No description available
3008        human: Option<bool>,
3009        /// No description available
3010        pretty: Option<bool>,
3011        /// No description available
3012        source: Option<String>,
3013    ) -> Result<crate::common::GetScriptLanguagesResponse, Error> {
3014        let local_var_configuration = &self.configuration;
3015
3016        let local_var_client = &local_var_configuration.client;
3017
3018        let local_var_uri_str = format!("{}_script_language", local_var_configuration.base_path);
3019        let mut local_var_req_builder =
3020            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
3021
3022        if let Some(ref local_var_str) = pretty {
3023            local_var_req_builder =
3024                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
3025        }
3026        if let Some(ref local_var_str) = source {
3027            local_var_req_builder =
3028                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
3029        }
3030        if let Some(ref local_var_str) = error_trace {
3031            local_var_req_builder =
3032                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
3033        }
3034        if let Some(ref local_var_str) = filter_path {
3035            local_var_req_builder =
3036                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
3037        }
3038        if let Some(ref local_var_str) = human {
3039            local_var_req_builder =
3040                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
3041        }
3042
3043        let local_var_req = local_var_req_builder.build()?;
3044        let local_var_resp = local_var_client.execute(local_var_req).await?;
3045
3046        let local_var_status = local_var_resp.status();
3047        let local_var_content = local_var_resp.text().await?;
3048
3049        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3050            serde_json::from_str(&local_var_content).map_err(Error::from)
3051        } else {
3052            let local_var_error = ResponseContent {
3053                status: local_var_status,
3054                content: local_var_content,
3055            };
3056            Err(Error::ApiError(local_var_error))
3057        }
3058    }
3059    ///
3060    /// Explicitly clears the search context for a scroll.
3061    #[builder(on(String, into))]
3062    pub async fn clear_scroll(
3063        &self,
3064        /// Comma-separated list of scroll IDs to clear if none was specified using the `scroll_id` parameter
3065        clear_scroll: Option<common::ClearScroll>,
3066        /// No description available
3067        error_trace: Option<bool>,
3068        /// No description available
3069        filter_path: Option<common::FilterPath>,
3070        /// No description available
3071        human: Option<bool>,
3072        /// No description available
3073        pretty: Option<bool>,
3074        /// No description available
3075        scroll_id: Option<String>,
3076        /// No description available
3077        source: Option<String>,
3078    ) -> Result<ClearScrollSuccess, Error> {
3079        let local_var_configuration = &self.configuration;
3080
3081        let local_var_client = &local_var_configuration.client;
3082
3083        let local_var_uri_str = if let Some(scroll_id) = &scroll_id {
3084            format!(
3085                "{}_search/scroll/{scroll_id}",
3086                local_var_configuration.base_path,
3087                scroll_id = scroll_id
3088            )
3089        } else {
3090            format!("{}_search/scroll", local_var_configuration.base_path)
3091        };
3092        let mut local_var_req_builder =
3093            local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
3094
3095        if let Some(ref local_var_str) = error_trace {
3096            local_var_req_builder =
3097                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
3098        }
3099        if let Some(ref local_var_str) = source {
3100            local_var_req_builder =
3101                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
3102        }
3103        if let Some(ref local_var_str) = human {
3104            local_var_req_builder =
3105                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
3106        }
3107        if let Some(ref local_var_str) = filter_path {
3108            local_var_req_builder =
3109                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
3110        }
3111        if let Some(ref local_var_str) = pretty {
3112            local_var_req_builder =
3113                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
3114        }
3115
3116        local_var_req_builder = local_var_req_builder.json(&clear_scroll);
3117
3118        let local_var_req = local_var_req_builder.build()?;
3119        let local_var_resp = local_var_client.execute(local_var_req).await?;
3120
3121        let local_var_status = local_var_resp.status();
3122        let local_var_content = local_var_resp.text().await?;
3123
3124        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3125            serde_json::from_str(&local_var_content).map_err(Error::from)
3126        } else {
3127            let local_var_error = ResponseContent {
3128                status: local_var_status,
3129                content: local_var_content,
3130            };
3131            Err(Error::ApiError(local_var_error))
3132        }
3133    }
3134    ///
3135    /// Allows to use the Mustache language to pre-render a search definition.
3136    #[builder(on(String, into))]
3137    pub async fn search_template(
3138        &self,
3139        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
3140        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
3141        scroll: Option<String>,
3142        /// No description available
3143        allow_no_indices: Option<bool>,
3144        /// No description available
3145        ccs_minimize_roundtrips: Option<bool>,
3146        /// No description available
3147        error_trace: Option<bool>,
3148        /// No description available
3149        explain: Option<bool>,
3150        /// No description available
3151        filter_path: Option<common::FilterPath>,
3152        /// No description available
3153        human: Option<bool>,
3154        /// No description available
3155        ignore_throttled: Option<bool>,
3156        /// No description available
3157        ignore_unavailable: Option<bool>,
3158        /// No description available
3159        preference: Option<String>,
3160        /// No description available
3161        pretty: Option<bool>,
3162        /// No description available
3163        profile: Option<bool>,
3164        /// No description available
3165        rest_total_hits_as_int: Option<bool>,
3166        /// No description available
3167        routing: Option<common::Routing>,
3168        /// No description available
3169        search_type: Option<common::SearchType>,
3170        /// No description available
3171        source: Option<String>,
3172        /// No description available
3173        typed_keys: Option<bool>,
3174        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
3175        expand_wildcards: Option<common::ExpandWildcards>,
3176        /// The search definition template and its parameters.
3177        search_template: common::SearchTemplate,
3178    ) -> Result<crate::common::SearchTemplateResponse, Error> {
3179        let local_var_configuration = &self.configuration;
3180
3181        let local_var_client = &local_var_configuration.client;
3182
3183        let local_var_uri_str = format!("{}_search/template", local_var_configuration.base_path);
3184        let mut local_var_req_builder =
3185            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
3186
3187        if let Some(ref local_var_str) = routing {
3188            local_var_req_builder =
3189                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
3190        }
3191        if let Some(ref local_var_str) = ignore_unavailable {
3192            local_var_req_builder =
3193                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
3194        }
3195        if let Some(ref local_var_str) = ignore_throttled {
3196            local_var_req_builder =
3197                local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
3198        }
3199        if let Some(ref local_var_str) = expand_wildcards {
3200            local_var_req_builder =
3201                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
3202        }
3203        if let Some(ref local_var_str) = human {
3204            local_var_req_builder =
3205                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
3206        }
3207        if let Some(ref local_var_str) = error_trace {
3208            local_var_req_builder =
3209                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
3210        }
3211        if let Some(ref local_var_str) = source {
3212            local_var_req_builder =
3213                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
3214        }
3215        if let Some(ref local_var_str) = filter_path {
3216            local_var_req_builder =
3217                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
3218        }
3219        if let Some(ref local_var_str) = ccs_minimize_roundtrips {
3220            local_var_req_builder = local_var_req_builder
3221                .query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
3222        }
3223        if let Some(ref local_var_str) = allow_no_indices {
3224            local_var_req_builder =
3225                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
3226        }
3227        if let Some(ref local_var_str) = scroll {
3228            local_var_req_builder =
3229                local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
3230        }
3231        if let Some(ref local_var_str) = rest_total_hits_as_int {
3232            local_var_req_builder = local_var_req_builder
3233                .query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
3234        }
3235        if let Some(ref local_var_str) = profile {
3236            local_var_req_builder =
3237                local_var_req_builder.query(&[("profile", &local_var_str.to_string())]);
3238        }
3239        if let Some(ref local_var_str) = typed_keys {
3240            local_var_req_builder =
3241                local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
3242        }
3243        if let Some(ref local_var_str) = search_type {
3244            local_var_req_builder =
3245                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
3246        }
3247        if let Some(ref local_var_str) = pretty {
3248            local_var_req_builder =
3249                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
3250        }
3251        if let Some(ref local_var_str) = explain {
3252            local_var_req_builder =
3253                local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
3254        }
3255        if let Some(ref local_var_str) = preference {
3256            local_var_req_builder =
3257                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
3258        }
3259
3260        local_var_req_builder = local_var_req_builder.json(&search_template);
3261
3262        let local_var_req = local_var_req_builder.build()?;
3263        let local_var_resp = local_var_client.execute(local_var_req).await?;
3264
3265        let local_var_status = local_var_resp.status();
3266        let local_var_content = local_var_resp.text().await?;
3267
3268        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3269            serde_json::from_str(&local_var_content).map_err(Error::from)
3270        } else {
3271            let local_var_error = ResponseContent {
3272                status: local_var_status,
3273                content: local_var_content,
3274            };
3275            Err(Error::ApiError(local_var_error))
3276        }
3277    }
3278    ///
3279    /// Returns number of documents matching a query.
3280    #[builder(on(String, into))]
3281    pub async fn count(
3282        &self,
3283        /// No description available
3284        index: String,
3285        /// Query to restrict the results specified with the Query DSL (optional)
3286        count: Option<common::Count>,
3287        /// Query to restrict the results specified with the Query DSL (optional)
3288        query: Option<crate::dsl::Query>,
3289        /// No description available
3290        allow_no_indices: Option<bool>,
3291        /// No description available
3292        analyze_wildcard: Option<bool>,
3293        /// No description available
3294        analyzer: Option<String>,
3295        /// No description available
3296        default_operator: Option<String>,
3297        /// No description available
3298        df: Option<String>,
3299        /// No description available
3300        error_trace: Option<bool>,
3301        /// No description available
3302        filter_path: Option<common::FilterPath>,
3303        /// No description available
3304        human: Option<bool>,
3305        /// No description available
3306        ignore_throttled: Option<bool>,
3307        /// No description available
3308        ignore_unavailable: Option<bool>,
3309        /// No description available
3310        lenient: Option<bool>,
3311        /// No description available
3312        min_score: Option<f64>,
3313        /// No description available
3314        preference: Option<String>,
3315        /// No description available
3316        pretty: Option<bool>,
3317        /// No description available
3318        q: Option<String>,
3319        /// No description available
3320        routing: Option<common::Routing>,
3321        /// No description available
3322        source: Option<String>,
3323        /// No description available
3324        terminate_after: Option<i32>,
3325        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
3326        expand_wildcards: Option<common::ExpandWildcards>,
3327    ) -> Result<crate::common::CountResponse, Error> {
3328        let local_var_configuration = &self.configuration;
3329
3330        let local_var_client = &local_var_configuration.client;
3331
3332        let local_var_uri_str = format!(
3333            "{}{index}/_count",
3334            local_var_configuration.base_path,
3335            index = index
3336        );
3337        let mut local_var_req_builder =
3338            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
3339
3340        if let Some(ref local_var_str) = default_operator {
3341            local_var_req_builder =
3342                local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
3343        }
3344        if let Some(ref local_var_str) = terminate_after {
3345            local_var_req_builder =
3346                local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
3347        }
3348        if let Some(ref local_var_str) = human {
3349            local_var_req_builder =
3350                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
3351        }
3352        if let Some(ref local_var_str) = routing {
3353            local_var_req_builder =
3354                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
3355        }
3356        if let Some(ref local_var_str) = analyze_wildcard {
3357            local_var_req_builder =
3358                local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
3359        }
3360        if let Some(ref local_var_str) = expand_wildcards {
3361            local_var_req_builder =
3362                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
3363        }
3364        if let Some(ref local_var_str) = ignore_unavailable {
3365            local_var_req_builder =
3366                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
3367        }
3368        if let Some(ref local_var_str) = pretty {
3369            local_var_req_builder =
3370                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
3371        }
3372        if let Some(ref local_var_str) = min_score {
3373            local_var_req_builder =
3374                local_var_req_builder.query(&[("min_score", &local_var_str.to_string())]);
3375        }
3376        if let Some(ref local_var_str) = filter_path {
3377            local_var_req_builder =
3378                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
3379        }
3380        if let Some(ref local_var_str) = source {
3381            local_var_req_builder =
3382                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
3383        }
3384        if let Some(ref local_var_str) = ignore_throttled {
3385            local_var_req_builder =
3386                local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
3387        }
3388        if let Some(ref local_var_str) = lenient {
3389            local_var_req_builder =
3390                local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
3391        }
3392        if let Some(ref local_var_str) = analyzer {
3393            local_var_req_builder =
3394                local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
3395        }
3396        if let Some(ref local_var_str) = df {
3397            local_var_req_builder =
3398                local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
3399        }
3400        if let Some(ref local_var_str) = error_trace {
3401            local_var_req_builder =
3402                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
3403        }
3404        if let Some(ref local_var_str) = allow_no_indices {
3405            local_var_req_builder =
3406                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
3407        }
3408        if let Some(ref local_var_str) = preference {
3409            local_var_req_builder =
3410                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
3411        }
3412        if let Some(ref local_var_str) = q {
3413            local_var_req_builder =
3414                local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
3415        }
3416        let mut count = count;
3417        if let Some(ref query) = query {
3418            count = Some(common::Count {
3419                query: Some(query.clone()),
3420            });
3421        }
3422
3423        if let Some(ref body) = count {
3424            local_var_req_builder = local_var_req_builder.json(&body);
3425        }
3426
3427        let local_var_req = local_var_req_builder.build()?;
3428        let local_var_resp = local_var_client.execute(local_var_req).await?;
3429
3430        let local_var_status = local_var_resp.status();
3431        let local_var_content = local_var_resp.text().await?;
3432
3433        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3434            serde_json::from_str(&local_var_content).map_err(Error::from)
3435        } else {
3436            let local_var_error = ResponseContent {
3437                status: local_var_status,
3438                content: local_var_content,
3439            };
3440            Err(Error::ApiError(local_var_error))
3441        }
3442    }
3443    ///
3444    /// Returns information about the indexes and shards that a search request would be executed against.
3445    #[builder(on(String, into))]
3446    pub async fn search_shards_with_index(
3447        &self,
3448        /// No description available
3449        allow_no_indices: Option<bool>,
3450        /// No description available
3451        error_trace: Option<bool>,
3452        /// No description available
3453        filter_path: Option<common::FilterPath>,
3454        /// No description available
3455        human: Option<bool>,
3456        /// No description available
3457        ignore_unavailable: Option<bool>,
3458        /// No description available
3459        index: String,
3460        /// No description available
3461        local: Option<bool>,
3462        /// No description available
3463        preference: Option<String>,
3464        /// No description available
3465        pretty: Option<bool>,
3466        /// No description available
3467        routing: Option<common::Routing>,
3468        /// No description available
3469        source: Option<String>,
3470        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
3471        expand_wildcards: Option<common::ExpandWildcards>,
3472    ) -> Result<crate::common::SearchShardsWithIndexResponse, Error> {
3473        let local_var_configuration = &self.configuration;
3474
3475        let local_var_client = &local_var_configuration.client;
3476
3477        let local_var_uri_str = format!(
3478            "{}{index}/_search_shards",
3479            local_var_configuration.base_path,
3480            index = index
3481        );
3482        let mut local_var_req_builder =
3483            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
3484
3485        if let Some(ref local_var_str) = local {
3486            local_var_req_builder =
3487                local_var_req_builder.query(&[("local", &local_var_str.to_string())]);
3488        }
3489        if let Some(ref local_var_str) = source {
3490            local_var_req_builder =
3491                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
3492        }
3493        if let Some(ref local_var_str) = pretty {
3494            local_var_req_builder =
3495                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
3496        }
3497        if let Some(ref local_var_str) = routing {
3498            local_var_req_builder =
3499                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
3500        }
3501        if let Some(ref local_var_str) = expand_wildcards {
3502            local_var_req_builder =
3503                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
3504        }
3505        if let Some(ref local_var_str) = ignore_unavailable {
3506            local_var_req_builder =
3507                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
3508        }
3509        if let Some(ref local_var_str) = allow_no_indices {
3510            local_var_req_builder =
3511                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
3512        }
3513        if let Some(ref local_var_str) = human {
3514            local_var_req_builder =
3515                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
3516        }
3517        if let Some(ref local_var_str) = filter_path {
3518            local_var_req_builder =
3519                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
3520        }
3521        if let Some(ref local_var_str) = preference {
3522            local_var_req_builder =
3523                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
3524        }
3525        if let Some(ref local_var_str) = error_trace {
3526            local_var_req_builder =
3527                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
3528        }
3529
3530        let local_var_req = local_var_req_builder.build()?;
3531        let local_var_resp = local_var_client.execute(local_var_req).await?;
3532
3533        let local_var_status = local_var_resp.status();
3534        let local_var_content = local_var_resp.text().await?;
3535
3536        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3537            serde_json::from_str(&local_var_content).map_err(Error::from)
3538        } else {
3539            let local_var_error = ResponseContent {
3540                status: local_var_status,
3541                content: local_var_content,
3542            };
3543            Err(Error::ApiError(local_var_error))
3544        }
3545    }
3546    ///
3547    /// Changes the number of requests per second for a particular reindex operation.
3548    #[builder(on(String, into))]
3549    pub async fn reindex_rethrottle(
3550        &self,
3551        /// No description available
3552        error_trace: Option<bool>,
3553        /// No description available
3554        filter_path: Option<common::FilterPath>,
3555        /// No description available
3556        human: Option<bool>,
3557        /// No description available
3558        pretty: Option<bool>,
3559        /// No description available
3560        requests_per_second: Option<f64>,
3561        /// No description available
3562        source: Option<String>,
3563        /// No description available
3564        task_id: String,
3565    ) -> Result<crate::common::ReindexRethrottleResponse, Error> {
3566        let local_var_configuration = &self.configuration;
3567
3568        let local_var_client = &local_var_configuration.client;
3569
3570        let local_var_uri_str = format!(
3571            "{}_reindex/{task_id}/_rethrottle",
3572            local_var_configuration.base_path,
3573            task_id = task_id
3574        );
3575        let mut local_var_req_builder =
3576            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
3577
3578        if let Some(ref local_var_str) = filter_path {
3579            local_var_req_builder =
3580                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
3581        }
3582        if let Some(ref local_var_str) = pretty {
3583            local_var_req_builder =
3584                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
3585        }
3586        if let Some(ref local_var_str) = requests_per_second {
3587            local_var_req_builder =
3588                local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
3589        }
3590        if let Some(ref local_var_str) = error_trace {
3591            local_var_req_builder =
3592                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
3593        }
3594        if let Some(ref local_var_str) = source {
3595            local_var_req_builder =
3596                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
3597        }
3598        if let Some(ref local_var_str) = human {
3599            local_var_req_builder =
3600                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
3601        }
3602
3603        let local_var_req = local_var_req_builder.build()?;
3604        let local_var_resp = local_var_client.execute(local_var_req).await?;
3605
3606        let local_var_status = local_var_resp.status();
3607        let local_var_content = local_var_resp.text().await?;
3608
3609        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3610            serde_json::from_str(&local_var_content).map_err(Error::from)
3611        } else {
3612            let local_var_error = ResponseContent {
3613                status: local_var_status,
3614                content: local_var_content,
3615            };
3616            Err(Error::ApiError(local_var_error))
3617        }
3618    }
3619    ///
3620    /// Creates a new document in the index.
3621    ///
3622    /// Returns a 409 response when a document with a same ID already exists in the index.
3623    #[builder(on(String, into))]
3624    pub async fn create(
3625        &self,
3626        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
3627        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
3628        timeout: Option<String>,
3629        /// No description available
3630        error_trace: Option<bool>,
3631        /// No description available
3632        filter_path: Option<common::FilterPath>,
3633        /// No description available
3634        human: Option<bool>,
3635        /// No description available
3636        id: String,
3637        /// No description available
3638        index: String,
3639        /// No description available
3640        pipeline: Option<String>,
3641        /// No description available
3642        pretty: Option<bool>,
3643        /// No description available
3644        refresh: Option<common::Refresh>,
3645        /// No description available
3646        routing: Option<common::Routing>,
3647        /// No description available
3648        source: Option<String>,
3649        /// No description available
3650        version: Option<i32>,
3651        /// No description available
3652        version_type: Option<String>,
3653        /// The document
3654        body: serde_json::Value,
3655        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
3656        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
3657    ) -> Result<crate::bulk::IndexResponse, Error> {
3658        let local_var_configuration = &self.configuration;
3659
3660        let local_var_client = &local_var_configuration.client;
3661
3662        let local_var_uri_str = format!(
3663            "{}{index}/_create/{id}",
3664            local_var_configuration.base_path,
3665            id = id,
3666            index = index
3667        );
3668        let mut local_var_req_builder =
3669            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
3670
3671        if let Some(ref local_var_str) = source {
3672            local_var_req_builder =
3673                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
3674        }
3675        if let Some(ref local_var_str) = pipeline {
3676            local_var_req_builder =
3677                local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
3678        }
3679        if let Some(ref local_var_str) = version {
3680            local_var_req_builder =
3681                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
3682        }
3683        if let Some(ref local_var_str) = pretty {
3684            local_var_req_builder =
3685                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
3686        }
3687        if let Some(ref local_var_str) = refresh {
3688            local_var_req_builder =
3689                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
3690        }
3691        if let Some(ref local_var_str) = wait_for_active_shards {
3692            local_var_req_builder = local_var_req_builder
3693                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
3694        }
3695        if let Some(ref local_var_str) = version_type {
3696            local_var_req_builder =
3697                local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
3698        }
3699        if let Some(ref local_var_str) = timeout {
3700            local_var_req_builder =
3701                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
3702        }
3703        if let Some(ref local_var_str) = error_trace {
3704            local_var_req_builder =
3705                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
3706        }
3707        if let Some(ref local_var_str) = filter_path {
3708            local_var_req_builder =
3709                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
3710        }
3711        if let Some(ref local_var_str) = routing {
3712            local_var_req_builder =
3713                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
3714        }
3715        if let Some(ref local_var_str) = human {
3716            local_var_req_builder =
3717                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
3718        }
3719
3720        local_var_req_builder = local_var_req_builder.json(&body);
3721
3722        let local_var_req = local_var_req_builder.build()?;
3723        let local_var_resp = local_var_client.execute(local_var_req).await?;
3724
3725        let local_var_status = local_var_resp.status();
3726        let local_var_content = local_var_resp.text().await?;
3727
3728        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
3729            serde_json::from_str(&local_var_content).map_err(Error::from)
3730        } else {
3731            if local_var_status.as_u16() == 409 {
3732                Err(Error::DocumentAlreadyExistsError(
3733                    index.to_string(),
3734                    id.to_string(),
3735                ))
3736            } else {
3737                let local_var_error = ResponseContent {
3738                    status: local_var_status,
3739                    content: local_var_content,
3740                };
3741                Err(Error::ApiError(local_var_error))
3742            }
3743        }
3744    }
3745    ///
3746    /// Returns results matching a query.
3747    #[builder(on(String, into))]
3748    pub async fn search(
3749        &self,
3750        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
3751        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
3752        cancel_after_time_interval: Option<String>,
3753        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
3754        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
3755        scroll: Option<String>,
3756        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
3757        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
3758        timeout: Option<String>,
3759        /// Customizable sequence of processing stages applied to search queries.
3760        search_pipeline: Option<String>,
3761        /// Indicates whether `hit.matched_queries` should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false)
3762        include_named_queries_score: Option<bool>,
3763        /// No description available
3764        source_excludes: Option<common::SourceExcludes>,
3765        /// No description available
3766        source_includes: Option<common::SourceIncludes>,
3767        /// No description available
3768        allow_no_indices: Option<bool>,
3769        /// No description available
3770        allow_partial_search_results: Option<bool>,
3771        /// No description available
3772        analyze_wildcard: Option<bool>,
3773        /// No description available
3774        analyzer: Option<String>,
3775        /// No description available
3776        batched_reduce_size: Option<i32>,
3777        /// No description available
3778        ccs_minimize_roundtrips: Option<bool>,
3779        /// No description available
3780        default_operator: Option<String>,
3781        /// No description available
3782        df: Option<String>,
3783        /// No description available
3784        docvalue_fields: Option<common::DocvalueFields>,
3785        /// No description available
3786        error_trace: Option<bool>,
3787        /// No description available
3788        explain: Option<bool>,
3789        /// No description available
3790        filter_path: Option<common::FilterPath>,
3791        /// No description available
3792        from: Option<i32>,
3793        /// No description available
3794        human: Option<bool>,
3795        /// No description available
3796        ignore_throttled: Option<bool>,
3797        /// No description available
3798        ignore_unavailable: Option<bool>,
3799        /// No description available
3800        lenient: Option<bool>,
3801        /// No description available
3802        max_concurrent_shard_requests: Option<i32>,
3803        /// No description available
3804        phase_took: Option<bool>,
3805        /// No description available
3806        pre_filter_shard_size: Option<i32>,
3807        /// No description available
3808        preference: Option<String>,
3809        /// No description available
3810        pretty: Option<bool>,
3811        /// No description available
3812        q: Option<String>,
3813        /// No description available
3814        request_cache: Option<bool>,
3815        /// No description available
3816        rest_total_hits_as_int: Option<bool>,
3817        /// No description available
3818        routing: Option<common::Routing>,
3819        /// No description available
3820        search_type: Option<common::SearchType>,
3821        /// No description available
3822        seq_no_primary_term: Option<bool>,
3823        /// No description available
3824        size: Option<i32>,
3825        /// No description available
3826        sort: Option<common::Sort>,
3827        /// No description available
3828        source: Option<String>,
3829        /// No description available
3830        stats: Option<Vec<String>>,
3831        /// No description available
3832        stored_fields: Option<common::StoredFields>,
3833        /// No description available
3834        suggest_mode: Option<String>,
3835        /// No description available
3836        suggest_size: Option<i32>,
3837        /// No description available
3838        suggest_text: Option<String>,
3839        /// No description available
3840        terminate_after: Option<i32>,
3841        /// No description available
3842        track_scores: Option<bool>,
3843        /// No description available
3844        typed_keys: Option<bool>,
3845        /// No description available
3846        version: Option<bool>,
3847        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
3848        expand_wildcards: Option<common::ExpandWildcards>,
3849        /// The number of hits matching the query. When `true`, the exact
3850        /// number of hits is returned at the cost of some performance. When `false`, the
3851        /// response does not include the total number of hits matching the query.
3852        /// Default is `10,000` hits.
3853        track_total_hits: Option<common::TrackTotalHits>,
3854        /// The path to a field or an array of paths. Some APIs support wildcards in the path, which allows you to select multiple fields.
3855        suggest_field: Option<String>,
3856        index: Option<String>,
3857        /// The search definition using the Query DSL
3858        search: Option<common::Search>,
3859    ) -> Result<SearchSuccess, Error> {
3860        let local_var_configuration = &self.configuration;
3861
3862        let local_var_client = &local_var_configuration.client;
3863
3864        let local_var_uri_str = if let Some(index) = &index {
3865            format!("{}{}/_search", local_var_configuration.base_path, index)
3866        } else {
3867            format!("{}_search", local_var_configuration.base_path)
3868        };
3869        let mut local_var_req_builder =
3870            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
3871
3872        if let Some(ref local_var_str) = analyzer {
3873            local_var_req_builder =
3874                local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
3875        }
3876        if let Some(ref local_var_str) = ignore_unavailable {
3877            local_var_req_builder =
3878                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
3879        }
3880        if let Some(ref local_var_str) = include_named_queries_score {
3881            local_var_req_builder = local_var_req_builder
3882                .query(&[("include_named_queries_score", &local_var_str.to_string())]);
3883        }
3884        if let Some(ref local_var_str) = batched_reduce_size {
3885            local_var_req_builder =
3886                local_var_req_builder.query(&[("batched_reduce_size", &local_var_str.to_string())]);
3887        }
3888        if let Some(ref local_var_str) = source_includes {
3889            local_var_req_builder =
3890                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
3891        }
3892        if let Some(ref local_var_str) = ccs_minimize_roundtrips {
3893            local_var_req_builder = local_var_req_builder
3894                .query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
3895        }
3896        if let Some(ref local_var_str) = analyze_wildcard {
3897            local_var_req_builder =
3898                local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
3899        }
3900        if let Some(ref local_var_str) = phase_took {
3901            local_var_req_builder =
3902                local_var_req_builder.query(&[("phase_took", &local_var_str.to_string())]);
3903        }
3904        if let Some(ref local_var_str) = rest_total_hits_as_int {
3905            local_var_req_builder = local_var_req_builder
3906                .query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
3907        }
3908        if let Some(ref local_var_str) = routing {
3909            local_var_req_builder =
3910                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
3911        }
3912        if let Some(ref local_var_str) = search_type {
3913            local_var_req_builder =
3914                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
3915        }
3916        if let Some(ref local_var_str) = seq_no_primary_term {
3917            local_var_req_builder =
3918                local_var_req_builder.query(&[("seq_no_primary_term", &local_var_str.to_string())]);
3919        }
3920        if let Some(ref local_var_str) = suggest_text {
3921            local_var_req_builder =
3922                local_var_req_builder.query(&[("suggest_text", &local_var_str.to_string())]);
3923        }
3924        if let Some(ref local_var_str) = track_scores {
3925            local_var_req_builder =
3926                local_var_req_builder.query(&[("track_scores", &local_var_str.to_string())]);
3927        }
3928        if let Some(ref local_var_str) = track_total_hits {
3929            local_var_req_builder =
3930                local_var_req_builder.query(&[("track_total_hits", &local_var_str.to_string())]);
3931        }
3932        if let Some(ref local_var_str) = max_concurrent_shard_requests {
3933            local_var_req_builder = local_var_req_builder
3934                .query(&[("max_concurrent_shard_requests", &local_var_str.to_string())]);
3935        }
3936        if let Some(ref local_var_str) = typed_keys {
3937            local_var_req_builder =
3938                local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
3939        }
3940        if let Some(ref local_var_str) = docvalue_fields {
3941            local_var_req_builder =
3942                local_var_req_builder.query(&[("docvalue_fields", &local_var_str.to_string())]);
3943        }
3944        if let Some(ref local_var_str) = df {
3945            local_var_req_builder =
3946                local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
3947        }
3948        if let Some(ref local_var_str) = q {
3949            local_var_req_builder =
3950                local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
3951        }
3952        if let Some(ref local_var_str) = allow_partial_search_results {
3953            local_var_req_builder = local_var_req_builder
3954                .query(&[("allow_partial_search_results", &local_var_str.to_string())]);
3955        }
3956        if let Some(ref local_var_str) = sort {
3957            local_var_req_builder =
3958                local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
3959        }
3960        if let Some(ref local_var_str) = source_excludes {
3961            local_var_req_builder =
3962                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
3963        }
3964        if let Some(ref local_var_str) = suggest_mode {
3965            local_var_req_builder =
3966                local_var_req_builder.query(&[("suggest_mode", &local_var_str.to_string())]);
3967        }
3968        if let Some(ref local_var_str) = suggest_size {
3969            local_var_req_builder =
3970                local_var_req_builder.query(&[("suggest_size", &local_var_str.to_string())]);
3971        }
3972        if let Some(ref local_var_str) = default_operator {
3973            local_var_req_builder =
3974                local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
3975        }
3976        if let Some(ref local_var_str) = from {
3977            local_var_req_builder =
3978                local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
3979        }
3980        if let Some(ref local_var_str) = human {
3981            local_var_req_builder =
3982                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
3983        }
3984        if let Some(ref local_var_str) = pre_filter_shard_size {
3985            local_var_req_builder = local_var_req_builder
3986                .query(&[("pre_filter_shard_size", &local_var_str.to_string())]);
3987        }
3988        if let Some(ref local_var_str) = error_trace {
3989            local_var_req_builder =
3990                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
3991        }
3992        if let Some(ref local_var_str) = source {
3993            local_var_req_builder =
3994                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
3995        }
3996        if let Some(ref local_var_str) = stats {
3997            local_var_req_builder = match "multi" {
3998                "multi" => local_var_req_builder.query(
3999                    &local_var_str
4000                        .into_iter()
4001                        .map(|p| ("stats".to_owned(), p.to_string()))
4002                        .collect::<Vec<(std::string::String, std::string::String)>>(),
4003                ),
4004                _ => local_var_req_builder.query(&[(
4005                    "stats",
4006                    &local_var_str
4007                        .into_iter()
4008                        .map(|p| p.to_string())
4009                        .collect::<Vec<String>>()
4010                        .join(",")
4011                        .to_string(),
4012                )]),
4013            };
4014        }
4015        if let Some(ref local_var_str) = terminate_after {
4016            local_var_req_builder =
4017                local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
4018        }
4019        if let Some(ref local_var_str) = cancel_after_time_interval {
4020            local_var_req_builder = local_var_req_builder
4021                .query(&[("cancel_after_time_interval", &local_var_str.to_string())]);
4022        }
4023        if let Some(ref local_var_str) = filter_path {
4024            local_var_req_builder =
4025                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
4026        }
4027        if let Some(ref local_var_str) = lenient {
4028            local_var_req_builder =
4029                local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
4030        }
4031        if let Some(ref local_var_str) = explain {
4032            local_var_req_builder =
4033                local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
4034        }
4035        if let Some(ref local_var_str) = search_pipeline {
4036            local_var_req_builder =
4037                local_var_req_builder.query(&[("search_pipeline", &local_var_str.to_string())]);
4038        }
4039        if let Some(ref local_var_str) = size {
4040            local_var_req_builder =
4041                local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
4042        }
4043        if let Some(ref local_var_str) = timeout {
4044            local_var_req_builder =
4045                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
4046        }
4047        if let Some(ref local_var_str) = version {
4048            local_var_req_builder =
4049                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
4050        }
4051        if let Some(ref local_var_str) = pretty {
4052            local_var_req_builder =
4053                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
4054        }
4055        if let Some(ref local_var_str) = stored_fields {
4056            local_var_req_builder =
4057                local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
4058        }
4059        if let Some(ref local_var_str) = expand_wildcards {
4060            local_var_req_builder =
4061                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
4062        }
4063        if let Some(ref local_var_str) = ignore_throttled {
4064            local_var_req_builder =
4065                local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
4066        }
4067        if let Some(ref local_var_str) = suggest_field {
4068            local_var_req_builder =
4069                local_var_req_builder.query(&[("suggest_field", &local_var_str.to_string())]);
4070        }
4071        if let Some(ref local_var_str) = scroll {
4072            local_var_req_builder =
4073                local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
4074        }
4075        if let Some(ref local_var_str) = preference {
4076            local_var_req_builder =
4077                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
4078        }
4079        if let Some(ref local_var_str) = request_cache {
4080            local_var_req_builder =
4081                local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
4082        }
4083        if let Some(ref local_var_str) = allow_no_indices {
4084            local_var_req_builder =
4085                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
4086        }
4087
4088        if let Some(ref body) = search {
4089            local_var_req_builder = local_var_req_builder.json(&body);
4090        }
4091        tracing::debug!(
4092            "Request: \npath:{}\n {}\n",
4093            local_var_uri_str,
4094            serde_json::to_string(&search).unwrap_or_default()
4095        );
4096
4097        let local_var_req = local_var_req_builder.build()?;
4098        let local_var_resp = local_var_client.execute(local_var_req).await?;
4099
4100        let local_var_status = local_var_resp.status();
4101        let local_var_content = local_var_resp.text().await?;
4102
4103        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4104            serde_json::from_str(&local_var_content).map_err(Error::from)
4105        } else {
4106            let local_var_error = ResponseContent {
4107                status: local_var_status,
4108                content: local_var_content,
4109            };
4110            Err(Error::ApiError(local_var_error))
4111        }
4112    }
4113    ///
4114    /// Returns the source of a document.
4115    #[builder(on(String, into))]
4116    pub async fn get_source(
4117        &self,
4118        /// No description available
4119        index: String,
4120        /// No description available
4121        id: String,
4122        /// No description available
4123        source_excludes: Option<common::SourceExcludes>,
4124        /// No description available
4125        source_includes: Option<common::SourceIncludes>,
4126        /// No description available
4127        error_trace: Option<bool>,
4128        /// No description available
4129        filter_path: Option<common::FilterPath>,
4130        /// No description available
4131        human: Option<bool>,
4132        /// No description available
4133        preference: Option<String>,
4134        /// No description available
4135        pretty: Option<bool>,
4136        /// No description available
4137        realtime: Option<bool>,
4138        /// No description available
4139        refresh: Option<common::Refresh>,
4140        /// No description available
4141        routing: Option<common::Routing>,
4142        /// No description available
4143        source: Option<String>,
4144        /// No description available
4145        version: Option<i32>,
4146        /// No description available
4147        version_type: Option<String>,
4148    ) -> Result<GetSourceSuccess, Error> {
4149        let local_var_configuration = &self.configuration;
4150
4151        let local_var_client = &local_var_configuration.client;
4152
4153        let local_var_uri_str = format!(
4154            "{}{index}/_source/{id}",
4155            local_var_configuration.base_path,
4156            index = index,
4157            id = id
4158        );
4159        let mut local_var_req_builder =
4160            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
4161
4162        if let Some(ref local_var_str) = pretty {
4163            local_var_req_builder =
4164                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
4165        }
4166        if let Some(ref local_var_str) = version_type {
4167            local_var_req_builder =
4168                local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
4169        }
4170        if let Some(ref local_var_str) = source {
4171            local_var_req_builder =
4172                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
4173        }
4174        if let Some(ref local_var_str) = source_excludes {
4175            local_var_req_builder =
4176                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
4177        }
4178        if let Some(ref local_var_str) = source_includes {
4179            local_var_req_builder =
4180                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
4181        }
4182        if let Some(ref local_var_str) = filter_path {
4183            local_var_req_builder =
4184                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
4185        }
4186        if let Some(ref local_var_str) = routing {
4187            local_var_req_builder =
4188                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
4189        }
4190        if let Some(ref local_var_str) = refresh {
4191            local_var_req_builder =
4192                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
4193        }
4194        if let Some(ref local_var_str) = human {
4195            local_var_req_builder =
4196                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
4197        }
4198        if let Some(ref local_var_str) = realtime {
4199            local_var_req_builder =
4200                local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
4201        }
4202        if let Some(ref local_var_str) = error_trace {
4203            local_var_req_builder =
4204                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
4205        }
4206        if let Some(ref local_var_str) = preference {
4207            local_var_req_builder =
4208                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
4209        }
4210        if let Some(ref local_var_str) = version {
4211            local_var_req_builder =
4212                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
4213        }
4214
4215        let local_var_req = local_var_req_builder.build()?;
4216        let local_var_resp = local_var_client.execute(local_var_req).await?;
4217
4218        let local_var_status = local_var_resp.status();
4219        let local_var_content = local_var_resp.text().await?;
4220
4221        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4222            serde_json::from_str(&local_var_content).map_err(Error::from)
4223        } else {
4224            let local_var_error = ResponseContent {
4225                status: local_var_status,
4226                content: local_var_content,
4227            };
4228            Err(Error::ApiError(local_var_error))
4229        }
4230    }
4231    ///
4232    /// Allows to perform multiple index/update/delete operations in a single request.
4233    #[builder(on(String, into))]
4234    pub async fn bulk(
4235        &self,
4236        /// The operation definition and data (action-data pairs), separated by newlines
4237        body: String,
4238        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
4239        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
4240        timeout: Option<String>,
4241        /// Default document type for items which don't provide one.
4242        r#type: Option<String>,
4243        /// No description available
4244        source_excludes: Option<common::SourceExcludes>,
4245        /// No description available
4246        source_includes: Option<common::SourceIncludes>,
4247        /// No description available
4248        error_trace: Option<bool>,
4249        /// No description available
4250        filter_path: Option<common::FilterPath>,
4251        /// No description available
4252        human: Option<bool>,
4253        /// No description available
4254        pipeline: Option<String>,
4255        /// No description available
4256        pretty: Option<bool>,
4257        /// No description available
4258        refresh: Option<common::Refresh>,
4259        /// No description available
4260        require_alias: Option<bool>,
4261        /// No description available
4262        routing: Option<common::Routing>,
4263        /// No description available
4264        source: Option<String>,
4265        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
4266        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
4267    ) -> Result<crate::bulk::BulkResponse, Error> {
4268        let local_var_configuration = &self.configuration;
4269
4270        let local_var_client = &local_var_configuration.client;
4271
4272        let local_var_uri_str = format!("{}_bulk", local_var_configuration.base_path);
4273        let mut local_var_req_builder =
4274            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
4275
4276        if let Some(ref local_var_str) = human {
4277            local_var_req_builder =
4278                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
4279        }
4280        if let Some(ref local_var_str) = refresh {
4281            local_var_req_builder =
4282                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
4283        }
4284        if let Some(ref local_var_str) = source_excludes {
4285            local_var_req_builder =
4286                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
4287        }
4288        if let Some(ref local_var_str) = routing {
4289            local_var_req_builder =
4290                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
4291        }
4292        if let Some(ref local_var_str) = wait_for_active_shards {
4293            local_var_req_builder = local_var_req_builder
4294                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
4295        }
4296        if let Some(ref local_var_str) = require_alias {
4297            local_var_req_builder =
4298                local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
4299        }
4300        if let Some(ref local_var_str) = filter_path {
4301            local_var_req_builder =
4302                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
4303        }
4304        if let Some(ref local_var_str) = source_includes {
4305            local_var_req_builder =
4306                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
4307        }
4308        if let Some(ref local_var_str) = pretty {
4309            local_var_req_builder =
4310                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
4311        }
4312        if let Some(ref local_var_str) = error_trace {
4313            local_var_req_builder =
4314                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
4315        }
4316        if let Some(ref local_var_str) = source {
4317            local_var_req_builder =
4318                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
4319        }
4320        if let Some(ref local_var_str) = pipeline {
4321            local_var_req_builder =
4322                local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
4323        }
4324        if let Some(ref local_var_str) = timeout {
4325            local_var_req_builder =
4326                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
4327        }
4328        if let Some(ref local_var_str) = r#type {
4329            local_var_req_builder =
4330                local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
4331        }
4332
4333        local_var_req_builder = local_var_req_builder
4334            .body(reqwest::Body::from(body))
4335            .header("Content-Type", "application/x-ndjson");
4336
4337        let local_var_req = local_var_req_builder.build()?;
4338        let local_var_resp = local_var_client.execute(local_var_req).await?;
4339
4340        let local_var_status = local_var_resp.status();
4341        let local_var_content = local_var_resp.text().await?;
4342
4343        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4344            serde_json::from_str(&local_var_content).map_err(Error::from)
4345        } else {
4346            let local_var_error = ResponseContent {
4347                status: local_var_status,
4348                content: local_var_content,
4349            };
4350            Err(Error::ApiError(local_var_error))
4351        }
4352    }
4353    ///
4354    /// Allows to retrieve a large numbers of results from a single search request.
4355    #[builder(on(String, into))]
4356    pub async fn scroll(
4357        &self,
4358        scroll: common::Scroll,
4359        /// No description available
4360        error_trace: Option<bool>,
4361        /// No description available
4362        filter_path: Option<common::FilterPath>,
4363        /// No description available
4364        human: Option<bool>,
4365        /// No description available
4366        pretty: Option<bool>,
4367        /// No description available
4368        rest_total_hits_as_int: Option<bool>,
4369        /// No description available
4370        scroll_id: Option<String>,
4371        /// No description available
4372        source: Option<String>,
4373    ) -> Result<crate::core::search::ResponseBody, Error> {
4374        let local_var_configuration = &self.configuration;
4375
4376        let local_var_client = &local_var_configuration.client;
4377
4378        let local_var_uri_str = format!(
4379            "{}_search/scroll/{scroll_id}",
4380            local_var_configuration.base_path,
4381            scroll_id = scroll_id.clone().unwrap_or_default()
4382        );
4383        let mut local_var_req_builder =
4384            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
4385
4386        if let Some(ref local_var_str) = filter_path {
4387            local_var_req_builder =
4388                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
4389        }
4390        if let Some(ref local_var_str) = source {
4391            local_var_req_builder =
4392                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
4393        }
4394        if let Some(ref local_var_str) = human {
4395            local_var_req_builder =
4396                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
4397        }
4398        if let Some(ref local_var_str) = scroll_id {
4399            local_var_req_builder =
4400                local_var_req_builder.query(&[("scroll_id", &local_var_str.to_string())]);
4401        }
4402        local_var_req_builder = local_var_req_builder.query(&[("scroll", &scroll.to_string())]);
4403        if let Some(ref local_var_str) = pretty {
4404            local_var_req_builder =
4405                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
4406        }
4407        if let Some(ref local_var_str) = error_trace {
4408            local_var_req_builder =
4409                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
4410        }
4411        if let Some(ref local_var_str) = rest_total_hits_as_int {
4412            local_var_req_builder = local_var_req_builder
4413                .query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
4414        }
4415
4416        local_var_req_builder = local_var_req_builder.json(&scroll);
4417
4418        let local_var_req = local_var_req_builder.build()?;
4419        let local_var_resp = local_var_client.execute(local_var_req).await?;
4420
4421        let local_var_status = local_var_resp.status();
4422        let local_var_content = local_var_resp.text().await?;
4423
4424        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4425            serde_json::from_str(&local_var_content).map_err(Error::from)
4426        } else {
4427            let local_var_error = ResponseContent {
4428                status: local_var_status,
4429                content: local_var_content,
4430            };
4431            Err(Error::ApiError(local_var_error))
4432        }
4433    }
4434    ///
4435    /// Allows to execute several search operations in one request.
4436    #[builder(on(String, into))]
4437    pub async fn msearch(
4438        &self,
4439        /// No description available
4440        ccs_minimize_roundtrips: Option<bool>,
4441        /// No description available
4442        error_trace: Option<bool>,
4443        /// No description available
4444        filter_path: Option<common::FilterPath>,
4445        /// No description available
4446        human: Option<bool>,
4447        /// No description available
4448        index: String,
4449        /// No description available
4450        max_concurrent_searches: Option<i32>,
4451        /// No description available
4452        max_concurrent_shard_requests: Option<i32>,
4453        /// No description available
4454        pre_filter_shard_size: Option<i32>,
4455        /// No description available
4456        pretty: Option<bool>,
4457        /// No description available
4458        rest_total_hits_as_int: Option<bool>,
4459        /// No description available
4460        search_type: Option<common::SearchType>,
4461        /// No description available
4462        source: Option<String>,
4463        /// No description available
4464        typed_keys: Option<bool>,
4465    ) -> Result<crate::core::msearch::MultiSearchResult, Error> {
4466        let local_var_configuration = &self.configuration;
4467
4468        let local_var_client = &local_var_configuration.client;
4469
4470        let local_var_uri_str = format!(
4471            "{}{index}/_msearch",
4472            local_var_configuration.base_path,
4473            index = index
4474        );
4475        let mut local_var_req_builder =
4476            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
4477
4478        if let Some(ref local_var_str) = search_type {
4479            local_var_req_builder =
4480                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
4481        }
4482        if let Some(ref local_var_str) = source {
4483            local_var_req_builder =
4484                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
4485        }
4486        if let Some(ref local_var_str) = max_concurrent_searches {
4487            local_var_req_builder = local_var_req_builder
4488                .query(&[("max_concurrent_searches", &local_var_str.to_string())]);
4489        }
4490        if let Some(ref local_var_str) = error_trace {
4491            local_var_req_builder =
4492                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
4493        }
4494        if let Some(ref local_var_str) = filter_path {
4495            local_var_req_builder =
4496                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
4497        }
4498        if let Some(ref local_var_str) = rest_total_hits_as_int {
4499            local_var_req_builder = local_var_req_builder
4500                .query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
4501        }
4502        if let Some(ref local_var_str) = max_concurrent_shard_requests {
4503            local_var_req_builder = local_var_req_builder
4504                .query(&[("max_concurrent_shard_requests", &local_var_str.to_string())]);
4505        }
4506        if let Some(ref local_var_str) = ccs_minimize_roundtrips {
4507            local_var_req_builder = local_var_req_builder
4508                .query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
4509        }
4510        if let Some(ref local_var_str) = pretty {
4511            local_var_req_builder =
4512                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
4513        }
4514        if let Some(ref local_var_str) = pre_filter_shard_size {
4515            local_var_req_builder = local_var_req_builder
4516                .query(&[("pre_filter_shard_size", &local_var_str.to_string())]);
4517        }
4518        if let Some(ref local_var_str) = typed_keys {
4519            local_var_req_builder =
4520                local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
4521        }
4522        if let Some(ref local_var_str) = human {
4523            local_var_req_builder =
4524                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
4525        }
4526
4527        let local_var_req = local_var_req_builder.build()?;
4528        let local_var_resp = local_var_client.execute(local_var_req).await?;
4529
4530        let local_var_status = local_var_resp.status();
4531        let local_var_content = local_var_resp.text().await?;
4532
4533        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4534            serde_json::from_str(&local_var_content).map_err(Error::from)
4535        } else {
4536            let local_var_error = ResponseContent {
4537                status: local_var_status,
4538                content: local_var_content,
4539            };
4540            Err(Error::ApiError(local_var_error))
4541        }
4542    }
4543    ///
4544    /// Allows an arbitrary script to be executed and a result to be returned.
4545    #[builder(on(String, into))]
4546    pub async fn scripts_painless_execute(
4547        &self,
4548        /// No description available
4549        error_trace: Option<bool>,
4550        /// No description available
4551        filter_path: Option<common::FilterPath>,
4552        /// No description available
4553        human: Option<bool>,
4554        /// No description available
4555        pretty: Option<bool>,
4556        /// No description available
4557        source: Option<String>,
4558        /// The script to execute
4559        scripts_painless_execute: common::ScriptsPainlessExecute,
4560    ) -> Result<crate::common::ScriptsPainlessExecuteResponse, Error> {
4561        let local_var_configuration = &self.configuration;
4562
4563        let local_var_client = &local_var_configuration.client;
4564
4565        let local_var_uri_str = format!(
4566            "{}_scripts/painless/_execute",
4567            local_var_configuration.base_path
4568        );
4569        let mut local_var_req_builder =
4570            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
4571
4572        if let Some(ref local_var_str) = error_trace {
4573            local_var_req_builder =
4574                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
4575        }
4576        if let Some(ref local_var_str) = pretty {
4577            local_var_req_builder =
4578                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
4579        }
4580        if let Some(ref local_var_str) = human {
4581            local_var_req_builder =
4582                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
4583        }
4584        if let Some(ref local_var_str) = source {
4585            local_var_req_builder =
4586                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
4587        }
4588        if let Some(ref local_var_str) = filter_path {
4589            local_var_req_builder =
4590                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
4591        }
4592
4593        local_var_req_builder = local_var_req_builder.json(&scripts_painless_execute);
4594
4595        let local_var_req = local_var_req_builder.build()?;
4596        let local_var_resp = local_var_client.execute(local_var_req).await?;
4597
4598        let local_var_status = local_var_resp.status();
4599        let local_var_content = local_var_resp.text().await?;
4600
4601        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4602            serde_json::from_str(&local_var_content).map_err(Error::from)
4603        } else {
4604            let local_var_error = ResponseContent {
4605                status: local_var_status,
4606                content: local_var_content,
4607            };
4608            Err(Error::ApiError(local_var_error))
4609        }
4610    }
4611    ///
4612    /// Performs an update on every document in the index without changing the source,
4613    /// for example to pick up a mapping change.
4614    #[builder(on(String, into))]
4615    pub async fn update_by_query(
4616        &self,
4617        index: String,
4618        /// The search definition using the Query DSL
4619        body: common::UpdateByQuery,
4620        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
4621        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
4622        scroll: Option<String>,
4623        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
4624        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
4625        search_timeout: Option<String>,
4626        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
4627        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
4628        timeout: Option<String>,
4629        /// Deprecated, use `max_docs` instead.
4630        size: Option<i32>,
4631        /// No description available
4632        source_excludes: Option<Vec<String>>,
4633        /// No description available
4634        source_includes: Option<Vec<String>>,
4635        /// No description available
4636        allow_no_indices: Option<bool>,
4637        /// No description available
4638        analyze_wildcard: Option<bool>,
4639        /// No description available
4640        analyzer: Option<String>,
4641        /// No description available
4642        conflicts: Option<String>,
4643        /// No description available
4644        default_operator: Option<String>,
4645        /// No description available
4646        df: Option<String>,
4647        /// No description available
4648        error_trace: Option<bool>,
4649        /// No description available
4650        filter_path: Option<common::FilterPath>,
4651        /// No description available
4652        from: Option<i32>,
4653        /// No description available
4654        human: Option<bool>,
4655        /// No description available
4656        ignore_unavailable: Option<bool>,
4657        /// No description available
4658        lenient: Option<bool>,
4659        /// No description available
4660        max_docs: Option<i32>,
4661        /// No description available
4662        pipeline: Option<String>,
4663        /// No description available
4664        preference: Option<String>,
4665        /// No description available
4666        pretty: Option<bool>,
4667        /// No description available
4668        refresh: Option<common::Refresh>,
4669        /// No description available
4670        request_cache: Option<bool>,
4671        /// No description available
4672        requests_per_second: Option<f64>,
4673        /// No description available
4674        routing: Option<common::Routing>,
4675        /// No description available
4676        scroll_size: Option<i32>,
4677        /// No description available
4678        search_type: Option<common::SearchType>,
4679        /// No description available
4680        sort: Option<Vec<String>>,
4681        /// No description available
4682        source: Option<String>,
4683        /// No description available
4684        stats: Option<Vec<String>>,
4685        /// No description available
4686        terminate_after: Option<i32>,
4687        /// No description available
4688        version: Option<bool>,
4689        /// No description available
4690        wait_for_completion: Option<bool>,
4691        /// Query in the Lucene query string syntax.
4692        q: Option<String>,
4693        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
4694        expand_wildcards: Option<common::ExpandWildcards>,
4695        /// The slice configuration used to parallelize a process.
4696        slices: Option<common::Slices>,
4697        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
4698        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
4699    ) -> Result<crate::common::UpdateByQueryOKJson, Error> {
4700        let local_var_configuration = &self.configuration;
4701
4702        let local_var_client = &local_var_configuration.client;
4703
4704        let local_var_uri_str = format!(
4705            "{}{index}/_update_by_query",
4706            local_var_configuration.base_path,
4707            index = index
4708        );
4709        let mut local_var_req_builder =
4710            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
4711
4712        if let Some(ref local_var_str) = conflicts {
4713            local_var_req_builder =
4714                local_var_req_builder.query(&[("conflicts", &local_var_str.to_string())]);
4715        }
4716        if let Some(ref local_var_str) = source_includes {
4717            local_var_req_builder = match "multi" {
4718                "multi" => local_var_req_builder.query(
4719                    &local_var_str
4720                        .into_iter()
4721                        .map(|p| ("source_includes".to_owned(), p.to_string()))
4722                        .collect::<Vec<(std::string::String, std::string::String)>>(),
4723                ),
4724                _ => local_var_req_builder.query(&[(
4725                    "source_includes",
4726                    &local_var_str
4727                        .into_iter()
4728                        .map(|p| p.to_string())
4729                        .collect::<Vec<String>>()
4730                        .join(",")
4731                        .to_string(),
4732                )]),
4733            };
4734        }
4735        if let Some(ref local_var_str) = scroll {
4736            local_var_req_builder =
4737                local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
4738        }
4739        if let Some(ref local_var_str) = scroll_size {
4740            local_var_req_builder =
4741                local_var_req_builder.query(&[("scroll_size", &local_var_str.to_string())]);
4742        }
4743        if let Some(ref local_var_str) = version {
4744            local_var_req_builder =
4745                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
4746        }
4747        if let Some(ref local_var_str) = analyze_wildcard {
4748            local_var_req_builder =
4749                local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
4750        }
4751        if let Some(ref local_var_str) = preference {
4752            local_var_req_builder =
4753                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
4754        }
4755        if let Some(ref local_var_str) = requests_per_second {
4756            local_var_req_builder =
4757                local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
4758        }
4759        if let Some(ref local_var_str) = error_trace {
4760            local_var_req_builder =
4761                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
4762        }
4763        if let Some(ref local_var_str) = pipeline {
4764            local_var_req_builder =
4765                local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
4766        }
4767        if let Some(ref local_var_str) = stats {
4768            local_var_req_builder = match "multi" {
4769                "multi" => local_var_req_builder.query(
4770                    &local_var_str
4771                        .into_iter()
4772                        .map(|p| ("stats".to_owned(), p.to_string()))
4773                        .collect::<Vec<(std::string::String, std::string::String)>>(),
4774                ),
4775                _ => local_var_req_builder.query(&[(
4776                    "stats",
4777                    &local_var_str
4778                        .into_iter()
4779                        .map(|p| p.to_string())
4780                        .collect::<Vec<String>>()
4781                        .join(",")
4782                        .to_string(),
4783                )]),
4784            };
4785        }
4786        if let Some(ref local_var_str) = q {
4787            local_var_req_builder =
4788                local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
4789        }
4790        if let Some(ref local_var_str) = lenient {
4791            local_var_req_builder =
4792                local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
4793        }
4794        if let Some(ref local_var_str) = pretty {
4795            local_var_req_builder =
4796                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
4797        }
4798        if let Some(ref local_var_str) = analyzer {
4799            local_var_req_builder =
4800                local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
4801        }
4802        if let Some(ref local_var_str) = terminate_after {
4803            local_var_req_builder =
4804                local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
4805        }
4806        if let Some(ref local_var_str) = source_excludes {
4807            local_var_req_builder = match "multi" {
4808                "multi" => local_var_req_builder.query(
4809                    &local_var_str
4810                        .into_iter()
4811                        .map(|p| ("source_excludes".to_owned(), p.to_string()))
4812                        .collect::<Vec<(std::string::String, std::string::String)>>(),
4813                ),
4814                _ => local_var_req_builder.query(&[(
4815                    "source_excludes",
4816                    &local_var_str
4817                        .into_iter()
4818                        .map(|p| p.to_string())
4819                        .collect::<Vec<String>>()
4820                        .join(",")
4821                        .to_string(),
4822                )]),
4823            };
4824        }
4825        if let Some(ref local_var_str) = slices {
4826            local_var_req_builder =
4827                local_var_req_builder.query(&[("slices", &local_var_str.to_string())]);
4828        }
4829        if let Some(ref local_var_str) = routing {
4830            local_var_req_builder =
4831                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
4832        }
4833        if let Some(ref local_var_str) = from {
4834            local_var_req_builder =
4835                local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
4836        }
4837        if let Some(ref local_var_str) = request_cache {
4838            local_var_req_builder =
4839                local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
4840        }
4841        if let Some(ref local_var_str) = human {
4842            local_var_req_builder =
4843                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
4844        }
4845        if let Some(ref local_var_str) = filter_path {
4846            local_var_req_builder =
4847                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
4848        }
4849        if let Some(ref local_var_str) = wait_for_completion {
4850            local_var_req_builder =
4851                local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
4852        }
4853        if let Some(ref local_var_str) = source {
4854            local_var_req_builder =
4855                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
4856        }
4857        if let Some(ref local_var_str) = max_docs {
4858            local_var_req_builder =
4859                local_var_req_builder.query(&[("max_docs", &local_var_str.to_string())]);
4860        }
4861        if let Some(ref local_var_str) = size {
4862            local_var_req_builder =
4863                local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
4864        }
4865        if let Some(ref local_var_str) = timeout {
4866            local_var_req_builder =
4867                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
4868        }
4869        if let Some(ref local_var_str) = refresh {
4870            local_var_req_builder =
4871                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
4872        }
4873        if let Some(ref local_var_str) = sort {
4874            local_var_req_builder = match "multi" {
4875                "multi" => local_var_req_builder.query(
4876                    &local_var_str
4877                        .into_iter()
4878                        .map(|p| ("sort".to_owned(), p.to_string()))
4879                        .collect::<Vec<(std::string::String, std::string::String)>>(),
4880                ),
4881                _ => local_var_req_builder.query(&[(
4882                    "sort",
4883                    &local_var_str
4884                        .into_iter()
4885                        .map(|p| p.to_string())
4886                        .collect::<Vec<String>>()
4887                        .join(",")
4888                        .to_string(),
4889                )]),
4890            };
4891        }
4892        if let Some(ref local_var_str) = expand_wildcards {
4893            local_var_req_builder =
4894                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
4895        }
4896        if let Some(ref local_var_str) = search_type {
4897            local_var_req_builder =
4898                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
4899        }
4900        if let Some(ref local_var_str) = allow_no_indices {
4901            local_var_req_builder =
4902                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
4903        }
4904        if let Some(ref local_var_str) = ignore_unavailable {
4905            local_var_req_builder =
4906                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
4907        }
4908        if let Some(ref local_var_str) = default_operator {
4909            local_var_req_builder =
4910                local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
4911        }
4912        if let Some(ref local_var_str) = wait_for_active_shards {
4913            local_var_req_builder = local_var_req_builder
4914                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
4915        }
4916        if let Some(ref local_var_str) = df {
4917            local_var_req_builder =
4918                local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
4919        }
4920        if let Some(ref local_var_str) = search_timeout {
4921            local_var_req_builder =
4922                local_var_req_builder.query(&[("search_timeout", &local_var_str.to_string())]);
4923        }
4924
4925        local_var_req_builder = local_var_req_builder.json(&body);
4926
4927        let local_var_req = local_var_req_builder.build()?;
4928        let local_var_resp = local_var_client.execute(local_var_req).await?;
4929
4930        let local_var_status = local_var_resp.status();
4931        let local_var_content = local_var_resp.text().await?;
4932
4933        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
4934            serde_json::from_str(&local_var_content).map_err(Error::from)
4935        } else {
4936            let local_var_error = ResponseContent {
4937                status: local_var_status,
4938                content: local_var_content,
4939            };
4940            Err(Error::ApiError(local_var_error))
4941        }
4942    }
4943    ///
4944    /// Performs an update on every document in the index without changing the source,
4945    /// for example to pick up a mapping change.
4946    #[builder(on(String, into))]
4947    pub async fn update_by_query_raw(
4948        &self,
4949        index: String,
4950        /// The search definition using the Query DSL
4951        body: serde_json::Value,
4952        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
4953        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
4954        scroll: Option<String>,
4955        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
4956        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
4957        search_timeout: Option<String>,
4958        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
4959        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
4960        timeout: Option<String>,
4961        /// Deprecated, use `max_docs` instead.
4962        size: Option<i32>,
4963        /// No description available
4964        source_excludes: Option<Vec<String>>,
4965        /// No description available
4966        source_includes: Option<Vec<String>>,
4967        /// No description available
4968        allow_no_indices: Option<bool>,
4969        /// No description available
4970        analyze_wildcard: Option<bool>,
4971        /// No description available
4972        analyzer: Option<String>,
4973        /// No description available
4974        conflicts: Option<String>,
4975        /// No description available
4976        default_operator: Option<String>,
4977        /// No description available
4978        df: Option<String>,
4979        /// No description available
4980        error_trace: Option<bool>,
4981        /// No description available
4982        filter_path: Option<common::FilterPath>,
4983        /// No description available
4984        from: Option<i32>,
4985        /// No description available
4986        human: Option<bool>,
4987        /// No description available
4988        ignore_unavailable: Option<bool>,
4989        /// No description available
4990        lenient: Option<bool>,
4991        /// No description available
4992        max_docs: Option<i32>,
4993        /// No description available
4994        pipeline: Option<String>,
4995        /// No description available
4996        preference: Option<String>,
4997        /// No description available
4998        pretty: Option<bool>,
4999        /// No description available
5000        refresh: Option<common::Refresh>,
5001        /// No description available
5002        request_cache: Option<bool>,
5003        /// No description available
5004        requests_per_second: Option<f64>,
5005        /// No description available
5006        routing: Option<common::Routing>,
5007        /// No description available
5008        scroll_size: Option<i32>,
5009        /// No description available
5010        search_type: Option<common::SearchType>,
5011        /// No description available
5012        sort: Option<Vec<String>>,
5013        /// No description available
5014        source: Option<String>,
5015        /// No description available
5016        stats: Option<Vec<String>>,
5017        /// No description available
5018        terminate_after: Option<i32>,
5019        /// No description available
5020        version: Option<bool>,
5021        /// No description available
5022        wait_for_completion: Option<bool>,
5023        /// Query in the Lucene query string syntax.
5024        q: Option<String>,
5025        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
5026        expand_wildcards: Option<common::ExpandWildcards>,
5027        /// The slice configuration used to parallelize a process.
5028        slices: Option<common::Slices>,
5029        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
5030        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
5031    ) -> Result<crate::common::UpdateByQueryOKJson, Error> {
5032        let local_var_configuration = &self.configuration;
5033
5034        let local_var_client = &local_var_configuration.client;
5035
5036        let local_var_uri_str = format!(
5037            "{}{index}/_update_by_query",
5038            local_var_configuration.base_path,
5039            index = index
5040        );
5041        let mut local_var_req_builder =
5042            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
5043
5044        if let Some(ref local_var_str) = conflicts {
5045            local_var_req_builder =
5046                local_var_req_builder.query(&[("conflicts", &local_var_str.to_string())]);
5047        }
5048        if let Some(ref local_var_str) = source_includes {
5049            local_var_req_builder = match "multi" {
5050                "multi" => local_var_req_builder.query(
5051                    &local_var_str
5052                        .into_iter()
5053                        .map(|p| ("source_includes".to_owned(), p.to_string()))
5054                        .collect::<Vec<(std::string::String, std::string::String)>>(),
5055                ),
5056                _ => local_var_req_builder.query(&[(
5057                    "source_includes",
5058                    &local_var_str
5059                        .into_iter()
5060                        .map(|p| p.to_string())
5061                        .collect::<Vec<String>>()
5062                        .join(",")
5063                        .to_string(),
5064                )]),
5065            };
5066        }
5067        if let Some(ref local_var_str) = scroll {
5068            local_var_req_builder =
5069                local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
5070        }
5071        if let Some(ref local_var_str) = scroll_size {
5072            local_var_req_builder =
5073                local_var_req_builder.query(&[("scroll_size", &local_var_str.to_string())]);
5074        }
5075        if let Some(ref local_var_str) = version {
5076            local_var_req_builder =
5077                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
5078        }
5079        if let Some(ref local_var_str) = analyze_wildcard {
5080            local_var_req_builder =
5081                local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
5082        }
5083        if let Some(ref local_var_str) = preference {
5084            local_var_req_builder =
5085                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
5086        }
5087        if let Some(ref local_var_str) = requests_per_second {
5088            local_var_req_builder =
5089                local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
5090        }
5091        if let Some(ref local_var_str) = error_trace {
5092            local_var_req_builder =
5093                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
5094        }
5095        if let Some(ref local_var_str) = pipeline {
5096            local_var_req_builder =
5097                local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
5098        }
5099        if let Some(ref local_var_str) = stats {
5100            local_var_req_builder = match "multi" {
5101                "multi" => local_var_req_builder.query(
5102                    &local_var_str
5103                        .into_iter()
5104                        .map(|p| ("stats".to_owned(), p.to_string()))
5105                        .collect::<Vec<(std::string::String, std::string::String)>>(),
5106                ),
5107                _ => local_var_req_builder.query(&[(
5108                    "stats",
5109                    &local_var_str
5110                        .into_iter()
5111                        .map(|p| p.to_string())
5112                        .collect::<Vec<String>>()
5113                        .join(",")
5114                        .to_string(),
5115                )]),
5116            };
5117        }
5118        if let Some(ref local_var_str) = q {
5119            local_var_req_builder =
5120                local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
5121        }
5122        if let Some(ref local_var_str) = lenient {
5123            local_var_req_builder =
5124                local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
5125        }
5126        if let Some(ref local_var_str) = pretty {
5127            local_var_req_builder =
5128                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
5129        }
5130        if let Some(ref local_var_str) = analyzer {
5131            local_var_req_builder =
5132                local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
5133        }
5134        if let Some(ref local_var_str) = terminate_after {
5135            local_var_req_builder =
5136                local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
5137        }
5138        if let Some(ref local_var_str) = source_excludes {
5139            local_var_req_builder = match "multi" {
5140                "multi" => local_var_req_builder.query(
5141                    &local_var_str
5142                        .into_iter()
5143                        .map(|p| ("source_excludes".to_owned(), p.to_string()))
5144                        .collect::<Vec<(std::string::String, std::string::String)>>(),
5145                ),
5146                _ => local_var_req_builder.query(&[(
5147                    "source_excludes",
5148                    &local_var_str
5149                        .into_iter()
5150                        .map(|p| p.to_string())
5151                        .collect::<Vec<String>>()
5152                        .join(",")
5153                        .to_string(),
5154                )]),
5155            };
5156        }
5157        if let Some(ref local_var_str) = slices {
5158            local_var_req_builder =
5159                local_var_req_builder.query(&[("slices", &local_var_str.to_string())]);
5160        }
5161        if let Some(ref local_var_str) = routing {
5162            local_var_req_builder =
5163                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
5164        }
5165        if let Some(ref local_var_str) = from {
5166            local_var_req_builder =
5167                local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
5168        }
5169        if let Some(ref local_var_str) = request_cache {
5170            local_var_req_builder =
5171                local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
5172        }
5173        if let Some(ref local_var_str) = human {
5174            local_var_req_builder =
5175                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
5176        }
5177        if let Some(ref local_var_str) = filter_path {
5178            local_var_req_builder =
5179                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
5180        }
5181        if let Some(ref local_var_str) = wait_for_completion {
5182            local_var_req_builder =
5183                local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
5184        }
5185        if let Some(ref local_var_str) = source {
5186            local_var_req_builder =
5187                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
5188        }
5189        if let Some(ref local_var_str) = max_docs {
5190            local_var_req_builder =
5191                local_var_req_builder.query(&[("max_docs", &local_var_str.to_string())]);
5192        }
5193        if let Some(ref local_var_str) = size {
5194            local_var_req_builder =
5195                local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
5196        }
5197        if let Some(ref local_var_str) = timeout {
5198            local_var_req_builder =
5199                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
5200        }
5201        if let Some(ref local_var_str) = refresh {
5202            local_var_req_builder =
5203                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
5204        }
5205        if let Some(ref local_var_str) = sort {
5206            local_var_req_builder = match "multi" {
5207                "multi" => local_var_req_builder.query(
5208                    &local_var_str
5209                        .into_iter()
5210                        .map(|p| ("sort".to_owned(), p.to_string()))
5211                        .collect::<Vec<(std::string::String, std::string::String)>>(),
5212                ),
5213                _ => local_var_req_builder.query(&[(
5214                    "sort",
5215                    &local_var_str
5216                        .into_iter()
5217                        .map(|p| p.to_string())
5218                        .collect::<Vec<String>>()
5219                        .join(",")
5220                        .to_string(),
5221                )]),
5222            };
5223        }
5224        if let Some(ref local_var_str) = expand_wildcards {
5225            local_var_req_builder =
5226                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
5227        }
5228        if let Some(ref local_var_str) = search_type {
5229            local_var_req_builder =
5230                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
5231        }
5232        if let Some(ref local_var_str) = allow_no_indices {
5233            local_var_req_builder =
5234                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
5235        }
5236        if let Some(ref local_var_str) = ignore_unavailable {
5237            local_var_req_builder =
5238                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
5239        }
5240        if let Some(ref local_var_str) = default_operator {
5241            local_var_req_builder =
5242                local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
5243        }
5244        if let Some(ref local_var_str) = wait_for_active_shards {
5245            local_var_req_builder = local_var_req_builder
5246                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
5247        }
5248        if let Some(ref local_var_str) = df {
5249            local_var_req_builder =
5250                local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
5251        }
5252        if let Some(ref local_var_str) = search_timeout {
5253            local_var_req_builder =
5254                local_var_req_builder.query(&[("search_timeout", &local_var_str.to_string())]);
5255        }
5256
5257        local_var_req_builder = local_var_req_builder.json(&body);
5258
5259        let local_var_req = local_var_req_builder.build()?;
5260        let local_var_resp = local_var_client.execute(local_var_req).await?;
5261
5262        let local_var_status = local_var_resp.status();
5263        let local_var_content = local_var_resp.text().await?;
5264
5265        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
5266            serde_json::from_str(&local_var_content).map_err(Error::from)
5267        } else {
5268            let local_var_error = ResponseContent {
5269                status: local_var_status,
5270                content: local_var_content,
5271            };
5272            Err(Error::ApiError(local_var_error))
5273        }
5274    }
5275    ///
5276    /// Changes the number of requests per second for a particular Update By Query operation.
5277    #[builder(on(String, into))]
5278    pub async fn update_by_query_rethrottle(
5279        &self,
5280        /// No description available
5281        error_trace: Option<bool>,
5282        /// No description available
5283        filter_path: Option<common::FilterPath>,
5284        /// No description available
5285        human: Option<bool>,
5286        /// No description available
5287        pretty: Option<bool>,
5288        /// No description available
5289        requests_per_second: Option<f64>,
5290        /// No description available
5291        source: Option<String>,
5292        /// No description available
5293        task_id: String,
5294    ) -> Result<crate::common::UpdateByQueryRethrottleResponse, Error> {
5295        let local_var_configuration = &self.configuration;
5296
5297        let local_var_client = &local_var_configuration.client;
5298
5299        let local_var_uri_str = format!(
5300            "{}_update_by_query/{task_id}/_rethrottle",
5301            local_var_configuration.base_path,
5302            task_id = task_id
5303        );
5304        let mut local_var_req_builder =
5305            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
5306
5307        if let Some(ref local_var_str) = source {
5308            local_var_req_builder =
5309                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
5310        }
5311        if let Some(ref local_var_str) = pretty {
5312            local_var_req_builder =
5313                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
5314        }
5315        if let Some(ref local_var_str) = human {
5316            local_var_req_builder =
5317                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
5318        }
5319        if let Some(ref local_var_str) = requests_per_second {
5320            local_var_req_builder =
5321                local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
5322        }
5323        if let Some(ref local_var_str) = error_trace {
5324            local_var_req_builder =
5325                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
5326        }
5327        if let Some(ref local_var_str) = filter_path {
5328            local_var_req_builder =
5329                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
5330        }
5331
5332        let local_var_req = local_var_req_builder.build()?;
5333        let local_var_resp = local_var_client.execute(local_var_req).await?;
5334
5335        let local_var_status = local_var_resp.status();
5336        let local_var_content = local_var_resp.text().await?;
5337
5338        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
5339            serde_json::from_str(&local_var_content).map_err(Error::from)
5340        } else {
5341            let local_var_error = ResponseContent {
5342                status: local_var_status,
5343                content: local_var_content,
5344            };
5345            Err(Error::ApiError(local_var_error))
5346        }
5347    }
5348    ///
5349    /// Returns all script contexts.
5350    #[builder(on(String, into))]
5351    pub async fn get_script_context(
5352        &self,
5353        /// No description available
5354        error_trace: Option<bool>,
5355        /// No description available
5356        filter_path: Option<common::FilterPath>,
5357        /// No description available
5358        human: Option<bool>,
5359        /// No description available
5360        pretty: Option<bool>,
5361        /// No description available
5362        source: Option<String>,
5363    ) -> Result<crate::common::GetScriptContextResponse, Error> {
5364        let local_var_configuration = &self.configuration;
5365
5366        let local_var_client = &local_var_configuration.client;
5367
5368        let local_var_uri_str = format!("{}_script_context", local_var_configuration.base_path);
5369        let mut local_var_req_builder =
5370            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
5371
5372        if let Some(ref local_var_str) = pretty {
5373            local_var_req_builder =
5374                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
5375        }
5376        if let Some(ref local_var_str) = human {
5377            local_var_req_builder =
5378                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
5379        }
5380        if let Some(ref local_var_str) = source {
5381            local_var_req_builder =
5382                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
5383        }
5384        if let Some(ref local_var_str) = filter_path {
5385            local_var_req_builder =
5386                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
5387        }
5388        if let Some(ref local_var_str) = error_trace {
5389            local_var_req_builder =
5390                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
5391        }
5392
5393        let local_var_req = local_var_req_builder.build()?;
5394        let local_var_resp = local_var_client.execute(local_var_req).await?;
5395
5396        let local_var_status = local_var_resp.status();
5397        let local_var_content = local_var_resp.text().await?;
5398
5399        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
5400            serde_json::from_str(&local_var_content).map_err(Error::from)
5401        } else {
5402            let local_var_error = ResponseContent {
5403                status: local_var_status,
5404                content: local_var_content,
5405            };
5406            Err(Error::ApiError(local_var_error))
5407        }
5408    }
5409    ///
5410    /// Changes the number of requests per second for a particular Delete By Query operation.
5411    #[builder(on(String, into))]
5412    pub async fn delete_by_query_rethrottle(
5413        &self,
5414        /// No description available
5415        error_trace: Option<bool>,
5416        /// No description available
5417        filter_path: Option<common::FilterPath>,
5418        /// No description available
5419        human: Option<bool>,
5420        /// No description available
5421        pretty: Option<bool>,
5422        /// No description available
5423        requests_per_second: Option<f64>,
5424        /// No description available
5425        source: Option<String>,
5426        /// No description available
5427        task_id: String,
5428    ) -> Result<crate::tasks::TaskListResponseBase, Error> {
5429        let local_var_configuration = &self.configuration;
5430
5431        let local_var_client = &local_var_configuration.client;
5432
5433        let local_var_uri_str = format!(
5434            "{}_delete_by_query/{task_id}/_rethrottle",
5435            local_var_configuration.base_path,
5436            task_id = task_id
5437        );
5438        let mut local_var_req_builder =
5439            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
5440
5441        if let Some(ref local_var_str) = source {
5442            local_var_req_builder =
5443                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
5444        }
5445        if let Some(ref local_var_str) = error_trace {
5446            local_var_req_builder =
5447                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
5448        }
5449        if let Some(ref local_var_str) = filter_path {
5450            local_var_req_builder =
5451                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
5452        }
5453        if let Some(ref local_var_str) = requests_per_second {
5454            local_var_req_builder =
5455                local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
5456        }
5457        if let Some(ref local_var_str) = pretty {
5458            local_var_req_builder =
5459                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
5460        }
5461        if let Some(ref local_var_str) = human {
5462            local_var_req_builder =
5463                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
5464        }
5465
5466        let local_var_req = local_var_req_builder.build()?;
5467        let local_var_resp = local_var_client.execute(local_var_req).await?;
5468
5469        let local_var_status = local_var_resp.status();
5470        let local_var_content = local_var_resp.text().await?;
5471
5472        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
5473            serde_json::from_str(&local_var_content).map_err(Error::from)
5474        } else {
5475            let local_var_error = ResponseContent {
5476                status: local_var_status,
5477                content: local_var_content,
5478            };
5479            Err(Error::ApiError(local_var_error))
5480        }
5481    }
5482    ///
5483    /// Allows to use the Mustache language to pre-render a search definition.
5484    #[builder(on(String, into))]
5485    pub async fn search_template_with_index(
5486        &self,
5487        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
5488        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
5489        scroll: Option<String>,
5490        /// No description available
5491        allow_no_indices: Option<bool>,
5492        /// No description available
5493        ccs_minimize_roundtrips: Option<bool>,
5494        /// No description available
5495        error_trace: Option<bool>,
5496        /// No description available
5497        explain: Option<bool>,
5498        /// No description available
5499        filter_path: Option<common::FilterPath>,
5500        /// No description available
5501        human: Option<bool>,
5502        /// No description available
5503        ignore_throttled: Option<bool>,
5504        /// No description available
5505        ignore_unavailable: Option<bool>,
5506        /// No description available
5507        index: String,
5508        /// No description available
5509        preference: Option<String>,
5510        /// No description available
5511        pretty: Option<bool>,
5512        /// No description available
5513        profile: Option<bool>,
5514        /// No description available
5515        rest_total_hits_as_int: Option<bool>,
5516        /// No description available
5517        routing: Option<common::Routing>,
5518        /// No description available
5519        search_type: Option<common::SearchType>,
5520        /// No description available
5521        source: Option<String>,
5522        /// No description available
5523        typed_keys: Option<bool>,
5524        /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
5525        expand_wildcards: Option<common::ExpandWildcards>,
5526        /// The search definition template and its parameters.
5527        search_template_with_index: common::SearchTemplateWithIndex,
5528    ) -> Result<crate::common::SearchTemplateWithIndexResponse, Error> {
5529        let local_var_configuration = &self.configuration;
5530
5531        let local_var_client = &local_var_configuration.client;
5532
5533        let local_var_uri_str = format!(
5534            "{}{index}/_search/template",
5535            local_var_configuration.base_path,
5536            index = index
5537        );
5538        let mut local_var_req_builder =
5539            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
5540
5541        if let Some(ref local_var_str) = ccs_minimize_roundtrips {
5542            local_var_req_builder = local_var_req_builder
5543                .query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
5544        }
5545        if let Some(ref local_var_str) = error_trace {
5546            local_var_req_builder =
5547                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
5548        }
5549        if let Some(ref local_var_str) = ignore_unavailable {
5550            local_var_req_builder =
5551                local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
5552        }
5553        if let Some(ref local_var_str) = profile {
5554            local_var_req_builder =
5555                local_var_req_builder.query(&[("profile", &local_var_str.to_string())]);
5556        }
5557        if let Some(ref local_var_str) = ignore_throttled {
5558            local_var_req_builder =
5559                local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
5560        }
5561        if let Some(ref local_var_str) = typed_keys {
5562            local_var_req_builder =
5563                local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
5564        }
5565        if let Some(ref local_var_str) = rest_total_hits_as_int {
5566            local_var_req_builder = local_var_req_builder
5567                .query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
5568        }
5569        if let Some(ref local_var_str) = expand_wildcards {
5570            local_var_req_builder =
5571                local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
5572        }
5573        if let Some(ref local_var_str) = filter_path {
5574            local_var_req_builder =
5575                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
5576        }
5577        if let Some(ref local_var_str) = preference {
5578            local_var_req_builder =
5579                local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
5580        }
5581        if let Some(ref local_var_str) = scroll {
5582            local_var_req_builder =
5583                local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
5584        }
5585        if let Some(ref local_var_str) = allow_no_indices {
5586            local_var_req_builder =
5587                local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
5588        }
5589        if let Some(ref local_var_str) = search_type {
5590            local_var_req_builder =
5591                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
5592        }
5593        if let Some(ref local_var_str) = explain {
5594            local_var_req_builder =
5595                local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
5596        }
5597        if let Some(ref local_var_str) = source {
5598            local_var_req_builder =
5599                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
5600        }
5601        if let Some(ref local_var_str) = pretty {
5602            local_var_req_builder =
5603                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
5604        }
5605        if let Some(ref local_var_str) = routing {
5606            local_var_req_builder =
5607                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
5608        }
5609        if let Some(ref local_var_str) = human {
5610            local_var_req_builder =
5611                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
5612        }
5613
5614        local_var_req_builder = local_var_req_builder.json(&search_template_with_index);
5615
5616        let local_var_req = local_var_req_builder.build()?;
5617        let local_var_resp = local_var_client.execute(local_var_req).await?;
5618
5619        let local_var_status = local_var_resp.status();
5620        let local_var_content = local_var_resp.text().await?;
5621
5622        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
5623            serde_json::from_str(&local_var_content).map_err(Error::from)
5624        } else {
5625            let local_var_error = ResponseContent {
5626                status: local_var_status,
5627                content: local_var_content,
5628            };
5629            Err(Error::ApiError(local_var_error))
5630        }
5631    }
5632    ///
5633    /// Allows to execute several search template operations in one request.
5634    #[builder(on(String, into))]
5635    pub async fn msearch_template(
5636        &self,
5637        /// No description available
5638        ccs_minimize_roundtrips: Option<bool>,
5639        /// No description available
5640        error_trace: Option<bool>,
5641        /// No description available
5642        filter_path: Option<common::FilterPath>,
5643        /// No description available
5644        human: Option<bool>,
5645        /// No description available
5646        index: String,
5647        /// No description available
5648        max_concurrent_searches: Option<i32>,
5649        /// No description available
5650        pretty: Option<bool>,
5651        /// No description available
5652        rest_total_hits_as_int: Option<bool>,
5653        /// No description available
5654        search_type: Option<common::SearchType>,
5655        /// No description available
5656        source: Option<String>,
5657        /// No description available
5658        typed_keys: Option<bool>,
5659    ) -> Result<crate::core::msearch::MultiSearchResult, Error> {
5660        let local_var_configuration = &self.configuration;
5661
5662        let local_var_client = &local_var_configuration.client;
5663
5664        let local_var_uri_str = format!(
5665            "{}{index}/_msearch/template",
5666            local_var_configuration.base_path,
5667            index = index
5668        );
5669        let mut local_var_req_builder =
5670            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
5671
5672        if let Some(ref local_var_str) = typed_keys {
5673            local_var_req_builder =
5674                local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
5675        }
5676        if let Some(ref local_var_str) = error_trace {
5677            local_var_req_builder =
5678                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
5679        }
5680        if let Some(ref local_var_str) = max_concurrent_searches {
5681            local_var_req_builder = local_var_req_builder
5682                .query(&[("max_concurrent_searches", &local_var_str.to_string())]);
5683        }
5684        if let Some(ref local_var_str) = filter_path {
5685            local_var_req_builder =
5686                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
5687        }
5688        if let Some(ref local_var_str) = rest_total_hits_as_int {
5689            local_var_req_builder = local_var_req_builder
5690                .query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
5691        }
5692        if let Some(ref local_var_str) = source {
5693            local_var_req_builder =
5694                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
5695        }
5696        if let Some(ref local_var_str) = human {
5697            local_var_req_builder =
5698                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
5699        }
5700        if let Some(ref local_var_str) = ccs_minimize_roundtrips {
5701            local_var_req_builder = local_var_req_builder
5702                .query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
5703        }
5704        if let Some(ref local_var_str) = pretty {
5705            local_var_req_builder =
5706                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
5707        }
5708        if let Some(ref local_var_str) = search_type {
5709            local_var_req_builder =
5710                local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
5711        }
5712
5713        let local_var_req = local_var_req_builder.build()?;
5714        let local_var_resp = local_var_client.execute(local_var_req).await?;
5715
5716        let local_var_status = local_var_resp.status();
5717        let local_var_content = local_var_resp.text().await?;
5718
5719        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
5720            serde_json::from_str(&local_var_content).map_err(Error::from)
5721        } else {
5722            let local_var_error = ResponseContent {
5723                status: local_var_status,
5724                content: local_var_content,
5725            };
5726            Err(Error::ApiError(local_var_error))
5727        }
5728    }
5729    ///
5730    /// Returns whether the cluster is running.
5731    #[builder(on(String, into))]
5732    pub async fn ping(
5733        &self,
5734        /// No description available
5735        error_trace: Option<bool>,
5736        /// No description available
5737        filter_path: Option<common::FilterPath>,
5738        /// No description available
5739        human: Option<bool>,
5740        /// No description available
5741        pretty: Option<bool>,
5742        /// No description available
5743        source: Option<String>,
5744    ) -> Result<serde_json::Value, Error> {
5745        let local_var_configuration = &self.configuration;
5746
5747        let local_var_client = &local_var_configuration.client;
5748
5749        let local_var_uri_str = format!("{}", local_var_configuration.base_path);
5750        let mut local_var_req_builder =
5751            local_var_client.request(reqwest::Method::HEAD, local_var_uri_str.as_str());
5752
5753        if let Some(ref local_var_str) = filter_path {
5754            local_var_req_builder =
5755                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
5756        }
5757        if let Some(ref local_var_str) = source {
5758            local_var_req_builder =
5759                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
5760        }
5761        if let Some(ref local_var_str) = error_trace {
5762            local_var_req_builder =
5763                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
5764        }
5765        if let Some(ref local_var_str) = pretty {
5766            local_var_req_builder =
5767                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
5768        }
5769        if let Some(ref local_var_str) = human {
5770            local_var_req_builder =
5771                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
5772        }
5773
5774        let local_var_req = local_var_req_builder.build()?;
5775        let local_var_resp = local_var_client.execute(local_var_req).await?;
5776
5777        let local_var_status = local_var_resp.status();
5778        let local_var_content = local_var_resp.text().await?;
5779
5780        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
5781            serde_json::from_str(&local_var_content).map_err(Error::from)
5782        } else {
5783            let local_var_error = ResponseContent {
5784                status: local_var_status,
5785                content: local_var_content,
5786            };
5787            Err(Error::ApiError(local_var_error))
5788        }
5789    }
5790    ///
5791    /// Creates or updates a document in an index.
5792    #[builder(on(String, into))]
5793    pub async fn index(
5794        &self,
5795        /// No description available
5796        index: String,
5797        body: serde_json::Value,
5798        /// No description available
5799        id: Option<String>,
5800
5801        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
5802        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
5803        timeout: Option<String>,
5804        /// No description available
5805        error_trace: Option<bool>,
5806        /// No description available
5807        filter_path: Option<common::FilterPath>,
5808        /// No description available
5809        human: Option<bool>,
5810        /// No description available
5811        if_primary_term: Option<i32>,
5812        /// No description available
5813        if_seq_no: Option<i32>,
5814        /// No description available
5815        op_type: Option<String>,
5816        /// No description available
5817        pipeline: Option<String>,
5818        /// No description available
5819        pretty: Option<bool>,
5820        /// No description available
5821        refresh: Option<common::Refresh>,
5822        /// No description available
5823        require_alias: Option<bool>,
5824        /// No description available
5825        routing: Option<common::Routing>,
5826        /// No description available
5827        source: Option<String>,
5828        /// No description available
5829        version: Option<i32>,
5830        /// No description available
5831        version_type: Option<String>,
5832        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
5833        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
5834    ) -> Result<crate::bulk::IndexResponse, Error> {
5835        let local_var_configuration = &self.configuration;
5836
5837        let local_var_client = &local_var_configuration.client;
5838
5839        let local_var_uri_str = if let Some(id) = id {
5840            format!(
5841                "{}{index}/_doc/{id}",
5842                local_var_configuration.base_path,
5843                index = index,
5844                id = id
5845            )
5846        } else {
5847            format!(
5848                "{}{index}/_doc",
5849                local_var_configuration.base_path,
5850                index = index
5851            )
5852        };
5853        let mut local_var_req_builder =
5854            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
5855        local_var_req_builder = local_var_req_builder.json(&body);
5856
5857        if let Some(ref local_var_str) = if_seq_no {
5858            local_var_req_builder =
5859                local_var_req_builder.query(&[("if_seq_no", &local_var_str.to_string())]);
5860        }
5861        if let Some(ref local_var_str) = timeout {
5862            local_var_req_builder =
5863                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
5864        }
5865        if let Some(ref local_var_str) = pipeline {
5866            local_var_req_builder =
5867                local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
5868        }
5869        if let Some(ref local_var_str) = routing {
5870            local_var_req_builder =
5871                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
5872        }
5873        if let Some(ref local_var_str) = if_primary_term {
5874            local_var_req_builder =
5875                local_var_req_builder.query(&[("if_primary_term", &local_var_str.to_string())]);
5876        }
5877        if let Some(ref local_var_str) = error_trace {
5878            local_var_req_builder =
5879                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
5880        }
5881        if let Some(ref local_var_str) = version {
5882            local_var_req_builder =
5883                local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
5884        }
5885        if let Some(ref local_var_str) = pretty {
5886            local_var_req_builder =
5887                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
5888        }
5889        if let Some(ref local_var_str) = refresh {
5890            local_var_req_builder =
5891                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
5892        }
5893        if let Some(ref local_var_str) = source {
5894            local_var_req_builder =
5895                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
5896        }
5897        if let Some(ref local_var_str) = human {
5898            local_var_req_builder =
5899                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
5900        }
5901        if let Some(ref local_var_str) = wait_for_active_shards {
5902            local_var_req_builder = local_var_req_builder
5903                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
5904        }
5905        if let Some(ref local_var_str) = require_alias {
5906            local_var_req_builder =
5907                local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
5908        }
5909        if let Some(ref local_var_str) = version_type {
5910            local_var_req_builder =
5911                local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
5912        }
5913        if let Some(ref local_var_str) = op_type {
5914            local_var_req_builder =
5915                local_var_req_builder.query(&[("op_type", &local_var_str.to_string())]);
5916        }
5917        if let Some(ref local_var_str) = filter_path {
5918            local_var_req_builder =
5919                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
5920        }
5921
5922        let local_var_req = local_var_req_builder.build()?;
5923        let local_var_resp = local_var_client.execute(local_var_req).await?;
5924
5925        let local_var_status = local_var_resp.status();
5926        let local_var_content = local_var_resp.text().await?;
5927
5928        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
5929            serde_json::from_str(&local_var_content).map_err(Error::from)
5930        } else {
5931            let local_var_error = ResponseContent {
5932                status: local_var_status,
5933                content: local_var_content,
5934            };
5935            Err(Error::ApiError(local_var_error))
5936        }
5937    }
5938    ///
5939    /// Updates a document with a script or partial document.
5940    #[builder(on(String, into))]
5941    pub async fn update(
5942        &self,
5943        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
5944        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
5945        timeout: Option<String>,
5946        /// No description available
5947        source_excludes: Option<common::SourceExcludes>,
5948        /// No description available
5949        source_includes: Option<common::SourceIncludes>,
5950        /// No description available
5951        error_trace: Option<bool>,
5952        /// No description available
5953        filter_path: Option<common::FilterPath>,
5954        /// No description available
5955        human: Option<bool>,
5956        /// No description available
5957        id: String,
5958        /// No description available
5959        if_primary_term: Option<i32>,
5960        /// No description available
5961        if_seq_no: Option<i32>,
5962        /// No description available
5963        index: String,
5964        /// No description available
5965        lang: Option<String>,
5966        /// No description available
5967        pretty: Option<bool>,
5968        /// No description available
5969        refresh: Option<common::Refresh>,
5970        /// No description available
5971        require_alias: Option<bool>,
5972        /// No description available
5973        retry_on_conflict: Option<i32>,
5974        /// No description available
5975        routing: Option<common::Routing>,
5976        /// No description available
5977        source: Option<String>,
5978        /// The request definition requires either `script` or partial `doc`
5979        update: common::Update,
5980        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
5981        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
5982    ) -> Result<crate::bulk::IndexResponse, Error> {
5983        let local_var_configuration = &self.configuration;
5984
5985        let local_var_client = &local_var_configuration.client;
5986
5987        let local_var_uri_str = format!(
5988            "{}{index}/_update/{id}",
5989            local_var_configuration.base_path,
5990            index = index,
5991            id = id
5992        );
5993        let mut local_var_req_builder =
5994            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
5995
5996        if let Some(ref local_var_str) = if_seq_no {
5997            local_var_req_builder =
5998                local_var_req_builder.query(&[("if_seq_no", &local_var_str.to_string())]);
5999        }
6000        if let Some(ref local_var_str) = refresh {
6001            local_var_req_builder =
6002                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
6003        }
6004        if let Some(ref local_var_str) = wait_for_active_shards {
6005            local_var_req_builder = local_var_req_builder
6006                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
6007        }
6008        if let Some(ref local_var_str) = routing {
6009            local_var_req_builder =
6010                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
6011        }
6012        if let Some(ref local_var_str) = if_primary_term {
6013            local_var_req_builder =
6014                local_var_req_builder.query(&[("if_primary_term", &local_var_str.to_string())]);
6015        }
6016        if let Some(ref local_var_str) = retry_on_conflict {
6017            local_var_req_builder =
6018                local_var_req_builder.query(&[("retry_on_conflict", &local_var_str.to_string())]);
6019        }
6020        if let Some(ref local_var_str) = human {
6021            local_var_req_builder =
6022                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
6023        }
6024        if let Some(ref local_var_str) = error_trace {
6025            local_var_req_builder =
6026                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
6027        }
6028        if let Some(ref local_var_str) = timeout {
6029            local_var_req_builder =
6030                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
6031        }
6032        if let Some(ref local_var_str) = source_includes {
6033            local_var_req_builder =
6034                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
6035        }
6036        if let Some(ref local_var_str) = source_excludes {
6037            local_var_req_builder =
6038                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
6039        }
6040        if let Some(ref local_var_str) = require_alias {
6041            local_var_req_builder =
6042                local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
6043        }
6044        if let Some(ref local_var_str) = pretty {
6045            local_var_req_builder =
6046                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
6047        }
6048        if let Some(ref local_var_str) = lang {
6049            local_var_req_builder =
6050                local_var_req_builder.query(&[("lang", &local_var_str.to_string())]);
6051        }
6052        if let Some(ref local_var_str) = filter_path {
6053            local_var_req_builder =
6054                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
6055        }
6056        if let Some(ref local_var_str) = source {
6057            local_var_req_builder =
6058                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
6059        }
6060
6061        local_var_req_builder = local_var_req_builder.json(&update);
6062
6063        let local_var_req = local_var_req_builder.build()?;
6064        let local_var_resp = local_var_client.execute(local_var_req).await?;
6065
6066        let local_var_status = local_var_resp.status();
6067        let local_var_content = local_var_resp.text().await?;
6068
6069        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
6070            serde_json::from_str(&local_var_content).map_err(Error::from)
6071        } else {
6072            let local_var_error = ResponseContent {
6073                status: local_var_status,
6074                content: local_var_content,
6075            };
6076            Err(Error::ApiError(local_var_error))
6077        }
6078    }
6079
6080    ///
6081    /// Updates a document with a script or partial document.
6082    #[builder(on(String, into))]
6083    pub async fn update_raw(
6084        &self,
6085        /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
6086        /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
6087        timeout: Option<String>,
6088        /// No description available
6089        source_excludes: Option<common::SourceExcludes>,
6090        /// No description available
6091        source_includes: Option<common::SourceIncludes>,
6092        /// No description available
6093        error_trace: Option<bool>,
6094        /// No description available
6095        filter_path: Option<common::FilterPath>,
6096        /// No description available
6097        human: Option<bool>,
6098        /// No description available
6099        id: String,
6100        /// No description available
6101        if_primary_term: Option<i32>,
6102        /// No description available
6103        if_seq_no: Option<i32>,
6104        /// No description available
6105        index: String,
6106        /// No description available
6107        lang: Option<String>,
6108        /// No description available
6109        pretty: Option<bool>,
6110        /// No description available
6111        refresh: Option<common::Refresh>,
6112        /// No description available
6113        require_alias: Option<bool>,
6114        /// No description available
6115        retry_on_conflict: Option<i32>,
6116        /// No description available
6117        routing: Option<common::Routing>,
6118        /// No description available
6119        source: Option<String>,
6120        /// The request definition requires either `script` or partial `doc`
6121        update: serde_json::Value,
6122        /// Waits until the specified number of shards is active before returning a response. Use `all` for all shards.
6123        wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
6124    ) -> Result<crate::bulk::IndexResponse, Error> {
6125        let local_var_configuration = &self.configuration;
6126
6127        let local_var_client = &local_var_configuration.client;
6128
6129        let local_var_uri_str = format!(
6130            "{}{index}/_update/{id}",
6131            local_var_configuration.base_path,
6132            index = index,
6133            id = id
6134        );
6135        let mut local_var_req_builder =
6136            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
6137
6138        if let Some(ref local_var_str) = if_seq_no {
6139            local_var_req_builder =
6140                local_var_req_builder.query(&[("if_seq_no", &local_var_str.to_string())]);
6141        }
6142        if let Some(ref local_var_str) = refresh {
6143            local_var_req_builder =
6144                local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
6145        }
6146        if let Some(ref local_var_str) = wait_for_active_shards {
6147            local_var_req_builder = local_var_req_builder
6148                .query(&[("wait_for_active_shards", &local_var_str.to_string())]);
6149        }
6150        if let Some(ref local_var_str) = routing {
6151            local_var_req_builder =
6152                local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
6153        }
6154        if let Some(ref local_var_str) = if_primary_term {
6155            local_var_req_builder =
6156                local_var_req_builder.query(&[("if_primary_term", &local_var_str.to_string())]);
6157        }
6158        if let Some(ref local_var_str) = retry_on_conflict {
6159            local_var_req_builder =
6160                local_var_req_builder.query(&[("retry_on_conflict", &local_var_str.to_string())]);
6161        }
6162        if let Some(ref local_var_str) = human {
6163            local_var_req_builder =
6164                local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
6165        }
6166        if let Some(ref local_var_str) = error_trace {
6167            local_var_req_builder =
6168                local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
6169        }
6170        if let Some(ref local_var_str) = timeout {
6171            local_var_req_builder =
6172                local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
6173        }
6174        if let Some(ref local_var_str) = source_includes {
6175            local_var_req_builder =
6176                local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
6177        }
6178        if let Some(ref local_var_str) = source_excludes {
6179            local_var_req_builder =
6180                local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
6181        }
6182        if let Some(ref local_var_str) = require_alias {
6183            local_var_req_builder =
6184                local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
6185        }
6186        if let Some(ref local_var_str) = pretty {
6187            local_var_req_builder =
6188                local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
6189        }
6190        if let Some(ref local_var_str) = lang {
6191            local_var_req_builder =
6192                local_var_req_builder.query(&[("lang", &local_var_str.to_string())]);
6193        }
6194        if let Some(ref local_var_str) = filter_path {
6195            local_var_req_builder =
6196                local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
6197        }
6198        if let Some(ref local_var_str) = source {
6199            local_var_req_builder =
6200                local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
6201        }
6202
6203        local_var_req_builder = local_var_req_builder.json(&update);
6204
6205        let local_var_req = local_var_req_builder.build()?;
6206        let local_var_resp = local_var_client.execute(local_var_req).await?;
6207
6208        let local_var_status = local_var_resp.status();
6209        let local_var_content = local_var_resp.text().await?;
6210
6211        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
6212            serde_json::from_str(&local_var_content).map_err(Error::from)
6213        } else {
6214            let local_var_error = ResponseContent {
6215                status: local_var_status,
6216                content: local_var_content,
6217            };
6218            Err(Error::ApiError(local_var_error))
6219        }
6220    }
6221
6222    /// Get the version of this API.
6223    ///
6224    /// This string is pulled directly from the source OpenAPI
6225    /// document and may be in any format the API selects.
6226    pub fn api_version(&self) -> &'static str {
6227        "2025-07-22"
6228    }
6229
6230    /// Sends a bulk index request to OpenSearch with the specified index, id and
6231    /// document body.
6232    ///
6233    /// # Arguments
6234    ///
6235    /// * `index` - A string slice that holds the name of the index.
6236    /// * `id` - An optional string slice that holds the id of the document.
6237    /// * `body` - A reference to a serializable document body.
6238    ///
6239    /// # Returns
6240    ///
6241    /// Returns a Result containing a serde_json::Value representing the response
6242    /// from OpenSearch or an Error if the request fails.
6243    ///
6244    /// # Example
6245    ///
6246    /// ```
6247    /// use opensearch_client::OpenSearchClient;
6248    ///
6249    /// #[derive(Serialize)]
6250    /// struct MyDocument {
6251    ///   title: String,
6252    ///   content: String,
6253    /// }
6254    ///
6255    /// #[tokio::main]
6256    /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
6257    ///   let client = OpenSearchClient::new("http://localhost:9200");
6258    ///   let document = MyDocument {
6259    ///     title: "My Title".to_string(),
6260    ///     content: "My Content".to_string(),
6261    ///   };
6262    ///   let response = client
6263    ///     .bulk_index_document("my_index", Some("my_id".to_string()), &document)
6264    ///     .await?;
6265    ///   Ok(())
6266    /// }
6267    /// ```
6268    pub async fn bulk_index_document<T: Serialize>(
6269        &self,
6270        index: &str,
6271        id: Option<String>,
6272        body: &T,
6273    ) -> Result<(), Error> {
6274        let body_json = serde_json::to_value(body)?;
6275        let action = BulkAction::Index(IndexAction {
6276            index: index.to_owned(),
6277            id: id.clone(),
6278            pipeline: None,
6279        });
6280        self.bulk_action(action, Some(&body_json)).await
6281    }
6282
6283    /// Sends a bulk action to the OpenSearch server.
6284    ///
6285    /// # Arguments
6286    ///
6287    /// * `command` - A string slice that holds the command to be executed.
6288    /// * `action` - A `BulkAction` enum that specifies the action to be taken.
6289    /// * `body` - An optional `serde_json::Value` that holds the request body.
6290    ///
6291    /// # Returns
6292    ///
6293    /// A `Result` containing a `serde_json::Value` object representing the
6294    /// response from the server, or an `Error` if the request failed.
6295    ///
6296    /// # Examples
6297    ///
6298    /// ```
6299    /// use opensearch_client::{BulkAction, OpenSearchClient};
6300    ///
6301    /// #[tokio::main]
6302    /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
6303    ///   let client = OpenSearchClient::new("http://localhost:9200")?;
6304    ///   let action = BulkAction::Index {
6305    ///     index: "my_index".to_string(),
6306    ///     id: Some("1".to_string()),
6307    ///   };
6308    ///   let response = client.bulk_action("index", action, None).await?;
6309    ///   Ok(())
6310    /// }
6311    /// ```
6312    pub async fn bulk_action(
6313        &self,
6314        action: BulkAction,
6315        body: Option<&serde_json::Value>,
6316    ) -> Result<(), Error> {
6317        let j = serde_json::to_string(&action)?;
6318        let bulker_arc = Arc::clone(&self.configuration.bulker);
6319        let mut bulker = bulker_arc.lock().unwrap();
6320        bulker.push_str(j.as_str());
6321        bulker.push('\n');
6322        match body {
6323            None => {}
6324            Some(js) => {
6325                let j = serde_json::to_string(js)?;
6326                bulker.push_str(j.as_str());
6327                bulker.push('\n');
6328            }
6329        }
6330
6331        let bulker_size_arc = Arc::clone(&self.configuration.bulker_size);
6332        let mut bulker_size = bulker_size_arc.lock().unwrap();
6333        *bulker_size += 1;
6334        if *bulker_size >= self.configuration.max_bulk_size {
6335            drop(bulker_size);
6336            drop(bulker);
6337            self.flush_bulk().await?;
6338        }
6339        Ok(())
6340    }
6341
6342    /// Sends a bulk create request to the OpenSearch cluster with the specified
6343    /// index, id and body.
6344    ///
6345    /// # Arguments
6346    ///
6347    /// * `index` - A string slice that holds the name of the index.
6348    /// * `id` - A string slice that holds the id of the document.
6349    /// * `body` - A generic type `T` that holds the body of the document to be
6350    ///   created.
6351    ///
6352    /// # Returns
6353    ///
6354    /// Returns a `Result` containing a `serde_json::Value` on success, or an
6355    /// `Error` on failure.
6356    pub async fn bulk_create_document<T: Serialize>(
6357        &self,
6358        index: &str,
6359        id: &str,
6360        body: &T,
6361    ) -> Result<(), Error> {
6362        let body_json = serde_json::to_value(body)?;
6363
6364        let action = BulkAction::Create(CreateAction {
6365            index: index.to_owned(),
6366            id: id.to_owned(),
6367            ..Default::default()
6368        });
6369
6370        self.bulk_action(action, Some(&body_json)).await
6371    }
6372
6373    /// Asynchronously updates a document in bulk.
6374    ///
6375    /// # Arguments
6376    ///
6377    /// * `index` - A string slice that holds the name of the index.
6378    /// * `id` - A string slice that holds the ID of the document to update.
6379    /// * `body` - An `UpdateAction` struct that holds the update action to
6380    ///   perform.
6381    ///
6382    /// # Returns
6383    ///
6384    /// Returns a `Result` containing a `serde_json::Value` on success, or an
6385    /// `Error` on failure.
6386    pub async fn bulk_update_document(
6387        &self,
6388        index: &str,
6389        id: &str,
6390        body: &UpdateActionBody,
6391    ) -> Result<(), Error> {
6392        let action = BulkAction::Update(UpdateAction {
6393            index: index.to_owned(),
6394            id: id.to_owned(),
6395            ..Default::default()
6396        });
6397        let j = serde_json::to_value(body)?;
6398        self.bulk_action(action, Some(&j)).await
6399    }
6400
6401    /// Sends a bulk request to the OpenSearch server and returns a
6402    /// `BulkResponse`. If the bulker size is 0, it returns an empty
6403    /// `BulkResponse`. If the bulk request contains errors, it logs the errors
6404    /// and returns the `BulkResponse`.
6405    ///
6406    /// # Examples
6407    ///
6408    /// ```no_run
6409    /// use opensearch_client::OpenSearchClient;
6410    ///
6411    /// #[tokio::main]
6412    /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
6413    ///   let client = OpenSearchClient::new("http://localhost:9200", "user", "password");
6414    ///   let response = client.flush_bulk().await?;
6415    ///   println!("{:?}", response);
6416    ///   Ok(())
6417    /// }
6418    /// ```
6419    pub async fn flush_bulk(&self) -> Result<BulkResponse, Error> {
6420        let bulker_size_arc = Arc::clone(&self.configuration.bulker_size);
6421        let mut bulker_size = bulker_size_arc.lock().unwrap();
6422        if *bulker_size > 0 {
6423            let bulker_arc = Arc::clone(&self.configuration.bulker);
6424            let mut bulker = bulker_arc.lock().unwrap();
6425
6426            // let request_url = format!("{}_bulk", self.server);
6427
6428            match self.bulk().body(bulker.to_owned()).call().await
6429        // .client
6430        // .post(request_url)
6431        // .basic_auth(self.user.as_str(), Some(self.password.as_str()))
6432        // .body()
6433        // .header("Content-Type", "application/x-ndjson")
6434        // .send()
6435        // .await
6436      {
6437        Ok(result) => {
6438          *bulker = String::new();
6439          *bulker_size = 0;
6440          // debug!("{:?}", &result);
6441          if result.errors {
6442            for map in &result.items {
6443              for (_, value) in map.iter() {
6444                if let Some(error) = &value.error {
6445                  if !error.kind.eq_ignore_ascii_case("version_conflict_engine_exception") {
6446                    tracing::trace!("{:?}", &value);
6447                  }
6448                }
6449              }
6450            }
6451          }
6452
6453          Ok(result)
6454        }
6455        Err(err) => {
6456          println!("{:?}", &err);
6457          Err(err)
6458        }
6459      }
6460        } else {
6461            Ok(BulkResponse {
6462                took: 0,
6463                errors: false,
6464                items: vec![],
6465                ingest_took: None,
6466            })
6467        }
6468    }
6469
6470    /// Indexes a document in the specified index with the given body and optional
6471    /// ID.
6472    ///
6473    /// # Arguments
6474    ///
6475    /// * `index` - A string slice that holds the name of the index to which the
6476    ///   document will be added.
6477    /// * `body` - A reference to a serializable object that represents the
6478    ///   document to be added.
6479    /// * `id` - An optional string slice that holds the ID of the document to be
6480    ///   added. If not provided, a new ID will be generated.
6481    ///
6482    /// # Returns
6483    ///
6484    /// A `Result` containing an `IndexResponse` object if the operation was
6485    /// successful, or an `Error` if an error occurred.
6486    ///
6487    /// # Examples
6488    ///
6489    /// ```
6490    /// use opensearch_client::Client;
6491    ///
6492    /// #[derive(Serialize)]
6493    /// struct MyDocument {
6494    ///   title: String,
6495    ///   content: String,
6496    /// }
6497    ///
6498    /// #[tokio::main]
6499    /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
6500    ///   let client = Client::new("http://localhost:9200")?;
6501    ///
6502    ///   let document = MyDocument {
6503    ///     title: "My Title".to_string(),
6504    ///     content: "My Content".to_string(),
6505    ///   };
6506    ///
6507    ///   let response = client.index_document("my_index", &document, None).await?;
6508    ///
6509    ///   println!("Document ID: {}", response._id);
6510    ///
6511    ///   Ok(())
6512    /// }
6513    /// ```
6514    pub async fn index_document<T: Serialize>(
6515        &self,
6516        index: &str,
6517        body: &T,
6518        id: Option<String>,
6519    ) -> Result<crate::bulk::IndexResponse, Error> {
6520        let body_json = serde_json::to_value(body)?;
6521        let partial_request = self.index().index(index).body(body_json).maybe_id(id);
6522        let response = partial_request.call().await?;
6523        Ok(response)
6524    }
6525
6526    /// Creates a new document in the specified index with the given ID and body.
6527    ///
6528    /// # Arguments
6529    ///
6530    /// * `index` - A string slice that holds the name of the index.
6531    /// * `id` - A string slice that holds the ID of the document.
6532    /// * `body` - A generic type `T` that holds the body of the document. The
6533    ///   type `T` must implement the `Serialize` trait from the `serde` crate.
6534    ///
6535    /// # Returns
6536    ///
6537    /// Returns a `Result` containing an `IndexResponse` on success, or an `Error`
6538    /// on failure.
6539    ///
6540    /// # Examples
6541    ///
6542    /// ```rust
6543    /// use opensearch_client::OpenSearchClient;
6544    ///
6545    /// #[derive(Serialize)]
6546    /// struct MyDocument {
6547    ///   title: String,
6548    ///   content: String,
6549    /// }
6550    ///
6551    /// #[tokio::main]
6552    /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
6553    ///   let client = OpenSearchClient::new("http://localhost:9200")?;
6554    ///
6555    ///   let document = MyDocument {
6556    ///     title: "My Title".to_string(),
6557    ///     content: "My Content".to_string(),
6558    ///   };
6559    ///
6560    ///   let response = client.create_document("my_index", "1", &document).await?;
6561    ///
6562    ///   Ok(())
6563    /// }
6564    /// ```
6565    pub async fn create_document<T: Serialize>(
6566        &self,
6567        index: &str,
6568        id: &str,
6569        body: &T,
6570    ) -> Result<crate::bulk::IndexResponse, Error> {
6571        let body_json = serde_json::to_value(body)?;
6572
6573        let response = self
6574            .create()
6575            .index(index)
6576            .id(id)
6577            .body(body_json)
6578            .call()
6579            .await?;
6580
6581        Ok(response)
6582    }
6583
6584    /// Asynchronously retrieves a typed document from the specified index and ID.
6585    ///
6586    /// # Arguments
6587    ///
6588    /// * `index` - A string slice that holds the name of the index to retrieve
6589    ///   the document from.
6590    /// * `id` - A string slice that holds the ID of the document to retrieve.
6591    ///
6592    /// # Returns
6593    ///
6594    /// A `Result` containing the deserialized content of the retrieved document,
6595    /// or an `Error` if the operation failed.
6596    ///
6597    /// # Generic Type Parameters
6598    ///
6599    /// * `T` - The type of the document to retrieve. Must implement the
6600    ///   `DeserializeOwned` and
6601    /// `std::default::Default` traits.
6602    pub async fn get_typed<T: DeserializeOwned>(
6603        &self,
6604        index: &str,
6605        id: &str,
6606    ) -> Result<crate::core::get::GetTypedResult<T>, Error> {
6607        let response = self.get().index(index).id(id).call().await?;
6608        let result = response.parse::<T>()?;
6609
6610        Ok(result)
6611    }
6612
6613    /// Updates a document in the specified index with the given ID using the
6614    /// provided update action.
6615    ///
6616    /// # Arguments
6617    ///
6618    /// * `index` - A string slice that holds the name of the index to update the
6619    ///   document in.
6620    /// * `id` - A string slice that holds the ID of the document to update.
6621    /// * `action` - A reference to an `UpdateAction` enum that specifies the
6622    ///   update action to perform.
6623    ///
6624    /// # Returns
6625    ///
6626    /// Returns a `Result` containing an `IndexResponse` struct if the update was
6627    /// successful, or an `Error` if an error occurred.
6628    ///
6629    /// # Example
6630    ///
6631    /// ```rust
6632    /// use opensearch_client::{Client, UpdateAction};
6633    ///
6634    /// #[tokio::main]
6635    /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
6636    ///     let client = Client::new("http://localhost:9200")?;
6637    ///
6638    ///     let index = "my_index";
6639    ///     let id = "1";
6640    ///     let action = UpdateAction::new().doc(json!({"foo": "bar"}));
6641    ///
6642    ///     let response = client.update_document(index, id, &action).await?;
6643    ///
6644    ///     Ok(())
6645    /// }
6646    /// ```
6647    pub async fn update_document(
6648        &self,
6649        index: &str,
6650        id: &str,
6651        action: &UpdateActionBody,
6652    ) -> Result<crate::bulk::IndexResponse, Error> {
6653        let body = serde_json::to_value(&action)?;
6654
6655        let response = self
6656            .update_raw()
6657            .update(body)
6658            .index(index)
6659            .id(id)
6660            .call()
6661            .await?;
6662        Ok(response)
6663    }
6664
6665    pub fn get_bulker(
6666        &self,
6667        bulk_size: u32,
6668        max_concurrent_connections: u32,
6669    ) -> (JoinHandle<()>, Bulker) {
6670        Bulker::new(
6671            Arc::new(self.clone()),
6672            bulk_size,
6673            max_concurrent_connections,
6674        )
6675    }
6676
6677    pub fn bulker(&self) -> BulkerBuilder {
6678        BulkerBuilder::new(Arc::new(self.clone()), self.configuration.max_bulk_size)
6679    }
6680
6681    pub async fn search_typed<T: DeserializeOwned /*+ std::default::Default*/>(
6682        &self,
6683        index: &str,
6684        search: Search,
6685    ) -> Result<crate::search::TypedSearchResult<T>, Error> {
6686        let response = self.search().index(index).search(search).call().await?;
6687        crate::search::TypedSearchResult::from_response(response)
6688    }
6689
6690    /// Searches for documents in the specified index and returns a stream of
6691    /// hits.
6692    ///
6693    /// # Arguments
6694    ///
6695    /// * `index` - The name of the index to search in.
6696    /// * `query` - The query to execute.
6697    /// * `sort` - The sort criteria to use.
6698    /// * `size` - The maximum number of hits to return.
6699    ///
6700    /// # Returns
6701    ///
6702    /// A stream of hits that match the specified search criteria.
6703    ///
6704    /// # Examples
6705    ///
6706    /// ```rust
6707    /// use opensearch_client::{Client, Query, SortCollection};
6708    ///
6709    /// #[tokio::main]
6710    /// async fn main() -> Result<(), Box<dyn std::error::Error>> {
6711    ///   let client = Client::new("http://localhost:9200")?;
6712    ///   let query = Query::match_all();
6713    ///   let sort = SortCollection::new().add_field("_doc", "asc");
6714    ///   let stream = client.search_stream("my_index", &query, &sort, 10).await?;
6715    ///   stream
6716    ///     .for_each(|hit| {
6717    ///       println!("{:?}", hit);
6718    ///       futures::future::ready(())
6719    ///     })
6720    ///     .await;
6721    ///   Ok(())
6722    /// }
6723    /// ```
6724    pub async fn search_stream<T: DeserializeOwned + std::default::Default>(
6725        &self,
6726        index: &str,
6727        query: &Query,
6728        sort: &SortCollection,
6729        size: u64,
6730    ) -> Result<impl Stream<Item = crate::search::TypedHit<T>> + 'static, Error> {
6731        let start_state = crate::search::SearchAfterState {
6732            client: Arc::new(self.clone()),
6733            stop: false,
6734            search_after: None,
6735            index: index.to_owned(),
6736            query: query.clone(),
6737            sort: sort.clone(),
6738            size,
6739        };
6740
6741        async fn stream_next<T: DeserializeOwned + std::default::Default>(
6742            state: crate::search::SearchAfterState,
6743        ) -> Result<
6744            (
6745                Vec<crate::search::TypedHit<T>>,
6746                crate::search::SearchAfterState,
6747            ),
6748            Error,
6749        > {
6750            let mut body: Search = Search::new()
6751                .size(state.size)
6752                .query(state.query.clone())
6753                .sort(state.sort.clone());
6754
6755            if let Some(search_after) = state.search_after.clone() {
6756                body = body.search_after(search_after.clone());
6757            }
6758            let response = state
6759                .client
6760                .clone()
6761                .search()
6762                .index(&state.index)
6763                .search(body)
6764                .call()
6765                .await?;
6766            let hits = response
6767                .hits
6768                .hits
6769                .into_iter()
6770                .map(|hit| {
6771                    let typed_hit: crate::search::TypedHit<T> =
6772                        crate::search::TypedHit::from_hit(hit);
6773                    typed_hit
6774                })
6775                .collect::<Vec<_>>();
6776            let next_state = crate::search::SearchAfterState {
6777                stop: (hits.len() as u64) < state.size,
6778                search_after: hits.iter().last().and_then(|f| {
6779                    let last_sort = f.sort.clone();
6780                    if last_sort.is_empty() {
6781                        None
6782                    } else {
6783                        Some(opensearch_dsl::Terms::from(last_sort))
6784                    }
6785                }),
6786                ..state
6787            };
6788
6789            Ok((hits, next_state))
6790        }
6791
6792        let stream = stream::unfold(start_state, move |state| async move {
6793            if state.stop {
6794                None
6795            } else {
6796                let result = stream_next::<T>(state).await;
6797                match result {
6798                    Ok((items, state)) => Some((stream::iter(items), state)),
6799                    Err(_err) => None,
6800                }
6801            }
6802        });
6803
6804        Ok(stream.flatten())
6805    }
6806
6807    // pub async fn send<T: Request + Serialize>(
6808    //     &self,
6809    //     request: T,
6810    // ) -> Result<ResponseValue<T::Response>, Error> {
6811    //     let body = request.body()?;
6812    //     let url = request.url(self.configuration.base_path.clone().as_ref())?;
6813    //     let mut request_builder = self.configuration.client.request(request.method(), url);
6814    //     if let Some(body) = body {
6815    //         request_builder = request_builder.body(body);
6816    //     }
6817    //     let response = request_builder.send().await?;
6818    //     match response.status().as_u16() {
6819    //         200u16 => ResponseValue::from_response(response).await,
6820    //         _ => Err(Error::UnexpectedResponse(
6821    //             ReqwestResponse::from_response(response).await,
6822    //         )),
6823    //     }
6824    // }
6825}