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