use std::collections::HashMap;
use futures::stream::{self, StreamExt};
use std::error;
use std::fmt;
use tokio::task::JoinHandle;
pub mod auth_middleware;
pub mod credentials;
use crate::bulk::*;
use crate::bulker::Bulker;
use crate::bulker::BulkerBuilder;
use crate::common;
use crate::common::*;
use bon::bon;
use futures::Stream;
use opensearch_dsl::Query;
use opensearch_dsl::SortCollection;
use serde::de::DeserializeOwned;
use serde::Serialize;
use thiserror::Error;
use url::Url;
pub trait Request {
type Response: DeserializeOwned + Send + Sync;
fn method(&self) -> reqwest::Method;
fn path(&self) -> Result<String, Error>;
fn body(&self) -> Result<Option<String>, Error>;
fn query_args(&self) -> Result<Option<HashMap<String, String>>, Error>;
fn url(&self, base_url: &Url) -> Result<Url, Error> {
let mut url = base_url.clone();
url.set_path(&self.path()?);
if let Some(query_args) = self.query_args()? {
url.query_pairs_mut()
.clear()
.extend_pairs(query_args.iter());
}
Ok(url)
}
}
#[derive(Debug, Clone)]
pub struct ResponseContent {
pub status: reqwest::StatusCode,
pub content: String,
}
impl fmt::Display for ResponseContent {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"ResponseContent {{ status: {}, content: {} }}",
self.status, self.content
)
}
}
#[derive(Debug, Error)]
pub enum Error {
#[error("Document Already Exists: ({0},{1})")]
DocumentAlreadyExistsError(String, String),
#[error("Not found: ({0},{1})")]
DocumentNotFoundError(String, String),
#[error(transparent)]
InvalidResponsePayload(#[from] reqwest::Error),
#[error(transparent)]
CommunicationError(#[from] reqwest_middleware::Error),
#[error(transparent)]
Serde(#[from] serde_json::Error),
#[error(transparent)]
UrlParseError(#[from] url::ParseError),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("Credential error: {0}")]
CredentialsConfigError(String),
#[error("ApiError: {0}")]
ApiError(ResponseContent),
#[error("UnexpectedStatusCode: {0}")]
UnexpectedStatusCode(reqwest::StatusCode),
#[error("Internal Error: {0}")]
InternalError(String),
}
#[cfg(feature = "loco")]
impl From<Error> for loco_rs::prelude::Error {
fn from(err: Error) -> Self {
use axum::http::StatusCode;
use loco_rs::controller::ErrorDetail;
use loco_rs::prelude::Error as LocoError;
match err {
Error::DocumentAlreadyExistsError(_, _) => LocoError::InternalServerError,
Error::DocumentNotFoundError(index, id) => LocoError::CustomError(
StatusCode::NOT_FOUND,
ErrorDetail::new("Error", &format!("Document not found: ({}, {})", index, id)),
),
_ => LocoError::CustomError(
StatusCode::INTERNAL_SERVER_ERROR,
ErrorDetail::new("OpenSearch Error", &err.to_string()),
),
}
}
}
pub fn urlencode<T: AsRef<str>>(s: T) -> String {
::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect()
}
pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> {
if let serde_json::Value::Object(object) = value {
let mut params = vec![];
for (key, value) in object {
match value {
serde_json::Value::Object(_) => params.append(&mut parse_deep_object(
&format!("{}[{}]", prefix, key),
value,
)),
serde_json::Value::Array(array) => {
for (i, value) in array.iter().enumerate() {
params.append(&mut parse_deep_object(
&format!("{}[{}][{}]", prefix, key, i),
value,
));
}
}
serde_json::Value::String(s) => {
params.push((format!("{}[{}]", prefix, key), s.clone()))
}
_ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
}
}
return params;
}
unimplemented!("Only objects are supported with style=deepObject")
}
#[allow(dead_code)]
pub enum ContentType {
Json,
Text,
Unsupported(String),
}
impl From<&str> for ContentType {
fn from(content_type: &str) -> Self {
if content_type.starts_with("application") && content_type.contains("json") {
return Self::Json;
} else if content_type.starts_with("text/plain") {
return Self::Text;
} else {
return Self::Unsupported(content_type.to_string());
}
}
}
pub mod configuration;
use std::sync::Arc;
use crate::ConfigurationBuilder;
#[derive(Clone)]
pub struct OsClient {
configuration: Arc<crate::Configuration>,
#[cfg(feature = "asynchronous_search")]
asynchronous_search_api: Arc<crate::asynchronous_search::AsynchronousSearchApi>,
#[cfg(feature = "cat")]
cat_api: Arc<crate::cat::CatApi>,
#[cfg(feature = "cluster")]
cluster_api: Arc<crate::cluster::ClusterApiClient>,
#[cfg(feature = "dangling_indices")]
dangling_indices_api: Arc<crate::dangling_indices::DanglingIndicesApi>,
#[cfg(feature = "indices")]
indices_api: Arc<crate::indices::IndicesApiClient>,
#[cfg(feature = "ingest")]
ingest_api: Arc<crate::ingest::IngestApiClient>,
#[cfg(feature = "insights")]
insights_api: Arc<crate::insights::InsightsApi>,
#[cfg(feature = "ism")]
ism_api: Arc<crate::ism::IsmApi>,
#[cfg(feature = "knn")]
knn_api: Arc<crate::knn::KnnApi>,
#[cfg(feature = "ml")]
ml_api: Arc<crate::ml::MlApiClient>,
#[cfg(feature = "nodes")]
nodes_api: Arc<crate::nodes::NodesApi>,
#[cfg(feature = "notifications")]
notifications_api: Arc<crate::notifications::NotificationsApi>,
#[cfg(feature = "observability")]
observability_api: Arc<crate::observability::ObservabilityApi>,
#[cfg(feature = "ppl")]
ppl_api: Arc<crate::ppl::PplApi>,
#[cfg(feature = "remote_store")]
remote_store_api: Arc<crate::remote_store::RemoteStoreApi>,
#[cfg(feature = "replication")]
replication_api: Arc<crate::replication::ReplicationApi>,
#[cfg(feature = "rollups")]
rollups_api: Arc<crate::rollups::RollupsApi>,
#[cfg(feature = "security")]
security_api: Arc<crate::security::SecurityApi>,
#[cfg(feature = "snapshot")]
snapshot_api: Arc<crate::snapshot::SnapshotApi>,
#[cfg(feature = "sql")]
sql_api: Arc<crate::sql::SqlApi>,
#[cfg(feature = "tasks")]
tasks_api: Arc<crate::tasks::TasksApi>,
#[cfg(feature = "transforms")]
transforms_api: Arc<crate::transforms::TransformsApi>,
}
#[bon]
impl OsClient {
pub fn new(configuration: Arc<crate::Configuration>) -> Self {
Self {
configuration: configuration.clone(),
#[cfg(feature = "asynchronous_search")]
asynchronous_search_api: Arc::new(
asynchronous_search::AsynchronousSearchApiClient::new(configuration.clone()),
),
#[cfg(feature = "cat")]
cat_api: Arc::new(crate::cat::CatApiClient::new(configuration.clone())),
#[cfg(feature = "cluster")]
cluster_api: Arc::new(crate::cluster::ClusterApiClient::new(configuration.clone())),
#[cfg(feature = "dangling_indices")]
dangling_indices_api: Arc::new(crate::dangling_indices::DanglingIndicesApiClient::new(
configuration.clone(),
)),
#[cfg(feature = "indices")]
indices_api: Arc::new(crate::indices::IndicesApiClient::new(configuration.clone())),
#[cfg(feature = "ingest")]
ingest_api: Arc::new(crate::ingest::IngestApiClient::new(configuration.clone())),
#[cfg(feature = "insights")]
insights_api: Arc::new(crate::insights::InsightsApiClient::new(
configuration.clone(),
)),
#[cfg(feature = "ism")]
ism_api: Arc::new(crate::ism::IsmApiClient::new(configuration.clone())),
#[cfg(feature = "knn")]
knn_api: Arc::new(crate::knn::KnnApiClient::new(configuration.clone())),
#[cfg(feature = "ml")]
ml_api: Arc::new(crate::ml::MlApiClient::new(configuration.clone())),
#[cfg(feature = "nodes")]
nodes_api: Arc::new(crate::nodes::NodesApiClient::new(configuration.clone())),
#[cfg(feature = "notifications")]
notifications_api: Arc::new(notifications::NotificationsApiClient::new(
configuration.clone(),
)),
#[cfg(feature = "observability")]
observability_api: Arc::new(observability::ObservabilityApiClient::new(
configuration.clone(),
)),
#[cfg(feature = "ppl")]
ppl_api: Arc::new(crate::ppl::PplApiClient::new(configuration.clone())),
#[cfg(feature = "remote_store")]
remote_store_api: Arc::new(remote_store::RemoteStoreApiClient::new(
configuration.clone(),
)),
#[cfg(feature = "replication")]
replication_api: Arc::new(replication::ReplicationApiClient::new(
configuration.clone(),
)),
#[cfg(feature = "rollups")]
rollups_api: Arc::new(crate::rollups::RollupsApiClient::new(configuration.clone())),
#[cfg(feature = "security")]
security_api: Arc::new(crate::security::SecurityApiClient::new(
configuration.clone(),
)),
#[cfg(feature = "snapshot")]
snapshot_api: Arc::new(crate::snapshot::SnapshotApiClient::new(
configuration.clone(),
)),
#[cfg(feature = "sql")]
sql_api: Arc::new(crate::sql::SqlApiClient::new(configuration.clone())),
#[cfg(feature = "tasks")]
tasks_api: Arc::new(crate::tasks::TasksApiClient::new(configuration.clone())),
#[cfg(feature = "transforms")]
transforms_api: Arc::new(crate::transforms::TransformsApiClient::new(
configuration.clone(),
)),
}
}
pub fn from_environment() -> Result<OsClient, Error> {
let accept_invalid_certificates: bool = match std::env::var("OPENSEARCH_SSL_VERIFY") {
Ok(value) => value.eq_ignore_ascii_case("false"),
Err(_) => false,
};
let user: String = match std::env::var("OPENSEARCH_USER") {
Ok(user) => user,
Err(_) => "admin".into(),
};
let password: String = match std::env::var("OPENSEARCH_PASSWORD") {
Ok(password) => password,
Err(_) => "admin".into(),
};
let server = match std::env::var("OPENSEARCH_URL") {
Ok(server) => server,
Err(_) => "https://localhost:9200".into(),
};
let mut builder = ConfigurationBuilder::new().base_url(Url::parse(&server)?);
if accept_invalid_certificates {
builder = builder.accept_invalid_certificates(true);
}
builder = builder.basic_auth(user, password);
if let Ok(max_bulk_size) = std::env::var("OPENSEARCH_MAX_BULK_SIZE") {
match max_bulk_size.parse::<u32>() {
Ok(max_bulk_size) => builder = builder.max_bulk_size(max_bulk_size),
Err(_) => {
tracing::info!("Invalid value for OPENSEARCH_MAX_BULK_SIZE, using default")
}
}
};
Ok(builder.build())
}
#[cfg(feature = "quickwit")]
pub fn from_quickwit_environment() -> Result<OsClient, Error> {
let accept_invalid_certificates: bool = match std::env::var("QUICKWIT_SSL_VERIFY") {
Ok(value) => value.eq_ignore_ascii_case("false"),
Err(_) => false,
};
let mut server = match std::env::var("QUICKWIT_URL") {
Ok(server) => server,
Err(_) => "http://localhost:7280".into(),
};
if !server.ends_with("/api/v1/_elastic") {
server.push_str("/api/v1/_elastic");
}
let mut builder = ConfigurationBuilder::new().base_url(Url::parse(&server)?);
if accept_invalid_certificates {
builder = builder.accept_invalid_certificates(true);
}
if let Ok(max_bulk_size) = std::env::var("QUICKWIT_MAX_BULK_SIZE") {
match max_bulk_size.parse::<u32>() {
Ok(max_bulk_size) => builder = builder.max_bulk_size(max_bulk_size),
Err(_) => info!("Invalid value for QUICKWIT_MAX_BULK_SIZE, using default"),
}
};
Ok(builder.build())
}
#[cfg(feature = "indices")]
pub fn indices(&self) -> &crate::indices::IndicesApiClient {
&self.indices_api
}
#[cfg(feature = "cluster")]
pub fn cluster(&self) -> &crate::cluster::ClusterApiClient {
&self.cluster_api
}
#[cfg(feature = "asynchronous_search")]
pub fn asynchronous_search(&self) -> &crate::asynchronous_search::AsynchronousSearchApi {
&self.asynchronous_search_api
}
#[cfg(feature = "cat")]
pub fn cat(&self) -> &crate::cat::CatApi {
&self.cat_api
}
#[cfg(feature = "dangling_indices")]
pub fn dangling_indices(&self) -> &crate::dangling_indices::DanglingIndicesApi {
&self.dangling_indices_api
}
#[cfg(feature = "ingest")]
pub fn ingest(&self) -> &crate::ingest::IngestApiClient {
&self.ingest_api
}
#[cfg(feature = "insights")]
pub fn insights(&self) -> &crate::insights::InsightsApi {
&self.insights_api
}
#[cfg(feature = "ism")]
pub fn ism(&self) -> &crate::ism::IsmApi {
&self.ism_api
}
#[cfg(feature = "knn")]
pub fn knn(&self) -> &crate::knn::KnnApi {
&self.knn_api
}
#[cfg(feature = "ml")]
pub fn ml(&self) -> &crate::ml::MlApiClient {
&self.ml_api
}
#[cfg(feature = "nodes")]
pub fn nodes(&self) -> &crate::nodes::NodesApi {
&self.nodes_api
}
#[cfg(feature = "notifications")]
pub fn notifications(&self) -> &crate::notifications::NotificationsApi {
&self.notifications_api
}
#[cfg(feature = "observability")]
pub fn observability(&self) -> &crate::observability::ObservabilityApi {
&self.observability_api
}
#[cfg(feature = "ppl")]
pub fn ppl(&self) -> &crate::ppl::PplApi {
&self.ppl_api
}
#[cfg(feature = "remote_store")]
pub fn remote_store(&self) -> &crate::remote_store::RemoteStoreApi {
&self.remote_store_api
}
#[cfg(feature = "replication")]
pub fn replication(&self) -> &crate::replication::ReplicationApi {
&self.replication_api
}
#[cfg(feature = "rollups")]
pub fn rollups(&self) -> &crate::rollups::RollupsApi {
&self.rollups_api
}
#[cfg(feature = "security")]
pub fn security(&self) -> &crate::security::SecurityApi {
&self.security_api
}
#[cfg(feature = "snapshot")]
pub fn snapshot(&self) -> &crate::snapshot::SnapshotApi {
&self.snapshot_api
}
#[cfg(feature = "sql")]
pub fn sql(&self) -> &crate::sql::SqlApi {
&self.sql_api
}
#[cfg(feature = "tasks")]
pub fn tasks(&self) -> &crate::tasks::TasksApi {
&self.tasks_api
}
#[cfg(feature = "transforms")]
pub fn transforms(&self) -> &crate::transforms::TransformsApi {
&self.transforms_api
}
#[cfg(feature = "tools")]
pub fn tools(&self) -> crate::tools::Tools {
crate::tools::Tools::new(Arc::new(self.clone()))
}
#[builder(on(String, into))]
pub async fn delete_script(
&self,
cluster_manager_timeout: Option<String>,
master_timeout: Option<String>,
timeout: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
pretty: Option<bool>,
source: Option<String>,
) -> Result<crate::common::AcknowledgedResponseBase, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}_scripts/{id}",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder
.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder =
local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn termvectors(
&self,
termvectors: common::Termvectors,
error_trace: Option<bool>,
field_statistics: Option<bool>,
fields: Option<common::Fields>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
index: String,
offsets: Option<bool>,
payloads: Option<bool>,
positions: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
realtime: Option<bool>,
routing: Option<common::Routing>,
source: Option<String>,
term_statistics: Option<bool>,
version: Option<i32>,
version_type: Option<String>,
) -> Result<crate::common::TermvectorsResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_termvectors/{id}",
local_var_configuration.base_path,
index = index,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = positions {
local_var_req_builder =
local_var_req_builder.query(&[("positions", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = fields {
local_var_req_builder =
local_var_req_builder.query(&[("fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version_type {
local_var_req_builder =
local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = offsets {
local_var_req_builder =
local_var_req_builder.query(&[("offsets", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = term_statistics {
local_var_req_builder =
local_var_req_builder.query(&[("term_statistics", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = field_statistics {
local_var_req_builder =
local_var_req_builder.query(&[("field_statistics", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = realtime {
local_var_req_builder =
local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = payloads {
local_var_req_builder =
local_var_req_builder.query(&[("payloads", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&termvectors);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn info(
&self,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
source: Option<String>,
) -> Result<crate::common::InfoResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn search_shards(
&self,
allow_no_indices: Option<bool>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
ignore_unavailable: Option<bool>,
local: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
routing: Option<common::Routing>,
source: Option<String>,
expand_wildcards: Option<common::ExpandWildcards>,
) -> Result<crate::common::SearchShardsResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_search_shards", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = local {
local_var_req_builder =
local_var_req_builder.query(&[("local", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn put_script(
&self,
cluster_manager_timeout: Option<String>,
master_timeout: Option<String>,
timeout: Option<String>,
context: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
pretty: Option<bool>,
source: Option<String>,
put_script: common::PutScript,
) -> Result<crate::common::AcknowledgedResponseBase, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}_scripts/{id}/{context}",
local_var_configuration.base_path,
id = id,
context = context.clone().unwrap_or_else(|| "painless".to_string())
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(local_var_str) = context {
local_var_req_builder =
local_var_req_builder.query(&[("context", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder =
local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder
.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&put_script);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn rank_eval(
&self,
allow_no_indices: Option<bool>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
ignore_unavailable: Option<bool>,
index: String,
pretty: Option<bool>,
search_type: Option<common::SearchType>,
source: Option<String>,
expand_wildcards: Option<common::ExpandWildcards>,
rank_eval: common::RankEval,
) -> Result<crate::common::RankEvalResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_rank_eval",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&rank_eval);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn explain(
&self,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
analyze_wildcard: Option<bool>,
analyzer: Option<String>,
default_operator: Option<String>,
df: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
index: String,
lenient: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
q: Option<String>,
routing: Option<common::Routing>,
source: Option<String>,
stored_fields: Option<common::StoredFields>,
explain: common::Explain,
) -> Result<crate::common::ExplainResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_explain/{id}",
local_var_configuration.base_path,
index = index,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = default_operator {
local_var_req_builder =
local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = df {
local_var_req_builder =
local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lenient {
local_var_req_builder =
local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stored_fields {
local_var_req_builder =
local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = q {
local_var_req_builder =
local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyzer {
local_var_req_builder =
local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyze_wildcard {
local_var_req_builder =
local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&explain);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn get_script(
&self,
cluster_manager_timeout: Option<String>,
master_timeout: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
pretty: Option<bool>,
source: Option<String>,
) -> Result<crate::common::GetScriptResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}_scripts/{id}",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = cluster_manager_timeout {
local_var_req_builder = local_var_req_builder
.query(&[("cluster_manager_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = master_timeout {
local_var_req_builder =
local_var_req_builder.query(&[("master_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn render_search_template(
&self,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
pretty: Option<bool>,
source: Option<String>,
render_search_template: common::RenderSearchTemplate,
) -> Result<crate::common::RenderSearchTemplateResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}_render/template/{id}",
local_var_configuration.base_path,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&render_search_template);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn reindex(
&self,
scroll: Option<String>,
timeout: Option<String>,
max_docs: Option<i32>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
refresh: Option<common::Refresh>,
requests_per_second: Option<f64>,
require_alias: Option<bool>,
source: Option<String>,
wait_for_completion: Option<bool>,
reindex: common::Reindex,
slices: Option<common::Slices>,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<crate::common::ReindexOKJson, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_reindex", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_completion {
local_var_req_builder =
local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_docs {
local_var_req_builder =
local_var_req_builder.query(&[("max_docs", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = requests_per_second {
local_var_req_builder =
local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll {
local_var_req_builder =
local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = slices {
local_var_req_builder =
local_var_req_builder.query(&[("slices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = require_alias {
local_var_req_builder =
local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&reindex);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn exists_source(
&self,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
index: String,
preference: Option<String>,
pretty: Option<bool>,
realtime: Option<bool>,
refresh: Option<common::Refresh>,
routing: Option<common::Routing>,
source: Option<String>,
version: Option<i32>,
version_type: Option<String>,
) -> Result<ExistsSourceSuccess, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_source/{id}",
local_var_configuration.base_path,
index = index,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::HEAD, local_var_uri_str.as_str());
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = realtime {
local_var_req_builder =
local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version_type {
local_var_req_builder =
local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn delete_by_query(
&self,
scroll: Option<String>,
search_timeout: Option<String>,
timeout: Option<String>,
size: Option<i32>,
source_excludes: Option<Vec<String>>,
source_includes: Option<Vec<String>>,
allow_no_indices: Option<bool>,
analyze_wildcard: Option<bool>,
analyzer: Option<String>,
conflicts: Option<String>,
default_operator: Option<String>,
df: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
from: Option<i32>,
human: Option<bool>,
ignore_unavailable: Option<bool>,
index: String,
lenient: Option<bool>,
max_docs: Option<i32>,
preference: Option<String>,
pretty: Option<bool>,
q: Option<String>,
refresh: Option<common::Refresh>,
request_cache: Option<bool>,
requests_per_second: Option<f64>,
routing: Option<common::Routing>,
scroll_size: Option<i32>,
search_type: Option<common::SearchType>,
sort: Option<Vec<String>>,
source: Option<String>,
stats: Option<Vec<String>>,
terminate_after: Option<i32>,
version: Option<bool>,
wait_for_completion: Option<bool>,
expand_wildcards: Option<common::ExpandWildcards>,
delete_by_query: common::DeleteByQuery,
slices: Option<common::Slices>,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<crate::common::DeleteByQueryOKJson, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_delete_by_query",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = slices {
local_var_req_builder =
local_var_req_builder.query(&[("slices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stats {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("stats".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"stats",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = max_docs {
local_var_req_builder =
local_var_req_builder.query(&[("max_docs", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_completion {
local_var_req_builder =
local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("source_includes".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"source_includes",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = conflicts {
local_var_req_builder =
local_var_req_builder.query(&[("conflicts", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = q {
local_var_req_builder =
local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = request_cache {
local_var_req_builder =
local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll {
local_var_req_builder =
local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyzer {
local_var_req_builder =
local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("sort".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"sort",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = df {
local_var_req_builder =
local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder =
local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll_size {
local_var_req_builder =
local_var_req_builder.query(&[("scroll_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = requests_per_second {
local_var_req_builder =
local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyze_wildcard {
local_var_req_builder =
local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("source_excludes".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"source_excludes",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = default_operator {
local_var_req_builder =
local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = from {
local_var_req_builder =
local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_timeout {
local_var_req_builder =
local_var_req_builder.query(&[("search_timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = terminate_after {
local_var_req_builder =
local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lenient {
local_var_req_builder =
local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&delete_by_query);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn exists(
&self,
index: String,
id: String,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
realtime: Option<bool>,
refresh: Option<common::Refresh>,
routing: Option<common::Routing>,
source: Option<String>,
stored_fields: Option<common::StoredFields>,
version: Option<i32>,
version_type: Option<String>,
) -> Result<ExistsSuccess, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_doc/{id}",
local_var_configuration.base_path,
index = index,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::HEAD, local_var_uri_str.as_str());
if let Some(ref local_var_str) = stored_fields {
local_var_req_builder =
local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = realtime {
local_var_req_builder =
local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version_type {
local_var_req_builder =
local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn field_caps(
&self,
field_caps: common::FieldCaps,
allow_no_indices: Option<bool>,
error_trace: Option<bool>,
fields: Option<common::Fields>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
ignore_unavailable: Option<bool>,
include_unmapped: Option<bool>,
index: String,
pretty: Option<bool>,
source: Option<String>,
expand_wildcards: Option<common::ExpandWildcards>,
) -> Result<crate::common::FieldCapsResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_field_caps",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = include_unmapped {
local_var_req_builder =
local_var_req_builder.query(&[("include_unmapped", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = fields {
local_var_req_builder =
local_var_req_builder.query(&[("fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&field_caps);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn get(
&self,
id: String,
index: String,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
realtime: Option<bool>,
refresh: Option<common::Refresh>,
routing: Option<common::Routing>,
source: Option<String>,
stored_fields: Option<common::StoredFields>,
version: Option<i32>,
version_type: Option<String>,
) -> Result<crate::core::get::GetResult, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_doc/{id}",
local_var_configuration.base_path,
index = index,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = realtime {
local_var_req_builder =
local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stored_fields {
local_var_req_builder =
local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version_type {
local_var_req_builder =
local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
if local_var_status == reqwest::StatusCode::NOT_FOUND {
return Err(Error::DocumentNotFoundError(index, id));
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
}
#[builder(on(String, into))]
pub async fn delete(
&self,
index: String,
id: String,
timeout: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
if_primary_term: Option<i32>,
if_seq_no: Option<i32>,
pretty: Option<bool>,
refresh: Option<common::Refresh>,
routing: Option<common::Routing>,
source: Option<String>,
version: Option<i32>,
version_type: Option<String>,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<DocumentDeleteResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_doc/{id}",
local_var_configuration.base_path,
id = id,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = if_seq_no {
local_var_req_builder =
local_var_req_builder.query(&[("if_seq_no", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = if_primary_term {
local_var_req_builder =
local_var_req_builder.query(&[("if_primary_term", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version_type {
local_var_req_builder =
local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn mtermvectors(
&self,
mtermvectors: common::Mtermvectors,
error_trace: Option<bool>,
field_statistics: Option<bool>,
fields: Option<common::Fields>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
ids: Option<Vec<String>>,
index: String,
offsets: Option<bool>,
payloads: Option<bool>,
positions: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
realtime: Option<bool>,
routing: Option<common::Routing>,
source: Option<String>,
term_statistics: Option<bool>,
version: Option<i32>,
version_type: Option<String>,
) -> Result<crate::common::MtermvectorsResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_mtermvectors",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ids {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("ids".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"ids",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = realtime {
local_var_req_builder =
local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = positions {
local_var_req_builder =
local_var_req_builder.query(&[("positions", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = payloads {
local_var_req_builder =
local_var_req_builder.query(&[("payloads", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = term_statistics {
local_var_req_builder =
local_var_req_builder.query(&[("term_statistics", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = fields {
local_var_req_builder =
local_var_req_builder.query(&[("fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = field_statistics {
local_var_req_builder =
local_var_req_builder.query(&[("field_statistics", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version_type {
local_var_req_builder =
local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = offsets {
local_var_req_builder =
local_var_req_builder.query(&[("offsets", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&mtermvectors);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn search_with_index(
&self,
cancel_after_time_interval: Option<String>,
scroll: Option<String>,
timeout: Option<String>,
search_pipeline: Option<String>,
include_named_queries_score: Option<bool>,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
allow_no_indices: Option<bool>,
allow_partial_search_results: Option<bool>,
analyze_wildcard: Option<bool>,
analyzer: Option<String>,
batched_reduce_size: Option<i32>,
ccs_minimize_roundtrips: Option<bool>,
default_operator: Option<String>,
df: Option<String>,
docvalue_fields: Option<common::DocvalueFields>,
error_trace: Option<bool>,
explain: Option<bool>,
filter_path: Option<common::FilterPath>,
from: Option<i32>,
human: Option<bool>,
ignore_throttled: Option<bool>,
ignore_unavailable: Option<bool>,
index: String,
lenient: Option<bool>,
max_concurrent_shard_requests: Option<i32>,
phase_took: Option<bool>,
pre_filter_shard_size: Option<i32>,
preference: Option<String>,
pretty: Option<bool>,
q: Option<String>,
request_cache: Option<bool>,
rest_total_hits_as_int: Option<bool>,
routing: Option<common::Routing>,
search_type: Option<common::SearchType>,
seq_no_primary_term: Option<bool>,
size: Option<i32>,
sort: Option<common::Sort>,
source: Option<String>,
stats: Option<Vec<String>>,
stored_fields: Option<common::StoredFields>,
suggest_mode: Option<String>,
suggest_size: Option<i32>,
suggest_text: Option<String>,
terminate_after: Option<i32>,
track_scores: Option<bool>,
typed_keys: Option<bool>,
version: Option<bool>,
expand_wildcards: Option<common::ExpandWildcards>,
track_total_hits: Option<common::TrackTotalHits>,
suggest_field: Option<String>,
search_with_index: common::SearchWithIndex,
) -> Result<SearchWithIndexSuccess, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_search",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = typed_keys {
local_var_req_builder =
local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = rest_total_hits_as_int {
local_var_req_builder = local_var_req_builder
.query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_concurrent_shard_requests {
local_var_req_builder = local_var_req_builder
.query(&[("max_concurrent_shard_requests", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cancel_after_time_interval {
local_var_req_builder = local_var_req_builder
.query(&[("cancel_after_time_interval", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = docvalue_fields {
local_var_req_builder =
local_var_req_builder.query(&[("docvalue_fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = include_named_queries_score {
local_var_req_builder = local_var_req_builder
.query(&[("include_named_queries_score", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = explain {
local_var_req_builder =
local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lenient {
local_var_req_builder =
local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ccs_minimize_roundtrips {
local_var_req_builder = local_var_req_builder
.query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder =
local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_partial_search_results {
local_var_req_builder = local_var_req_builder
.query(&[("allow_partial_search_results", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_mode {
local_var_req_builder =
local_var_req_builder.query(&[("suggest_mode", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = track_scores {
local_var_req_builder =
local_var_req_builder.query(&[("track_scores", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = batched_reduce_size {
local_var_req_builder =
local_var_req_builder.query(&[("batched_reduce_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = request_cache {
local_var_req_builder =
local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyzer {
local_var_req_builder =
local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_throttled {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_pipeline {
local_var_req_builder =
local_var_req_builder.query(&[("search_pipeline", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_text {
local_var_req_builder =
local_var_req_builder.query(&[("suggest_text", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = from {
local_var_req_builder =
local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stored_fields {
local_var_req_builder =
local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll {
local_var_req_builder =
local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyze_wildcard {
local_var_req_builder =
local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pre_filter_shard_size {
local_var_req_builder = local_var_req_builder
.query(&[("pre_filter_shard_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = df {
local_var_req_builder =
local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_size {
local_var_req_builder =
local_var_req_builder.query(&[("suggest_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = track_total_hits {
local_var_req_builder =
local_var_req_builder.query(&[("track_total_hits", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = phase_took {
local_var_req_builder =
local_var_req_builder.query(&[("phase_took", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stats {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("stats".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"stats",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = terminate_after {
local_var_req_builder =
local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_field {
local_var_req_builder =
local_var_req_builder.query(&[("suggest_field", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = q {
local_var_req_builder =
local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder =
local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = default_operator {
local_var_req_builder =
local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = seq_no_primary_term {
local_var_req_builder =
local_var_req_builder.query(&[("seq_no_primary_term", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&search_with_index);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn mget(
&self,
index: String,
mget: common::Mget,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
realtime: Option<bool>,
refresh: Option<common::Refresh>,
routing: Option<common::Routing>,
source: Option<String>,
stored_fields: Option<common::StoredFields>,
) -> Result<crate::common::MgetResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_mget",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = realtime {
local_var_req_builder =
local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stored_fields {
local_var_req_builder =
local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&mget);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn get_script_languages(
&self,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
source: Option<String>,
) -> Result<crate::common::GetScriptLanguagesResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_script_language", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn clear_scroll(
&self,
clear_scroll: Option<common::ClearScroll>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
scroll_id: Option<String>,
source: Option<String>,
) -> Result<ClearScrollSuccess, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = if let Some(scroll_id) = &scroll_id {
format!(
"{}_search/scroll/{scroll_id}",
local_var_configuration.base_path,
scroll_id = scroll_id
)
} else {
format!("{}_search/scroll", local_var_configuration.base_path)
};
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&clear_scroll);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn search_template(
&self,
scroll: Option<String>,
allow_no_indices: Option<bool>,
ccs_minimize_roundtrips: Option<bool>,
error_trace: Option<bool>,
explain: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
ignore_throttled: Option<bool>,
ignore_unavailable: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
profile: Option<bool>,
rest_total_hits_as_int: Option<bool>,
routing: Option<common::Routing>,
search_type: Option<common::SearchType>,
source: Option<String>,
typed_keys: Option<bool>,
expand_wildcards: Option<common::ExpandWildcards>,
search_template: common::SearchTemplate,
) -> Result<crate::common::SearchTemplateResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_search/template", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_throttled {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ccs_minimize_roundtrips {
local_var_req_builder = local_var_req_builder
.query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll {
local_var_req_builder =
local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = rest_total_hits_as_int {
local_var_req_builder = local_var_req_builder
.query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = profile {
local_var_req_builder =
local_var_req_builder.query(&[("profile", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = typed_keys {
local_var_req_builder =
local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = explain {
local_var_req_builder =
local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&search_template);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn count(
&self,
index: String,
count: Option<common::Count>,
query: Option<crate::dsl::Query>,
allow_no_indices: Option<bool>,
analyze_wildcard: Option<bool>,
analyzer: Option<String>,
default_operator: Option<String>,
df: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
ignore_throttled: Option<bool>,
ignore_unavailable: Option<bool>,
lenient: Option<bool>,
min_score: Option<f64>,
preference: Option<String>,
pretty: Option<bool>,
q: Option<String>,
routing: Option<common::Routing>,
source: Option<String>,
terminate_after: Option<i32>,
expand_wildcards: Option<common::ExpandWildcards>,
) -> Result<crate::common::CountResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_count",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = default_operator {
local_var_req_builder =
local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = terminate_after {
local_var_req_builder =
local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyze_wildcard {
local_var_req_builder =
local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = min_score {
local_var_req_builder =
local_var_req_builder.query(&[("min_score", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_throttled {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lenient {
local_var_req_builder =
local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyzer {
local_var_req_builder =
local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = df {
local_var_req_builder =
local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = q {
local_var_req_builder =
local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
}
let mut count = count;
if let Some(ref query) = query {
count = Some(common::Count {
query: Some(query.clone()),
});
}
if let Some(ref body) = count {
local_var_req_builder = local_var_req_builder.json(&body);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn search_shards_with_index(
&self,
allow_no_indices: Option<bool>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
ignore_unavailable: Option<bool>,
index: String,
local: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
routing: Option<common::Routing>,
source: Option<String>,
expand_wildcards: Option<common::ExpandWildcards>,
) -> Result<crate::common::SearchShardsWithIndexResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_search_shards",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = local {
local_var_req_builder =
local_var_req_builder.query(&[("local", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn reindex_rethrottle(
&self,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
requests_per_second: Option<f64>,
source: Option<String>,
task_id: String,
) -> Result<crate::common::ReindexRethrottleResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}_reindex/{task_id}/_rethrottle",
local_var_configuration.base_path,
task_id = task_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = requests_per_second {
local_var_req_builder =
local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn create(
&self,
timeout: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
index: String,
pipeline: Option<String>,
pretty: Option<bool>,
refresh: Option<common::Refresh>,
routing: Option<common::Routing>,
source: Option<String>,
version: Option<i32>,
version_type: Option<String>,
body: serde_json::Value,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<crate::bulk::IndexResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_create/{id}",
local_var_configuration.base_path,
id = id,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pipeline {
local_var_req_builder =
local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version_type {
local_var_req_builder =
local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&body);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
if local_var_status.as_u16() == 409 {
Err(Error::DocumentAlreadyExistsError(
index.to_string(),
id.to_string(),
))
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
}
#[builder(on(String, into))]
pub async fn search(
&self,
cancel_after_time_interval: Option<String>,
scroll: Option<String>,
timeout: Option<String>,
search_pipeline: Option<String>,
include_named_queries_score: Option<bool>,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
allow_no_indices: Option<bool>,
allow_partial_search_results: Option<bool>,
analyze_wildcard: Option<bool>,
analyzer: Option<String>,
batched_reduce_size: Option<i32>,
ccs_minimize_roundtrips: Option<bool>,
default_operator: Option<String>,
df: Option<String>,
docvalue_fields: Option<common::DocvalueFields>,
error_trace: Option<bool>,
explain: Option<bool>,
filter_path: Option<common::FilterPath>,
from: Option<i32>,
human: Option<bool>,
ignore_throttled: Option<bool>,
ignore_unavailable: Option<bool>,
lenient: Option<bool>,
max_concurrent_shard_requests: Option<i32>,
phase_took: Option<bool>,
pre_filter_shard_size: Option<i32>,
preference: Option<String>,
pretty: Option<bool>,
q: Option<String>,
request_cache: Option<bool>,
rest_total_hits_as_int: Option<bool>,
routing: Option<common::Routing>,
search_type: Option<common::SearchType>,
seq_no_primary_term: Option<bool>,
size: Option<i32>,
sort: Option<common::Sort>,
source: Option<String>,
stats: Option<Vec<String>>,
stored_fields: Option<common::StoredFields>,
suggest_mode: Option<String>,
suggest_size: Option<i32>,
suggest_text: Option<String>,
terminate_after: Option<i32>,
track_scores: Option<bool>,
typed_keys: Option<bool>,
version: Option<bool>,
expand_wildcards: Option<common::ExpandWildcards>,
track_total_hits: Option<common::TrackTotalHits>,
suggest_field: Option<String>,
index: Option<String>,
search: Option<common::Search>,
) -> Result<SearchSuccess, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = if let Some(index) = &index {
format!("{}{}/_search", local_var_configuration.base_path, index)
} else {
format!("{}_search", local_var_configuration.base_path)
};
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = analyzer {
local_var_req_builder =
local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = include_named_queries_score {
local_var_req_builder = local_var_req_builder
.query(&[("include_named_queries_score", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = batched_reduce_size {
local_var_req_builder =
local_var_req_builder.query(&[("batched_reduce_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ccs_minimize_roundtrips {
local_var_req_builder = local_var_req_builder
.query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyze_wildcard {
local_var_req_builder =
local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = phase_took {
local_var_req_builder =
local_var_req_builder.query(&[("phase_took", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = rest_total_hits_as_int {
local_var_req_builder = local_var_req_builder
.query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = seq_no_primary_term {
local_var_req_builder =
local_var_req_builder.query(&[("seq_no_primary_term", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_text {
local_var_req_builder =
local_var_req_builder.query(&[("suggest_text", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = track_scores {
local_var_req_builder =
local_var_req_builder.query(&[("track_scores", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = track_total_hits {
local_var_req_builder =
local_var_req_builder.query(&[("track_total_hits", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_concurrent_shard_requests {
local_var_req_builder = local_var_req_builder
.query(&[("max_concurrent_shard_requests", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = typed_keys {
local_var_req_builder =
local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = docvalue_fields {
local_var_req_builder =
local_var_req_builder.query(&[("docvalue_fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = df {
local_var_req_builder =
local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = q {
local_var_req_builder =
local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_partial_search_results {
local_var_req_builder = local_var_req_builder
.query(&[("allow_partial_search_results", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder =
local_var_req_builder.query(&[("sort", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_mode {
local_var_req_builder =
local_var_req_builder.query(&[("suggest_mode", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_size {
local_var_req_builder =
local_var_req_builder.query(&[("suggest_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = default_operator {
local_var_req_builder =
local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = from {
local_var_req_builder =
local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pre_filter_shard_size {
local_var_req_builder = local_var_req_builder
.query(&[("pre_filter_shard_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stats {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("stats".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"stats",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = terminate_after {
local_var_req_builder =
local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = cancel_after_time_interval {
local_var_req_builder = local_var_req_builder
.query(&[("cancel_after_time_interval", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lenient {
local_var_req_builder =
local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = explain {
local_var_req_builder =
local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_pipeline {
local_var_req_builder =
local_var_req_builder.query(&[("search_pipeline", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder =
local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stored_fields {
local_var_req_builder =
local_var_req_builder.query(&[("stored_fields", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_throttled {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = suggest_field {
local_var_req_builder =
local_var_req_builder.query(&[("suggest_field", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll {
local_var_req_builder =
local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = request_cache {
local_var_req_builder =
local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref body) = search {
local_var_req_builder = local_var_req_builder.json(&body);
}
tracing::debug!(
"Request: \npath:{}\n {}\n",
local_var_uri_str,
serde_json::to_string(&search).unwrap_or_default()
);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn get_source(
&self,
index: String,
id: String,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
preference: Option<String>,
pretty: Option<bool>,
realtime: Option<bool>,
refresh: Option<common::Refresh>,
routing: Option<common::Routing>,
source: Option<String>,
version: Option<i32>,
version_type: Option<String>,
) -> Result<GetSourceSuccess, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_source/{id}",
local_var_configuration.base_path,
index = index,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version_type {
local_var_req_builder =
local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = realtime {
local_var_req_builder =
local_var_req_builder.query(&[("realtime", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn bulk(
&self,
body: String,
timeout: Option<String>,
r#type: Option<String>,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pipeline: Option<String>,
pretty: Option<bool>,
refresh: Option<common::Refresh>,
require_alias: Option<bool>,
routing: Option<common::Routing>,
source: Option<String>,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<crate::bulk::BulkResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_bulk", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = require_alias {
local_var_req_builder =
local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pipeline {
local_var_req_builder =
local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = r#type {
local_var_req_builder =
local_var_req_builder.query(&[("type", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder
.body(reqwest::Body::from(body))
.header("Content-Type", "application/x-ndjson");
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn scroll(
&self,
scroll: common::Scroll,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
rest_total_hits_as_int: Option<bool>,
scroll_id: Option<String>,
source: Option<String>,
) -> Result<crate::core::search::ResponseBody, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}_search/scroll/{scroll_id}",
local_var_configuration.base_path,
scroll_id = scroll_id.clone().unwrap_or_default()
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll_id {
local_var_req_builder =
local_var_req_builder.query(&[("scroll_id", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.query(&[("scroll", &scroll.to_string())]);
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = rest_total_hits_as_int {
local_var_req_builder = local_var_req_builder
.query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&scroll);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn msearch(
&self,
ccs_minimize_roundtrips: Option<bool>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
index: String,
max_concurrent_searches: Option<i32>,
max_concurrent_shard_requests: Option<i32>,
pre_filter_shard_size: Option<i32>,
pretty: Option<bool>,
rest_total_hits_as_int: Option<bool>,
search_type: Option<common::SearchType>,
source: Option<String>,
typed_keys: Option<bool>,
) -> Result<crate::core::msearch::MultiSearchResult, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_msearch",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_concurrent_searches {
local_var_req_builder = local_var_req_builder
.query(&[("max_concurrent_searches", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = rest_total_hits_as_int {
local_var_req_builder = local_var_req_builder
.query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_concurrent_shard_requests {
local_var_req_builder = local_var_req_builder
.query(&[("max_concurrent_shard_requests", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ccs_minimize_roundtrips {
local_var_req_builder = local_var_req_builder
.query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pre_filter_shard_size {
local_var_req_builder = local_var_req_builder
.query(&[("pre_filter_shard_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = typed_keys {
local_var_req_builder =
local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn scripts_painless_execute(
&self,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
source: Option<String>,
scripts_painless_execute: common::ScriptsPainlessExecute,
) -> Result<crate::common::ScriptsPainlessExecuteResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}_scripts/painless/_execute",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&scripts_painless_execute);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn update_by_query(
&self,
index: String,
body: common::UpdateByQuery,
scroll: Option<String>,
search_timeout: Option<String>,
timeout: Option<String>,
size: Option<i32>,
source_excludes: Option<Vec<String>>,
source_includes: Option<Vec<String>>,
allow_no_indices: Option<bool>,
analyze_wildcard: Option<bool>,
analyzer: Option<String>,
conflicts: Option<String>,
default_operator: Option<String>,
df: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
from: Option<i32>,
human: Option<bool>,
ignore_unavailable: Option<bool>,
lenient: Option<bool>,
max_docs: Option<i32>,
pipeline: Option<String>,
preference: Option<String>,
pretty: Option<bool>,
refresh: Option<common::Refresh>,
request_cache: Option<bool>,
requests_per_second: Option<f64>,
routing: Option<common::Routing>,
scroll_size: Option<i32>,
search_type: Option<common::SearchType>,
sort: Option<Vec<String>>,
source: Option<String>,
stats: Option<Vec<String>>,
terminate_after: Option<i32>,
version: Option<bool>,
wait_for_completion: Option<bool>,
q: Option<String>,
expand_wildcards: Option<common::ExpandWildcards>,
slices: Option<common::Slices>,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<crate::common::UpdateByQueryOKJson, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_update_by_query",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = conflicts {
local_var_req_builder =
local_var_req_builder.query(&[("conflicts", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("source_includes".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"source_includes",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = scroll {
local_var_req_builder =
local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll_size {
local_var_req_builder =
local_var_req_builder.query(&[("scroll_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyze_wildcard {
local_var_req_builder =
local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = requests_per_second {
local_var_req_builder =
local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pipeline {
local_var_req_builder =
local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stats {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("stats".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"stats",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = q {
local_var_req_builder =
local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lenient {
local_var_req_builder =
local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyzer {
local_var_req_builder =
local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = terminate_after {
local_var_req_builder =
local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("source_excludes".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"source_excludes",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = slices {
local_var_req_builder =
local_var_req_builder.query(&[("slices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = from {
local_var_req_builder =
local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = request_cache {
local_var_req_builder =
local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_completion {
local_var_req_builder =
local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_docs {
local_var_req_builder =
local_var_req_builder.query(&[("max_docs", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder =
local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("sort".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"sort",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = default_operator {
local_var_req_builder =
local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = df {
local_var_req_builder =
local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_timeout {
local_var_req_builder =
local_var_req_builder.query(&[("search_timeout", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&body);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn update_by_query_raw(
&self,
index: String,
body: serde_json::Value,
scroll: Option<String>,
search_timeout: Option<String>,
timeout: Option<String>,
size: Option<i32>,
source_excludes: Option<Vec<String>>,
source_includes: Option<Vec<String>>,
allow_no_indices: Option<bool>,
analyze_wildcard: Option<bool>,
analyzer: Option<String>,
conflicts: Option<String>,
default_operator: Option<String>,
df: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
from: Option<i32>,
human: Option<bool>,
ignore_unavailable: Option<bool>,
lenient: Option<bool>,
max_docs: Option<i32>,
pipeline: Option<String>,
preference: Option<String>,
pretty: Option<bool>,
refresh: Option<common::Refresh>,
request_cache: Option<bool>,
requests_per_second: Option<f64>,
routing: Option<common::Routing>,
scroll_size: Option<i32>,
search_type: Option<common::SearchType>,
sort: Option<Vec<String>>,
source: Option<String>,
stats: Option<Vec<String>>,
terminate_after: Option<i32>,
version: Option<bool>,
wait_for_completion: Option<bool>,
q: Option<String>,
expand_wildcards: Option<common::ExpandWildcards>,
slices: Option<common::Slices>,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<crate::common::UpdateByQueryOKJson, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_update_by_query",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = conflicts {
local_var_req_builder =
local_var_req_builder.query(&[("conflicts", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("source_includes".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"source_includes",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = scroll {
local_var_req_builder =
local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll_size {
local_var_req_builder =
local_var_req_builder.query(&[("scroll_size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyze_wildcard {
local_var_req_builder =
local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = requests_per_second {
local_var_req_builder =
local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pipeline {
local_var_req_builder =
local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = stats {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("stats".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"stats",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = q {
local_var_req_builder =
local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lenient {
local_var_req_builder =
local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = analyzer {
local_var_req_builder =
local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = terminate_after {
local_var_req_builder =
local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("source_excludes".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"source_excludes",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = slices {
local_var_req_builder =
local_var_req_builder.query(&[("slices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = from {
local_var_req_builder =
local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = request_cache {
local_var_req_builder =
local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_completion {
local_var_req_builder =
local_var_req_builder.query(&[("wait_for_completion", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_docs {
local_var_req_builder =
local_var_req_builder.query(&[("max_docs", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = size {
local_var_req_builder =
local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = sort {
local_var_req_builder = match "multi" {
"multi" => local_var_req_builder.query(
&local_var_str
.into_iter()
.map(|p| ("sort".to_owned(), p.to_string()))
.collect::<Vec<(std::string::String, std::string::String)>>(),
),
_ => local_var_req_builder.query(&[(
"sort",
&local_var_str
.into_iter()
.map(|p| p.to_string())
.collect::<Vec<String>>()
.join(",")
.to_string(),
)]),
};
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = default_operator {
local_var_req_builder =
local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = df {
local_var_req_builder =
local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_timeout {
local_var_req_builder =
local_var_req_builder.query(&[("search_timeout", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&body);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn update_by_query_rethrottle(
&self,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
requests_per_second: Option<f64>,
source: Option<String>,
task_id: String,
) -> Result<crate::common::UpdateByQueryRethrottleResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}_update_by_query/{task_id}/_rethrottle",
local_var_configuration.base_path,
task_id = task_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = requests_per_second {
local_var_req_builder =
local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn get_script_context(
&self,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
source: Option<String>,
) -> Result<crate::common::GetScriptContextResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}_script_context", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn delete_by_query_rethrottle(
&self,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
requests_per_second: Option<f64>,
source: Option<String>,
task_id: String,
) -> Result<crate::tasks::TaskListResponseBase, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}_delete_by_query/{task_id}/_rethrottle",
local_var_configuration.base_path,
task_id = task_id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = requests_per_second {
local_var_req_builder =
local_var_req_builder.query(&[("requests_per_second", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn search_template_with_index(
&self,
scroll: Option<String>,
allow_no_indices: Option<bool>,
ccs_minimize_roundtrips: Option<bool>,
error_trace: Option<bool>,
explain: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
ignore_throttled: Option<bool>,
ignore_unavailable: Option<bool>,
index: String,
preference: Option<String>,
pretty: Option<bool>,
profile: Option<bool>,
rest_total_hits_as_int: Option<bool>,
routing: Option<common::Routing>,
search_type: Option<common::SearchType>,
source: Option<String>,
typed_keys: Option<bool>,
expand_wildcards: Option<common::ExpandWildcards>,
search_template_with_index: common::SearchTemplateWithIndex,
) -> Result<crate::common::SearchTemplateWithIndexResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_search/template",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = ccs_minimize_roundtrips {
local_var_req_builder = local_var_req_builder
.query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_unavailable {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = profile {
local_var_req_builder =
local_var_req_builder.query(&[("profile", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ignore_throttled {
local_var_req_builder =
local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = typed_keys {
local_var_req_builder =
local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = rest_total_hits_as_int {
local_var_req_builder = local_var_req_builder
.query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = expand_wildcards {
local_var_req_builder =
local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = preference {
local_var_req_builder =
local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = scroll {
local_var_req_builder =
local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = allow_no_indices {
local_var_req_builder =
local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = explain {
local_var_req_builder =
local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&search_template_with_index);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn msearch_template(
&self,
ccs_minimize_roundtrips: Option<bool>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
index: String,
max_concurrent_searches: Option<i32>,
pretty: Option<bool>,
rest_total_hits_as_int: Option<bool>,
search_type: Option<common::SearchType>,
source: Option<String>,
typed_keys: Option<bool>,
) -> Result<crate::core::msearch::MultiSearchResult, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_msearch/template",
local_var_configuration.base_path,
index = index
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = typed_keys {
local_var_req_builder =
local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = max_concurrent_searches {
local_var_req_builder = local_var_req_builder
.query(&[("max_concurrent_searches", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = rest_total_hits_as_int {
local_var_req_builder = local_var_req_builder
.query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = ccs_minimize_roundtrips {
local_var_req_builder = local_var_req_builder
.query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = search_type {
local_var_req_builder =
local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn ping(
&self,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
pretty: Option<bool>,
source: Option<String>,
) -> Result<serde_json::Value, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!("{}", local_var_configuration.base_path);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::HEAD, local_var_uri_str.as_str());
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn index(
&self,
index: String,
body: serde_json::Value,
id: Option<String>,
timeout: Option<String>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
if_primary_term: Option<i32>,
if_seq_no: Option<i32>,
op_type: Option<String>,
pipeline: Option<String>,
pretty: Option<bool>,
refresh: Option<common::Refresh>,
require_alias: Option<bool>,
routing: Option<common::Routing>,
source: Option<String>,
version: Option<i32>,
version_type: Option<String>,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<crate::bulk::IndexResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = if let Some(id) = id {
format!(
"{}{index}/_doc/{id}",
local_var_configuration.base_path,
index = index,
id = id
)
} else {
format!(
"{}{index}/_doc",
local_var_configuration.base_path,
index = index
)
};
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
local_var_req_builder = local_var_req_builder.json(&body);
if let Some(ref local_var_str) = if_seq_no {
local_var_req_builder =
local_var_req_builder.query(&[("if_seq_no", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pipeline {
local_var_req_builder =
local_var_req_builder.query(&[("pipeline", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = if_primary_term {
local_var_req_builder =
local_var_req_builder.query(&[("if_primary_term", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version {
local_var_req_builder =
local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = require_alias {
local_var_req_builder =
local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = version_type {
local_var_req_builder =
local_var_req_builder.query(&[("version_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = op_type {
local_var_req_builder =
local_var_req_builder.query(&[("op_type", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn update(
&self,
timeout: Option<String>,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
if_primary_term: Option<i32>,
if_seq_no: Option<i32>,
index: String,
lang: Option<String>,
pretty: Option<bool>,
refresh: Option<common::Refresh>,
require_alias: Option<bool>,
retry_on_conflict: Option<i32>,
routing: Option<common::Routing>,
source: Option<String>,
update: common::Update,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<crate::bulk::IndexResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_update/{id}",
local_var_configuration.base_path,
index = index,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = if_seq_no {
local_var_req_builder =
local_var_req_builder.query(&[("if_seq_no", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = if_primary_term {
local_var_req_builder =
local_var_req_builder.query(&[("if_primary_term", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = retry_on_conflict {
local_var_req_builder =
local_var_req_builder.query(&[("retry_on_conflict", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = require_alias {
local_var_req_builder =
local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lang {
local_var_req_builder =
local_var_req_builder.query(&[("lang", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&update);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
#[builder(on(String, into))]
pub async fn update_raw(
&self,
timeout: Option<String>,
source_excludes: Option<common::SourceExcludes>,
source_includes: Option<common::SourceIncludes>,
error_trace: Option<bool>,
filter_path: Option<common::FilterPath>,
human: Option<bool>,
id: String,
if_primary_term: Option<i32>,
if_seq_no: Option<i32>,
index: String,
lang: Option<String>,
pretty: Option<bool>,
refresh: Option<common::Refresh>,
require_alias: Option<bool>,
retry_on_conflict: Option<i32>,
routing: Option<common::Routing>,
source: Option<String>,
update: serde_json::Value,
wait_for_active_shards: Option<common::wait_for_active_shards::WaitForActiveShards>,
) -> Result<crate::bulk::IndexResponse, Error> {
let local_var_configuration = &self.configuration;
let local_var_client = &local_var_configuration.client;
let local_var_uri_str = format!(
"{}{index}/_update/{id}",
local_var_configuration.base_path,
index = index,
id = id
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
if let Some(ref local_var_str) = if_seq_no {
local_var_req_builder =
local_var_req_builder.query(&[("if_seq_no", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = refresh {
local_var_req_builder =
local_var_req_builder.query(&[("refresh", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = wait_for_active_shards {
local_var_req_builder = local_var_req_builder
.query(&[("wait_for_active_shards", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = routing {
local_var_req_builder =
local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = if_primary_term {
local_var_req_builder =
local_var_req_builder.query(&[("if_primary_term", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = retry_on_conflict {
local_var_req_builder =
local_var_req_builder.query(&[("retry_on_conflict", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = human {
local_var_req_builder =
local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = error_trace {
local_var_req_builder =
local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = timeout {
local_var_req_builder =
local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_includes {
local_var_req_builder =
local_var_req_builder.query(&[("source_includes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source_excludes {
local_var_req_builder =
local_var_req_builder.query(&[("source_excludes", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = require_alias {
local_var_req_builder =
local_var_req_builder.query(&[("require_alias", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = pretty {
local_var_req_builder =
local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = lang {
local_var_req_builder =
local_var_req_builder.query(&[("lang", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = filter_path {
local_var_req_builder =
local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
}
if let Some(ref local_var_str) = source {
local_var_req_builder =
local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
}
local_var_req_builder = local_var_req_builder.json(&update);
let local_var_req = local_var_req_builder.build()?;
let local_var_resp = local_var_client.execute(local_var_req).await?;
let local_var_status = local_var_resp.status();
let local_var_content = local_var_resp.text().await?;
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
};
Err(Error::ApiError(local_var_error))
}
}
pub fn api_version(&self) -> &'static str {
"2025-07-22"
}
pub async fn bulk_index_document<T: Serialize>(
&self,
index: &str,
id: Option<String>,
body: &T,
) -> Result<(), Error> {
let body_json = serde_json::to_value(body)?;
let action = BulkAction::Index(IndexAction {
index: index.to_owned(),
id: id.clone(),
pipeline: None,
});
self.bulk_action(action, Some(&body_json)).await
}
pub async fn bulk_action(
&self,
action: BulkAction,
body: Option<&serde_json::Value>,
) -> Result<(), Error> {
let j = serde_json::to_string(&action)?;
let bulker_arc = Arc::clone(&self.configuration.bulker);
let mut bulker = bulker_arc.lock().unwrap();
bulker.push_str(j.as_str());
bulker.push('\n');
match body {
None => {}
Some(js) => {
let j = serde_json::to_string(js)?;
bulker.push_str(j.as_str());
bulker.push('\n');
}
}
let bulker_size_arc = Arc::clone(&self.configuration.bulker_size);
let mut bulker_size = bulker_size_arc.lock().unwrap();
*bulker_size += 1;
if *bulker_size >= self.configuration.max_bulk_size {
drop(bulker_size);
drop(bulker);
self.flush_bulk().await?;
}
Ok(())
}
pub async fn bulk_create_document<T: Serialize>(
&self,
index: &str,
id: &str,
body: &T,
) -> Result<(), Error> {
let body_json = serde_json::to_value(body)?;
let action = BulkAction::Create(CreateAction {
index: index.to_owned(),
id: id.to_owned(),
..Default::default()
});
self.bulk_action(action, Some(&body_json)).await
}
pub async fn bulk_update_document(
&self,
index: &str,
id: &str,
body: &UpdateActionBody,
) -> Result<(), Error> {
let action = BulkAction::Update(UpdateAction {
index: index.to_owned(),
id: id.to_owned(),
..Default::default()
});
let j = serde_json::to_value(body)?;
self.bulk_action(action, Some(&j)).await
}
pub async fn flush_bulk(&self) -> Result<BulkResponse, Error> {
let bulker_size_arc = Arc::clone(&self.configuration.bulker_size);
let mut bulker_size = bulker_size_arc.lock().unwrap();
if *bulker_size > 0 {
let bulker_arc = Arc::clone(&self.configuration.bulker);
let mut bulker = bulker_arc.lock().unwrap();
match self.bulk().body(bulker.to_owned()).call().await
{
Ok(result) => {
*bulker = String::new();
*bulker_size = 0;
if result.errors {
for map in &result.items {
for (_, value) in map.iter() {
if let Some(error) = &value.error {
if !error.kind.eq_ignore_ascii_case("version_conflict_engine_exception") {
tracing::trace!("{:?}", &value);
}
}
}
}
}
Ok(result)
}
Err(err) => {
println!("{:?}", &err);
Err(err)
}
}
} else {
Ok(BulkResponse {
took: 0,
errors: false,
items: vec![],
ingest_took: None,
})
}
}
pub async fn index_document<T: Serialize>(
&self,
index: &str,
body: &T,
id: Option<String>,
) -> Result<crate::bulk::IndexResponse, Error> {
let body_json = serde_json::to_value(body)?;
let partial_request = self.index().index(index).body(body_json).maybe_id(id);
let response = partial_request.call().await?;
Ok(response)
}
pub async fn create_document<T: Serialize>(
&self,
index: &str,
id: &str,
body: &T,
) -> Result<crate::bulk::IndexResponse, Error> {
let body_json = serde_json::to_value(body)?;
let response = self
.create()
.index(index)
.id(id)
.body(body_json)
.call()
.await?;
Ok(response)
}
pub async fn get_typed<T: DeserializeOwned>(
&self,
index: &str,
id: &str,
) -> Result<crate::core::get::GetTypedResult<T>, Error> {
let response = self.get().index(index).id(id).call().await?;
let result = response.parse::<T>()?;
Ok(result)
}
pub async fn update_document(
&self,
index: &str,
id: &str,
action: &UpdateActionBody,
) -> Result<crate::bulk::IndexResponse, Error> {
let body = serde_json::to_value(&action)?;
let response = self
.update_raw()
.update(body)
.index(index)
.id(id)
.call()
.await?;
Ok(response)
}
pub fn get_bulker(
&self,
bulk_size: u32,
max_concurrent_connections: u32,
) -> (JoinHandle<()>, Bulker) {
Bulker::new(
Arc::new(self.clone()),
bulk_size,
max_concurrent_connections,
)
}
pub fn bulker(&self) -> BulkerBuilder {
BulkerBuilder::new(Arc::new(self.clone()), self.configuration.max_bulk_size)
}
pub async fn search_typed<T: DeserializeOwned >(
&self,
index: &str,
search: Search,
) -> Result<crate::search::TypedSearchResult<T>, Error> {
let response = self.search().index(index).search(search).call().await?;
crate::search::TypedSearchResult::from_response(response)
}
pub async fn search_stream<T: DeserializeOwned + std::default::Default>(
&self,
index: &str,
query: &Query,
sort: &SortCollection,
size: u64,
) -> Result<impl Stream<Item = crate::search::TypedHit<T>> + 'static, Error> {
let start_state = crate::search::SearchAfterState {
client: Arc::new(self.clone()),
stop: false,
search_after: None,
index: index.to_owned(),
query: query.clone(),
sort: sort.clone(),
size,
};
async fn stream_next<T: DeserializeOwned + std::default::Default>(
state: crate::search::SearchAfterState,
) -> Result<
(
Vec<crate::search::TypedHit<T>>,
crate::search::SearchAfterState,
),
Error,
> {
let mut body: Search = Search::new()
.size(state.size)
.query(state.query.clone())
.sort(state.sort.clone());
if let Some(search_after) = state.search_after.clone() {
body = body.search_after(search_after.clone());
}
let response = state
.client
.clone()
.search()
.index(&state.index)
.search(body)
.call()
.await?;
let hits = response
.hits
.hits
.into_iter()
.map(|hit| {
let typed_hit: crate::search::TypedHit<T> =
crate::search::TypedHit::from_hit(hit);
typed_hit
})
.collect::<Vec<_>>();
let next_state = crate::search::SearchAfterState {
stop: (hits.len() as u64) < state.size,
search_after: hits.iter().last().and_then(|f| {
let last_sort = f.sort.clone();
if last_sort.is_empty() {
None
} else {
Some(opensearch_dsl::Terms::from(last_sort))
}
}),
..state
};
Ok((hits, next_state))
}
let stream = stream::unfold(start_state, move |state| async move {
if state.stop {
None
} else {
let result = stream_next::<T>(state).await;
match result {
Ok((items, state)) => Some((stream::iter(items), state)),
Err(_err) => None,
}
}
});
Ok(stream.flatten())
}
}