1#![allow(unused_imports)]
28use crate::{
29 client::Elasticsearch,
30 error::Error,
31 http::{
32 self,
33 headers::{HeaderMap, HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE},
34 request::{Body, JsonBody, NdBody, PARTS_ENCODED},
35 response::Response,
36 transport::Transport,
37 },
38 params::*,
39};
40use percent_encoding::percent_encode;
41use serde::Serialize;
42use std::{borrow::Cow, time::Duration};
43#[derive(Debug, Clone, PartialEq, Eq)]
44#[doc = "API parts for the Bulk API"]
45pub enum BulkParts<'b> {
46 #[doc = "No parts"]
47 None,
48 #[doc = "Index"]
49 Index(&'b str),
50}
51impl<'b> BulkParts<'b> {
52 #[doc = "Builds a relative URL path to the Bulk API"]
53 pub fn url(self) -> Cow<'static, str> {
54 match self {
55 BulkParts::None => "/_bulk".into(),
56 BulkParts::Index(index) => {
57 let encoded_index: Cow<str> =
58 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
59 let mut p = String::with_capacity(7usize + encoded_index.len());
60 p.push('/');
61 p.push_str(encoded_index.as_ref());
62 p.push_str("/_bulk");
63 p.into()
64 }
65 }
66 }
67}
68#[doc = "Builder for the [Bulk API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-bulk.html)\n\nAllows to perform multiple index/update/delete operations in a single request."]
69#[derive(Clone, Debug)]
70pub struct Bulk<'a, 'b, B> {
71 transport: &'a Transport,
72 parts: BulkParts<'b>,
73 _source: Option<&'b [&'b str]>,
74 _source_excludes: Option<&'b [&'b str]>,
75 _source_includes: Option<&'b [&'b str]>,
76 body: Option<B>,
77 error_trace: Option<bool>,
78 filter_path: Option<&'b [&'b str]>,
79 headers: HeaderMap,
80 human: Option<bool>,
81 include_source_on_error: Option<bool>,
82 list_executed_pipelines: Option<bool>,
83 pipeline: Option<&'b str>,
84 pretty: Option<bool>,
85 refresh: Option<Refresh>,
86 request_timeout: Option<Duration>,
87 require_alias: Option<bool>,
88 require_data_stream: Option<bool>,
89 routing: Option<&'b str>,
90 source: Option<&'b str>,
91 timeout: Option<&'b str>,
92 wait_for_active_shards: Option<&'b str>,
93}
94impl<'a, 'b, B> Bulk<'a, 'b, B>
95where
96 B: Body,
97{
98 #[doc = "Creates a new instance of [Bulk] with the specified API parts"]
99 pub fn new(transport: &'a Transport, parts: BulkParts<'b>) -> Self {
100 let headers = HeaderMap::new();
101 Bulk {
102 transport,
103 parts,
104 headers,
105 _source: None,
106 _source_excludes: None,
107 _source_includes: None,
108 body: None,
109 error_trace: None,
110 filter_path: None,
111 human: None,
112 include_source_on_error: None,
113 list_executed_pipelines: None,
114 pipeline: None,
115 pretty: None,
116 refresh: None,
117 request_timeout: None,
118 require_alias: None,
119 require_data_stream: None,
120 routing: None,
121 source: None,
122 timeout: None,
123 wait_for_active_shards: None,
124 }
125 }
126 #[doc = "True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request"]
127 pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
128 self._source = Some(_source);
129 self
130 }
131 #[doc = "Default list of fields to exclude from the returned _source field, can be overridden on each sub-request"]
132 pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
133 self._source_excludes = Some(_source_excludes);
134 self
135 }
136 #[doc = "Default list of fields to extract and return from the _source field, can be overridden on each sub-request"]
137 pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
138 self._source_includes = Some(_source_includes);
139 self
140 }
141 #[doc = "The body for the API call"]
142 pub fn body<T>(self, body: Vec<T>) -> Bulk<'a, 'b, NdBody<T>>
143 where
144 T: Body,
145 {
146 Bulk {
147 transport: self.transport,
148 parts: self.parts,
149 body: Some(NdBody::new(body)),
150 _source: self._source,
151 _source_excludes: self._source_excludes,
152 _source_includes: self._source_includes,
153 error_trace: self.error_trace,
154 filter_path: self.filter_path,
155 headers: self.headers,
156 human: self.human,
157 include_source_on_error: self.include_source_on_error,
158 list_executed_pipelines: self.list_executed_pipelines,
159 pipeline: self.pipeline,
160 pretty: self.pretty,
161 refresh: self.refresh,
162 request_timeout: self.request_timeout,
163 require_alias: self.require_alias,
164 require_data_stream: self.require_data_stream,
165 routing: self.routing,
166 source: self.source,
167 timeout: self.timeout,
168 wait_for_active_shards: self.wait_for_active_shards,
169 }
170 }
171 #[doc = "Include the stack trace of returned errors."]
172 pub fn error_trace(mut self, error_trace: bool) -> Self {
173 self.error_trace = Some(error_trace);
174 self
175 }
176 #[doc = "A comma-separated list of filters used to reduce the response."]
177 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
178 self.filter_path = Some(filter_path);
179 self
180 }
181 #[doc = "Adds a HTTP header"]
182 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
183 self.headers.insert(key, value);
184 self
185 }
186 #[doc = "Return human readable values for statistics."]
187 pub fn human(mut self, human: bool) -> Self {
188 self.human = Some(human);
189 self
190 }
191 #[doc = "True or false if to include the document source in the error message in case of parsing errors. Defaults to true."]
192 pub fn include_source_on_error(mut self, include_source_on_error: bool) -> Self {
193 self.include_source_on_error = Some(include_source_on_error);
194 self
195 }
196 #[doc = "Sets list_executed_pipelines for all incoming documents. Defaults to unset (false)"]
197 pub fn list_executed_pipelines(mut self, list_executed_pipelines: bool) -> Self {
198 self.list_executed_pipelines = Some(list_executed_pipelines);
199 self
200 }
201 #[doc = "The pipeline id to preprocess incoming documents with"]
202 pub fn pipeline(mut self, pipeline: &'b str) -> Self {
203 self.pipeline = Some(pipeline);
204 self
205 }
206 #[doc = "Pretty format the returned JSON response."]
207 pub fn pretty(mut self, pretty: bool) -> Self {
208 self.pretty = Some(pretty);
209 self
210 }
211 #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
212 pub fn refresh(mut self, refresh: Refresh) -> Self {
213 self.refresh = Some(refresh);
214 self
215 }
216 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
217 pub fn request_timeout(mut self, timeout: Duration) -> Self {
218 self.request_timeout = Some(timeout);
219 self
220 }
221 #[doc = "If true, the request\u{2019}s actions must target an index alias. Defaults to false."]
222 pub fn require_alias(mut self, require_alias: bool) -> Self {
223 self.require_alias = Some(require_alias);
224 self
225 }
226 #[doc = "If true, the request's actions must target a data stream (existing or to-be-created). Default to false"]
227 pub fn require_data_stream(mut self, require_data_stream: bool) -> Self {
228 self.require_data_stream = Some(require_data_stream);
229 self
230 }
231 #[doc = "Specific routing value"]
232 pub fn routing(mut self, routing: &'b str) -> Self {
233 self.routing = Some(routing);
234 self
235 }
236 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
237 pub fn source(mut self, source: &'b str) -> Self {
238 self.source = Some(source);
239 self
240 }
241 #[doc = "Explicit operation timeout"]
242 pub fn timeout(mut self, timeout: &'b str) -> Self {
243 self.timeout = Some(timeout);
244 self
245 }
246 #[doc = "Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"]
247 pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
248 self.wait_for_active_shards = Some(wait_for_active_shards);
249 self
250 }
251 #[doc = "Creates an asynchronous call to the Bulk API that can be awaited"]
252 pub async fn send(self) -> Result<Response, Error> {
253 let path = self.parts.url();
254 let method = http::Method::Post;
255 let headers = self.headers;
256 let timeout = self.request_timeout;
257 let query_string = {
258 #[serde_with::skip_serializing_none]
259 #[derive(Serialize)]
260 struct QueryParams<'b> {
261 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
262 _source: Option<&'b [&'b str]>,
263 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
264 _source_excludes: Option<&'b [&'b str]>,
265 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
266 _source_includes: Option<&'b [&'b str]>,
267 error_trace: Option<bool>,
268 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
269 filter_path: Option<&'b [&'b str]>,
270 human: Option<bool>,
271 include_source_on_error: Option<bool>,
272 list_executed_pipelines: Option<bool>,
273 pipeline: Option<&'b str>,
274 pretty: Option<bool>,
275 refresh: Option<Refresh>,
276 require_alias: Option<bool>,
277 require_data_stream: Option<bool>,
278 routing: Option<&'b str>,
279 source: Option<&'b str>,
280 timeout: Option<&'b str>,
281 wait_for_active_shards: Option<&'b str>,
282 }
283 let query_params = QueryParams {
284 _source: self._source,
285 _source_excludes: self._source_excludes,
286 _source_includes: self._source_includes,
287 error_trace: self.error_trace,
288 filter_path: self.filter_path,
289 human: self.human,
290 include_source_on_error: self.include_source_on_error,
291 list_executed_pipelines: self.list_executed_pipelines,
292 pipeline: self.pipeline,
293 pretty: self.pretty,
294 refresh: self.refresh,
295 require_alias: self.require_alias,
296 require_data_stream: self.require_data_stream,
297 routing: self.routing,
298 source: self.source,
299 timeout: self.timeout,
300 wait_for_active_shards: self.wait_for_active_shards,
301 };
302 Some(query_params)
303 };
304 let body = self.body;
305 let response = self
306 .transport
307 .send(method, &path, headers, query_string.as_ref(), body, timeout)
308 .await?;
309 Ok(response)
310 }
311}
312#[cfg(feature = "experimental-apis")]
313#[derive(Debug, Clone, PartialEq, Eq)]
314#[doc = "API parts for the Capabilities API"]
315pub enum CapabilitiesParts {
316 #[doc = "No parts"]
317 None,
318}
319#[cfg(feature = "experimental-apis")]
320impl CapabilitiesParts {
321 #[doc = "Builds a relative URL path to the Capabilities API"]
322 pub fn url(self) -> Cow<'static, str> {
323 match self {
324 CapabilitiesParts::None => "/_capabilities".into(),
325 }
326 }
327}
328#[doc = "Builder for the [Capabilities API](https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc#require-or-skip-api-capabilities)\n\nChecks if the specified combination of method, API, parameters, and arbitrary capabilities are supported"]
329#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "]
330#[cfg(feature = "experimental-apis")]
331#[derive(Clone, Debug)]
332pub struct Capabilities<'a, 'b> {
333 transport: &'a Transport,
334 parts: CapabilitiesParts,
335 capabilities: Option<&'b str>,
336 error_trace: Option<bool>,
337 filter_path: Option<&'b [&'b str]>,
338 headers: HeaderMap,
339 human: Option<bool>,
340 local_only: Option<bool>,
341 method: Option<Method>,
342 parameters: Option<&'b str>,
343 path: Option<&'b str>,
344 pretty: Option<bool>,
345 request_timeout: Option<Duration>,
346 source: Option<&'b str>,
347}
348#[cfg(feature = "experimental-apis")]
349impl<'a, 'b> Capabilities<'a, 'b> {
350 #[doc = "Creates a new instance of [Capabilities]"]
351 pub fn new(transport: &'a Transport) -> Self {
352 let headers = HeaderMap::new();
353 Capabilities {
354 transport,
355 parts: CapabilitiesParts::None,
356 headers,
357 capabilities: None,
358 error_trace: None,
359 filter_path: None,
360 human: None,
361 local_only: None,
362 method: None,
363 parameters: None,
364 path: None,
365 pretty: None,
366 request_timeout: None,
367 source: None,
368 }
369 }
370 #[doc = "Comma-separated list of arbitrary API capabilities to check"]
371 pub fn capabilities(mut self, capabilities: &'b str) -> Self {
372 self.capabilities = Some(capabilities);
373 self
374 }
375 #[doc = "Include the stack trace of returned errors."]
376 pub fn error_trace(mut self, error_trace: bool) -> Self {
377 self.error_trace = Some(error_trace);
378 self
379 }
380 #[doc = "A comma-separated list of filters used to reduce the response."]
381 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
382 self.filter_path = Some(filter_path);
383 self
384 }
385 #[doc = "Adds a HTTP header"]
386 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
387 self.headers.insert(key, value);
388 self
389 }
390 #[doc = "Return human readable values for statistics."]
391 pub fn human(mut self, human: bool) -> Self {
392 self.human = Some(human);
393 self
394 }
395 #[doc = "True if only the node being called should be considered"]
396 pub fn local_only(mut self, local_only: bool) -> Self {
397 self.local_only = Some(local_only);
398 self
399 }
400 #[doc = "REST method to check"]
401 pub fn method(mut self, method: Method) -> Self {
402 self.method = Some(method);
403 self
404 }
405 #[doc = "Comma-separated list of API parameters to check"]
406 pub fn parameters(mut self, parameters: &'b str) -> Self {
407 self.parameters = Some(parameters);
408 self
409 }
410 #[doc = "API path to check"]
411 pub fn path(mut self, path: &'b str) -> Self {
412 self.path = Some(path);
413 self
414 }
415 #[doc = "Pretty format the returned JSON response."]
416 pub fn pretty(mut self, pretty: bool) -> Self {
417 self.pretty = Some(pretty);
418 self
419 }
420 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
421 pub fn request_timeout(mut self, timeout: Duration) -> Self {
422 self.request_timeout = Some(timeout);
423 self
424 }
425 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
426 pub fn source(mut self, source: &'b str) -> Self {
427 self.source = Some(source);
428 self
429 }
430 #[doc = "Creates an asynchronous call to the Capabilities API that can be awaited"]
431 pub async fn send(self) -> Result<Response, Error> {
432 let path = self.parts.url();
433 let method = http::Method::Get;
434 let headers = self.headers;
435 let timeout = self.request_timeout;
436 let query_string = {
437 #[serde_with::skip_serializing_none]
438 #[derive(Serialize)]
439 struct QueryParams<'b> {
440 capabilities: Option<&'b str>,
441 error_trace: Option<bool>,
442 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
443 filter_path: Option<&'b [&'b str]>,
444 human: Option<bool>,
445 local_only: Option<bool>,
446 method: Option<Method>,
447 parameters: Option<&'b str>,
448 path: Option<&'b str>,
449 pretty: Option<bool>,
450 source: Option<&'b str>,
451 }
452 let query_params = QueryParams {
453 capabilities: self.capabilities,
454 error_trace: self.error_trace,
455 filter_path: self.filter_path,
456 human: self.human,
457 local_only: self.local_only,
458 method: self.method,
459 parameters: self.parameters,
460 path: self.path,
461 pretty: self.pretty,
462 source: self.source,
463 };
464 Some(query_params)
465 };
466 let body = Option::<()>::None;
467 let response = self
468 .transport
469 .send(method, &path, headers, query_string.as_ref(), body, timeout)
470 .await?;
471 Ok(response)
472 }
473}
474#[derive(Debug, Clone, PartialEq, Eq)]
475#[doc = "API parts for the Clear Scroll API"]
476pub enum ClearScrollParts<'b> {
477 #[doc = "No parts"]
478 None,
479 #[doc = "ScrollId"]
480 ScrollId(&'b [&'b str]),
481}
482impl<'b> ClearScrollParts<'b> {
483 #[doc = "Builds a relative URL path to the Clear Scroll API"]
484 pub fn url(self) -> Cow<'static, str> {
485 match self {
486 ClearScrollParts::None => "/_search/scroll".into(),
487 ClearScrollParts::ScrollId(scroll_id) => {
488 let scroll_id_str = scroll_id.join(",");
489 let encoded_scroll_id: Cow<str> =
490 percent_encode(scroll_id_str.as_bytes(), PARTS_ENCODED).into();
491 let mut p = String::with_capacity(16usize + encoded_scroll_id.len());
492 p.push_str("/_search/scroll/");
493 p.push_str(encoded_scroll_id.as_ref());
494 p.into()
495 }
496 }
497 }
498}
499#[doc = "Builder for the [Clear Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/clear-scroll-api.html)\n\nExplicitly clears the search context for a scroll."]
500#[derive(Clone, Debug)]
501pub struct ClearScroll<'a, 'b, B> {
502 transport: &'a Transport,
503 parts: ClearScrollParts<'b>,
504 body: Option<B>,
505 error_trace: Option<bool>,
506 filter_path: Option<&'b [&'b str]>,
507 headers: HeaderMap,
508 human: Option<bool>,
509 pretty: Option<bool>,
510 request_timeout: Option<Duration>,
511 source: Option<&'b str>,
512}
513impl<'a, 'b, B> ClearScroll<'a, 'b, B>
514where
515 B: Body,
516{
517 #[doc = "Creates a new instance of [ClearScroll] with the specified API parts"]
518 pub fn new(transport: &'a Transport, parts: ClearScrollParts<'b>) -> Self {
519 let headers = HeaderMap::new();
520 ClearScroll {
521 transport,
522 parts,
523 headers,
524 body: None,
525 error_trace: None,
526 filter_path: None,
527 human: None,
528 pretty: None,
529 request_timeout: None,
530 source: None,
531 }
532 }
533 #[doc = "The body for the API call"]
534 pub fn body<T>(self, body: T) -> ClearScroll<'a, 'b, JsonBody<T>>
535 where
536 T: Serialize,
537 {
538 ClearScroll {
539 transport: self.transport,
540 parts: self.parts,
541 body: Some(body.into()),
542 error_trace: self.error_trace,
543 filter_path: self.filter_path,
544 headers: self.headers,
545 human: self.human,
546 pretty: self.pretty,
547 request_timeout: self.request_timeout,
548 source: self.source,
549 }
550 }
551 #[doc = "Include the stack trace of returned errors."]
552 pub fn error_trace(mut self, error_trace: bool) -> Self {
553 self.error_trace = Some(error_trace);
554 self
555 }
556 #[doc = "A comma-separated list of filters used to reduce the response."]
557 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
558 self.filter_path = Some(filter_path);
559 self
560 }
561 #[doc = "Adds a HTTP header"]
562 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
563 self.headers.insert(key, value);
564 self
565 }
566 #[doc = "Return human readable values for statistics."]
567 pub fn human(mut self, human: bool) -> Self {
568 self.human = Some(human);
569 self
570 }
571 #[doc = "Pretty format the returned JSON response."]
572 pub fn pretty(mut self, pretty: bool) -> Self {
573 self.pretty = Some(pretty);
574 self
575 }
576 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
577 pub fn request_timeout(mut self, timeout: Duration) -> Self {
578 self.request_timeout = Some(timeout);
579 self
580 }
581 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
582 pub fn source(mut self, source: &'b str) -> Self {
583 self.source = Some(source);
584 self
585 }
586 #[doc = "Creates an asynchronous call to the Clear Scroll API that can be awaited"]
587 pub async fn send(self) -> Result<Response, Error> {
588 let path = self.parts.url();
589 let method = http::Method::Delete;
590 let headers = self.headers;
591 let timeout = self.request_timeout;
592 let query_string = {
593 #[serde_with::skip_serializing_none]
594 #[derive(Serialize)]
595 struct QueryParams<'b> {
596 error_trace: Option<bool>,
597 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
598 filter_path: Option<&'b [&'b str]>,
599 human: Option<bool>,
600 pretty: Option<bool>,
601 source: Option<&'b str>,
602 }
603 let query_params = QueryParams {
604 error_trace: self.error_trace,
605 filter_path: self.filter_path,
606 human: self.human,
607 pretty: self.pretty,
608 source: self.source,
609 };
610 Some(query_params)
611 };
612 let body = self.body;
613 let response = self
614 .transport
615 .send(method, &path, headers, query_string.as_ref(), body, timeout)
616 .await?;
617 Ok(response)
618 }
619}
620#[derive(Debug, Clone, PartialEq, Eq)]
621#[doc = "API parts for the Close Point In Time API"]
622pub enum ClosePointInTimeParts {
623 #[doc = "No parts"]
624 None,
625}
626impl ClosePointInTimeParts {
627 #[doc = "Builds a relative URL path to the Close Point In Time API"]
628 pub fn url(self) -> Cow<'static, str> {
629 match self {
630 ClosePointInTimeParts::None => "/_pit".into(),
631 }
632 }
633}
634#[doc = "Builder for the [Close Point In Time API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/point-in-time-api.html)\n\nClose a point in time"]
635#[derive(Clone, Debug)]
636pub struct ClosePointInTime<'a, 'b, B> {
637 transport: &'a Transport,
638 parts: ClosePointInTimeParts,
639 body: Option<B>,
640 error_trace: Option<bool>,
641 filter_path: Option<&'b [&'b str]>,
642 headers: HeaderMap,
643 human: Option<bool>,
644 pretty: Option<bool>,
645 request_timeout: Option<Duration>,
646 source: Option<&'b str>,
647}
648impl<'a, 'b, B> ClosePointInTime<'a, 'b, B>
649where
650 B: Body,
651{
652 #[doc = "Creates a new instance of [ClosePointInTime]"]
653 pub fn new(transport: &'a Transport) -> Self {
654 let headers = HeaderMap::new();
655 ClosePointInTime {
656 transport,
657 parts: ClosePointInTimeParts::None,
658 headers,
659 body: None,
660 error_trace: None,
661 filter_path: None,
662 human: None,
663 pretty: None,
664 request_timeout: None,
665 source: None,
666 }
667 }
668 #[doc = "The body for the API call"]
669 pub fn body<T>(self, body: T) -> ClosePointInTime<'a, 'b, JsonBody<T>>
670 where
671 T: Serialize,
672 {
673 ClosePointInTime {
674 transport: self.transport,
675 parts: self.parts,
676 body: Some(body.into()),
677 error_trace: self.error_trace,
678 filter_path: self.filter_path,
679 headers: self.headers,
680 human: self.human,
681 pretty: self.pretty,
682 request_timeout: self.request_timeout,
683 source: self.source,
684 }
685 }
686 #[doc = "Include the stack trace of returned errors."]
687 pub fn error_trace(mut self, error_trace: bool) -> Self {
688 self.error_trace = Some(error_trace);
689 self
690 }
691 #[doc = "A comma-separated list of filters used to reduce the response."]
692 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
693 self.filter_path = Some(filter_path);
694 self
695 }
696 #[doc = "Adds a HTTP header"]
697 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
698 self.headers.insert(key, value);
699 self
700 }
701 #[doc = "Return human readable values for statistics."]
702 pub fn human(mut self, human: bool) -> Self {
703 self.human = Some(human);
704 self
705 }
706 #[doc = "Pretty format the returned JSON response."]
707 pub fn pretty(mut self, pretty: bool) -> Self {
708 self.pretty = Some(pretty);
709 self
710 }
711 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
712 pub fn request_timeout(mut self, timeout: Duration) -> Self {
713 self.request_timeout = Some(timeout);
714 self
715 }
716 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
717 pub fn source(mut self, source: &'b str) -> Self {
718 self.source = Some(source);
719 self
720 }
721 #[doc = "Creates an asynchronous call to the Close Point In Time API that can be awaited"]
722 pub async fn send(self) -> Result<Response, Error> {
723 let path = self.parts.url();
724 let method = http::Method::Delete;
725 let headers = self.headers;
726 let timeout = self.request_timeout;
727 let query_string = {
728 #[serde_with::skip_serializing_none]
729 #[derive(Serialize)]
730 struct QueryParams<'b> {
731 error_trace: Option<bool>,
732 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
733 filter_path: Option<&'b [&'b str]>,
734 human: Option<bool>,
735 pretty: Option<bool>,
736 source: Option<&'b str>,
737 }
738 let query_params = QueryParams {
739 error_trace: self.error_trace,
740 filter_path: self.filter_path,
741 human: self.human,
742 pretty: self.pretty,
743 source: self.source,
744 };
745 Some(query_params)
746 };
747 let body = self.body;
748 let response = self
749 .transport
750 .send(method, &path, headers, query_string.as_ref(), body, timeout)
751 .await?;
752 Ok(response)
753 }
754}
755#[derive(Debug, Clone, PartialEq, Eq)]
756#[doc = "API parts for the Count API"]
757pub enum CountParts<'b> {
758 #[doc = "No parts"]
759 None,
760 #[doc = "Index"]
761 Index(&'b [&'b str]),
762}
763impl<'b> CountParts<'b> {
764 #[doc = "Builds a relative URL path to the Count API"]
765 pub fn url(self) -> Cow<'static, str> {
766 match self {
767 CountParts::None => "/_count".into(),
768 CountParts::Index(index) => {
769 let index_str = index.join(",");
770 let encoded_index: Cow<str> =
771 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
772 let mut p = String::with_capacity(8usize + encoded_index.len());
773 p.push('/');
774 p.push_str(encoded_index.as_ref());
775 p.push_str("/_count");
776 p.into()
777 }
778 }
779 }
780}
781#[doc = "Builder for the [Count API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-count.html)\n\nReturns number of documents matching a query."]
782#[derive(Clone, Debug)]
783pub struct Count<'a, 'b, B> {
784 transport: &'a Transport,
785 parts: CountParts<'b>,
786 allow_no_indices: Option<bool>,
787 analyze_wildcard: Option<bool>,
788 analyzer: Option<&'b str>,
789 body: Option<B>,
790 default_operator: Option<DefaultOperator>,
791 df: Option<&'b str>,
792 error_trace: Option<bool>,
793 expand_wildcards: Option<&'b [ExpandWildcards]>,
794 filter_path: Option<&'b [&'b str]>,
795 headers: HeaderMap,
796 human: Option<bool>,
797 ignore_throttled: Option<bool>,
798 ignore_unavailable: Option<bool>,
799 lenient: Option<bool>,
800 min_score: Option<i64>,
801 preference: Option<&'b str>,
802 pretty: Option<bool>,
803 q: Option<&'b str>,
804 request_timeout: Option<Duration>,
805 routing: Option<&'b [&'b str]>,
806 source: Option<&'b str>,
807 terminate_after: Option<i64>,
808}
809impl<'a, 'b, B> Count<'a, 'b, B>
810where
811 B: Body,
812{
813 #[doc = "Creates a new instance of [Count] with the specified API parts"]
814 pub fn new(transport: &'a Transport, parts: CountParts<'b>) -> Self {
815 let headers = HeaderMap::new();
816 Count {
817 transport,
818 parts,
819 headers,
820 allow_no_indices: None,
821 analyze_wildcard: None,
822 analyzer: None,
823 body: None,
824 default_operator: None,
825 df: None,
826 error_trace: None,
827 expand_wildcards: None,
828 filter_path: None,
829 human: None,
830 ignore_throttled: None,
831 ignore_unavailable: None,
832 lenient: None,
833 min_score: None,
834 preference: None,
835 pretty: None,
836 q: None,
837 request_timeout: None,
838 routing: None,
839 source: None,
840 terminate_after: None,
841 }
842 }
843 #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
844 pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
845 self.allow_no_indices = Some(allow_no_indices);
846 self
847 }
848 #[doc = "Specify whether wildcard and prefix queries should be analyzed (default: false)"]
849 pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
850 self.analyze_wildcard = Some(analyze_wildcard);
851 self
852 }
853 #[doc = "The analyzer to use for the query string"]
854 pub fn analyzer(mut self, analyzer: &'b str) -> Self {
855 self.analyzer = Some(analyzer);
856 self
857 }
858 #[doc = "The body for the API call"]
859 pub fn body<T>(self, body: T) -> Count<'a, 'b, JsonBody<T>>
860 where
861 T: Serialize,
862 {
863 Count {
864 transport: self.transport,
865 parts: self.parts,
866 body: Some(body.into()),
867 allow_no_indices: self.allow_no_indices,
868 analyze_wildcard: self.analyze_wildcard,
869 analyzer: self.analyzer,
870 default_operator: self.default_operator,
871 df: self.df,
872 error_trace: self.error_trace,
873 expand_wildcards: self.expand_wildcards,
874 filter_path: self.filter_path,
875 headers: self.headers,
876 human: self.human,
877 ignore_throttled: self.ignore_throttled,
878 ignore_unavailable: self.ignore_unavailable,
879 lenient: self.lenient,
880 min_score: self.min_score,
881 preference: self.preference,
882 pretty: self.pretty,
883 q: self.q,
884 request_timeout: self.request_timeout,
885 routing: self.routing,
886 source: self.source,
887 terminate_after: self.terminate_after,
888 }
889 }
890 #[doc = "The default operator for query string query (AND or OR)"]
891 pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
892 self.default_operator = Some(default_operator);
893 self
894 }
895 #[doc = "The field to use as default where no field prefix is given in the query string"]
896 pub fn df(mut self, df: &'b str) -> Self {
897 self.df = Some(df);
898 self
899 }
900 #[doc = "Include the stack trace of returned errors."]
901 pub fn error_trace(mut self, error_trace: bool) -> Self {
902 self.error_trace = Some(error_trace);
903 self
904 }
905 #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
906 pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
907 self.expand_wildcards = Some(expand_wildcards);
908 self
909 }
910 #[doc = "A comma-separated list of filters used to reduce the response."]
911 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
912 self.filter_path = Some(filter_path);
913 self
914 }
915 #[doc = "Adds a HTTP header"]
916 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
917 self.headers.insert(key, value);
918 self
919 }
920 #[doc = "Return human readable values for statistics."]
921 pub fn human(mut self, human: bool) -> Self {
922 self.human = Some(human);
923 self
924 }
925 #[doc = "Whether specified concrete, expanded or aliased indices should be ignored when throttled"]
926 pub fn ignore_throttled(mut self, ignore_throttled: bool) -> Self {
927 self.ignore_throttled = Some(ignore_throttled);
928 self
929 }
930 #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
931 pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
932 self.ignore_unavailable = Some(ignore_unavailable);
933 self
934 }
935 #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
936 pub fn lenient(mut self, lenient: bool) -> Self {
937 self.lenient = Some(lenient);
938 self
939 }
940 #[doc = "Include only documents with a specific `_score` value in the result"]
941 pub fn min_score(mut self, min_score: i64) -> Self {
942 self.min_score = Some(min_score);
943 self
944 }
945 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
946 pub fn preference(mut self, preference: &'b str) -> Self {
947 self.preference = Some(preference);
948 self
949 }
950 #[doc = "Pretty format the returned JSON response."]
951 pub fn pretty(mut self, pretty: bool) -> Self {
952 self.pretty = Some(pretty);
953 self
954 }
955 #[doc = "Query in the Lucene query string syntax"]
956 pub fn q(mut self, q: &'b str) -> Self {
957 self.q = Some(q);
958 self
959 }
960 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
961 pub fn request_timeout(mut self, timeout: Duration) -> Self {
962 self.request_timeout = Some(timeout);
963 self
964 }
965 #[doc = "A comma-separated list of specific routing values"]
966 pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
967 self.routing = Some(routing);
968 self
969 }
970 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
971 pub fn source(mut self, source: &'b str) -> Self {
972 self.source = Some(source);
973 self
974 }
975 #[doc = "The maximum count for each shard, upon reaching which the query execution will terminate early"]
976 pub fn terminate_after(mut self, terminate_after: i64) -> Self {
977 self.terminate_after = Some(terminate_after);
978 self
979 }
980 #[doc = "Creates an asynchronous call to the Count API that can be awaited"]
981 pub async fn send(self) -> Result<Response, Error> {
982 let path = self.parts.url();
983 let method = match self.body {
984 Some(_) => http::Method::Post,
985 None => http::Method::Get,
986 };
987 let headers = self.headers;
988 let timeout = self.request_timeout;
989 let query_string = {
990 #[serde_with::skip_serializing_none]
991 #[derive(Serialize)]
992 struct QueryParams<'b> {
993 allow_no_indices: Option<bool>,
994 analyze_wildcard: Option<bool>,
995 analyzer: Option<&'b str>,
996 default_operator: Option<DefaultOperator>,
997 df: Option<&'b str>,
998 error_trace: Option<bool>,
999 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1000 expand_wildcards: Option<&'b [ExpandWildcards]>,
1001 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1002 filter_path: Option<&'b [&'b str]>,
1003 human: Option<bool>,
1004 ignore_throttled: Option<bool>,
1005 ignore_unavailable: Option<bool>,
1006 lenient: Option<bool>,
1007 min_score: Option<i64>,
1008 preference: Option<&'b str>,
1009 pretty: Option<bool>,
1010 q: Option<&'b str>,
1011 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1012 routing: Option<&'b [&'b str]>,
1013 source: Option<&'b str>,
1014 terminate_after: Option<i64>,
1015 }
1016 let query_params = QueryParams {
1017 allow_no_indices: self.allow_no_indices,
1018 analyze_wildcard: self.analyze_wildcard,
1019 analyzer: self.analyzer,
1020 default_operator: self.default_operator,
1021 df: self.df,
1022 error_trace: self.error_trace,
1023 expand_wildcards: self.expand_wildcards,
1024 filter_path: self.filter_path,
1025 human: self.human,
1026 ignore_throttled: self.ignore_throttled,
1027 ignore_unavailable: self.ignore_unavailable,
1028 lenient: self.lenient,
1029 min_score: self.min_score,
1030 preference: self.preference,
1031 pretty: self.pretty,
1032 q: self.q,
1033 routing: self.routing,
1034 source: self.source,
1035 terminate_after: self.terminate_after,
1036 };
1037 Some(query_params)
1038 };
1039 let body = self.body;
1040 let response = self
1041 .transport
1042 .send(method, &path, headers, query_string.as_ref(), body, timeout)
1043 .await?;
1044 Ok(response)
1045 }
1046}
1047#[derive(Debug, Clone, PartialEq, Eq)]
1048#[doc = "API parts for the Create API"]
1049pub enum CreateParts<'b> {
1050 #[doc = "Index and Id"]
1051 IndexId(&'b str, &'b str),
1052}
1053impl<'b> CreateParts<'b> {
1054 #[doc = "Builds a relative URL path to the Create API"]
1055 pub fn url(self) -> Cow<'static, str> {
1056 match self {
1057 CreateParts::IndexId(index, id) => {
1058 let encoded_index: Cow<str> =
1059 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
1060 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
1061 let mut p = String::with_capacity(10usize + encoded_index.len() + encoded_id.len());
1062 p.push('/');
1063 p.push_str(encoded_index.as_ref());
1064 p.push_str("/_create/");
1065 p.push_str(encoded_id.as_ref());
1066 p.into()
1067 }
1068 }
1069 }
1070}
1071#[doc = "Builder for the [Create API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-index_.html)\n\nCreates a new document in the index.\n\nReturns a 409 response when a document with a same ID already exists in the index."]
1072#[derive(Clone, Debug)]
1073pub struct Create<'a, 'b, B> {
1074 transport: &'a Transport,
1075 parts: CreateParts<'b>,
1076 body: Option<B>,
1077 error_trace: Option<bool>,
1078 filter_path: Option<&'b [&'b str]>,
1079 headers: HeaderMap,
1080 human: Option<bool>,
1081 include_source_on_error: Option<bool>,
1082 pipeline: Option<&'b str>,
1083 pretty: Option<bool>,
1084 refresh: Option<Refresh>,
1085 request_timeout: Option<Duration>,
1086 routing: Option<&'b str>,
1087 source: Option<&'b str>,
1088 timeout: Option<&'b str>,
1089 version: Option<i64>,
1090 version_type: Option<VersionType>,
1091 wait_for_active_shards: Option<&'b str>,
1092}
1093impl<'a, 'b, B> Create<'a, 'b, B>
1094where
1095 B: Body,
1096{
1097 #[doc = "Creates a new instance of [Create] with the specified API parts"]
1098 pub fn new(transport: &'a Transport, parts: CreateParts<'b>) -> Self {
1099 let headers = HeaderMap::new();
1100 Create {
1101 transport,
1102 parts,
1103 headers,
1104 body: None,
1105 error_trace: None,
1106 filter_path: None,
1107 human: None,
1108 include_source_on_error: None,
1109 pipeline: None,
1110 pretty: None,
1111 refresh: None,
1112 request_timeout: None,
1113 routing: None,
1114 source: None,
1115 timeout: None,
1116 version: None,
1117 version_type: None,
1118 wait_for_active_shards: None,
1119 }
1120 }
1121 #[doc = "The body for the API call"]
1122 pub fn body<T>(self, body: T) -> Create<'a, 'b, JsonBody<T>>
1123 where
1124 T: Serialize,
1125 {
1126 Create {
1127 transport: self.transport,
1128 parts: self.parts,
1129 body: Some(body.into()),
1130 error_trace: self.error_trace,
1131 filter_path: self.filter_path,
1132 headers: self.headers,
1133 human: self.human,
1134 include_source_on_error: self.include_source_on_error,
1135 pipeline: self.pipeline,
1136 pretty: self.pretty,
1137 refresh: self.refresh,
1138 request_timeout: self.request_timeout,
1139 routing: self.routing,
1140 source: self.source,
1141 timeout: self.timeout,
1142 version: self.version,
1143 version_type: self.version_type,
1144 wait_for_active_shards: self.wait_for_active_shards,
1145 }
1146 }
1147 #[doc = "Include the stack trace of returned errors."]
1148 pub fn error_trace(mut self, error_trace: bool) -> Self {
1149 self.error_trace = Some(error_trace);
1150 self
1151 }
1152 #[doc = "A comma-separated list of filters used to reduce the response."]
1153 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
1154 self.filter_path = Some(filter_path);
1155 self
1156 }
1157 #[doc = "Adds a HTTP header"]
1158 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
1159 self.headers.insert(key, value);
1160 self
1161 }
1162 #[doc = "Return human readable values for statistics."]
1163 pub fn human(mut self, human: bool) -> Self {
1164 self.human = Some(human);
1165 self
1166 }
1167 #[doc = "True or false if to include the document source in the error message in case of parsing errors. Defaults to true."]
1168 pub fn include_source_on_error(mut self, include_source_on_error: bool) -> Self {
1169 self.include_source_on_error = Some(include_source_on_error);
1170 self
1171 }
1172 #[doc = "The pipeline id to preprocess incoming documents with"]
1173 pub fn pipeline(mut self, pipeline: &'b str) -> Self {
1174 self.pipeline = Some(pipeline);
1175 self
1176 }
1177 #[doc = "Pretty format the returned JSON response."]
1178 pub fn pretty(mut self, pretty: bool) -> Self {
1179 self.pretty = Some(pretty);
1180 self
1181 }
1182 #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
1183 pub fn refresh(mut self, refresh: Refresh) -> Self {
1184 self.refresh = Some(refresh);
1185 self
1186 }
1187 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
1188 pub fn request_timeout(mut self, timeout: Duration) -> Self {
1189 self.request_timeout = Some(timeout);
1190 self
1191 }
1192 #[doc = "Specific routing value"]
1193 pub fn routing(mut self, routing: &'b str) -> Self {
1194 self.routing = Some(routing);
1195 self
1196 }
1197 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
1198 pub fn source(mut self, source: &'b str) -> Self {
1199 self.source = Some(source);
1200 self
1201 }
1202 #[doc = "Explicit operation timeout"]
1203 pub fn timeout(mut self, timeout: &'b str) -> Self {
1204 self.timeout = Some(timeout);
1205 self
1206 }
1207 #[doc = "Explicit version number for concurrency control"]
1208 pub fn version(mut self, version: i64) -> Self {
1209 self.version = Some(version);
1210 self
1211 }
1212 #[doc = "Specific version type"]
1213 pub fn version_type(mut self, version_type: VersionType) -> Self {
1214 self.version_type = Some(version_type);
1215 self
1216 }
1217 #[doc = "Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"]
1218 pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
1219 self.wait_for_active_shards = Some(wait_for_active_shards);
1220 self
1221 }
1222 #[doc = "Creates an asynchronous call to the Create API that can be awaited"]
1223 pub async fn send(self) -> Result<Response, Error> {
1224 let path = self.parts.url();
1225 let method = http::Method::Post;
1226 let headers = self.headers;
1227 let timeout = self.request_timeout;
1228 let query_string = {
1229 #[serde_with::skip_serializing_none]
1230 #[derive(Serialize)]
1231 struct QueryParams<'b> {
1232 error_trace: Option<bool>,
1233 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1234 filter_path: Option<&'b [&'b str]>,
1235 human: Option<bool>,
1236 include_source_on_error: Option<bool>,
1237 pipeline: Option<&'b str>,
1238 pretty: Option<bool>,
1239 refresh: Option<Refresh>,
1240 routing: Option<&'b str>,
1241 source: Option<&'b str>,
1242 timeout: Option<&'b str>,
1243 version: Option<i64>,
1244 version_type: Option<VersionType>,
1245 wait_for_active_shards: Option<&'b str>,
1246 }
1247 let query_params = QueryParams {
1248 error_trace: self.error_trace,
1249 filter_path: self.filter_path,
1250 human: self.human,
1251 include_source_on_error: self.include_source_on_error,
1252 pipeline: self.pipeline,
1253 pretty: self.pretty,
1254 refresh: self.refresh,
1255 routing: self.routing,
1256 source: self.source,
1257 timeout: self.timeout,
1258 version: self.version,
1259 version_type: self.version_type,
1260 wait_for_active_shards: self.wait_for_active_shards,
1261 };
1262 Some(query_params)
1263 };
1264 let body = self.body;
1265 let response = self
1266 .transport
1267 .send(method, &path, headers, query_string.as_ref(), body, timeout)
1268 .await?;
1269 Ok(response)
1270 }
1271}
1272#[derive(Debug, Clone, PartialEq, Eq)]
1273#[doc = "API parts for the Delete API"]
1274pub enum DeleteParts<'b> {
1275 #[doc = "Index and Id"]
1276 IndexId(&'b str, &'b str),
1277}
1278impl<'b> DeleteParts<'b> {
1279 #[doc = "Builds a relative URL path to the Delete API"]
1280 pub fn url(self) -> Cow<'static, str> {
1281 match self {
1282 DeleteParts::IndexId(index, id) => {
1283 let encoded_index: Cow<str> =
1284 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
1285 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
1286 let mut p = String::with_capacity(7usize + encoded_index.len() + encoded_id.len());
1287 p.push('/');
1288 p.push_str(encoded_index.as_ref());
1289 p.push_str("/_doc/");
1290 p.push_str(encoded_id.as_ref());
1291 p.into()
1292 }
1293 }
1294 }
1295}
1296#[doc = "Builder for the [Delete API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-delete.html)\n\nRemoves a document from the index."]
1297#[derive(Clone, Debug)]
1298pub struct Delete<'a, 'b> {
1299 transport: &'a Transport,
1300 parts: DeleteParts<'b>,
1301 error_trace: Option<bool>,
1302 filter_path: Option<&'b [&'b str]>,
1303 headers: HeaderMap,
1304 human: Option<bool>,
1305 if_primary_term: Option<i64>,
1306 if_seq_no: Option<i64>,
1307 pretty: Option<bool>,
1308 refresh: Option<Refresh>,
1309 request_timeout: Option<Duration>,
1310 routing: Option<&'b str>,
1311 source: Option<&'b str>,
1312 timeout: Option<&'b str>,
1313 version: Option<i64>,
1314 version_type: Option<VersionType>,
1315 wait_for_active_shards: Option<&'b str>,
1316}
1317impl<'a, 'b> Delete<'a, 'b> {
1318 #[doc = "Creates a new instance of [Delete] with the specified API parts"]
1319 pub fn new(transport: &'a Transport, parts: DeleteParts<'b>) -> Self {
1320 let headers = HeaderMap::new();
1321 Delete {
1322 transport,
1323 parts,
1324 headers,
1325 error_trace: None,
1326 filter_path: None,
1327 human: None,
1328 if_primary_term: None,
1329 if_seq_no: None,
1330 pretty: None,
1331 refresh: None,
1332 request_timeout: None,
1333 routing: None,
1334 source: None,
1335 timeout: None,
1336 version: None,
1337 version_type: None,
1338 wait_for_active_shards: None,
1339 }
1340 }
1341 #[doc = "Include the stack trace of returned errors."]
1342 pub fn error_trace(mut self, error_trace: bool) -> Self {
1343 self.error_trace = Some(error_trace);
1344 self
1345 }
1346 #[doc = "A comma-separated list of filters used to reduce the response."]
1347 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
1348 self.filter_path = Some(filter_path);
1349 self
1350 }
1351 #[doc = "Adds a HTTP header"]
1352 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
1353 self.headers.insert(key, value);
1354 self
1355 }
1356 #[doc = "Return human readable values for statistics."]
1357 pub fn human(mut self, human: bool) -> Self {
1358 self.human = Some(human);
1359 self
1360 }
1361 #[doc = "only perform the delete operation if the last operation that has changed the document has the specified primary term"]
1362 pub fn if_primary_term(mut self, if_primary_term: i64) -> Self {
1363 self.if_primary_term = Some(if_primary_term);
1364 self
1365 }
1366 #[doc = "only perform the delete operation if the last operation that has changed the document has the specified sequence number"]
1367 pub fn if_seq_no(mut self, if_seq_no: i64) -> Self {
1368 self.if_seq_no = Some(if_seq_no);
1369 self
1370 }
1371 #[doc = "Pretty format the returned JSON response."]
1372 pub fn pretty(mut self, pretty: bool) -> Self {
1373 self.pretty = Some(pretty);
1374 self
1375 }
1376 #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
1377 pub fn refresh(mut self, refresh: Refresh) -> Self {
1378 self.refresh = Some(refresh);
1379 self
1380 }
1381 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
1382 pub fn request_timeout(mut self, timeout: Duration) -> Self {
1383 self.request_timeout = Some(timeout);
1384 self
1385 }
1386 #[doc = "Specific routing value"]
1387 pub fn routing(mut self, routing: &'b str) -> Self {
1388 self.routing = Some(routing);
1389 self
1390 }
1391 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
1392 pub fn source(mut self, source: &'b str) -> Self {
1393 self.source = Some(source);
1394 self
1395 }
1396 #[doc = "Explicit operation timeout"]
1397 pub fn timeout(mut self, timeout: &'b str) -> Self {
1398 self.timeout = Some(timeout);
1399 self
1400 }
1401 #[doc = "Explicit version number for concurrency control"]
1402 pub fn version(mut self, version: i64) -> Self {
1403 self.version = Some(version);
1404 self
1405 }
1406 #[doc = "Specific version type"]
1407 pub fn version_type(mut self, version_type: VersionType) -> Self {
1408 self.version_type = Some(version_type);
1409 self
1410 }
1411 #[doc = "Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"]
1412 pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
1413 self.wait_for_active_shards = Some(wait_for_active_shards);
1414 self
1415 }
1416 #[doc = "Creates an asynchronous call to the Delete API that can be awaited"]
1417 pub async fn send(self) -> Result<Response, Error> {
1418 let path = self.parts.url();
1419 let method = http::Method::Delete;
1420 let headers = self.headers;
1421 let timeout = self.request_timeout;
1422 let query_string = {
1423 #[serde_with::skip_serializing_none]
1424 #[derive(Serialize)]
1425 struct QueryParams<'b> {
1426 error_trace: Option<bool>,
1427 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1428 filter_path: Option<&'b [&'b str]>,
1429 human: Option<bool>,
1430 if_primary_term: Option<i64>,
1431 if_seq_no: Option<i64>,
1432 pretty: Option<bool>,
1433 refresh: Option<Refresh>,
1434 routing: Option<&'b str>,
1435 source: Option<&'b str>,
1436 timeout: Option<&'b str>,
1437 version: Option<i64>,
1438 version_type: Option<VersionType>,
1439 wait_for_active_shards: Option<&'b str>,
1440 }
1441 let query_params = QueryParams {
1442 error_trace: self.error_trace,
1443 filter_path: self.filter_path,
1444 human: self.human,
1445 if_primary_term: self.if_primary_term,
1446 if_seq_no: self.if_seq_no,
1447 pretty: self.pretty,
1448 refresh: self.refresh,
1449 routing: self.routing,
1450 source: self.source,
1451 timeout: self.timeout,
1452 version: self.version,
1453 version_type: self.version_type,
1454 wait_for_active_shards: self.wait_for_active_shards,
1455 };
1456 Some(query_params)
1457 };
1458 let body = Option::<()>::None;
1459 let response = self
1460 .transport
1461 .send(method, &path, headers, query_string.as_ref(), body, timeout)
1462 .await?;
1463 Ok(response)
1464 }
1465}
1466#[derive(Debug, Clone, PartialEq, Eq)]
1467#[doc = "API parts for the Delete By Query API"]
1468pub enum DeleteByQueryParts<'b> {
1469 #[doc = "Index"]
1470 Index(&'b [&'b str]),
1471}
1472impl<'b> DeleteByQueryParts<'b> {
1473 #[doc = "Builds a relative URL path to the Delete By Query API"]
1474 pub fn url(self) -> Cow<'static, str> {
1475 match self {
1476 DeleteByQueryParts::Index(index) => {
1477 let index_str = index.join(",");
1478 let encoded_index: Cow<str> =
1479 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
1480 let mut p = String::with_capacity(18usize + encoded_index.len());
1481 p.push('/');
1482 p.push_str(encoded_index.as_ref());
1483 p.push_str("/_delete_by_query");
1484 p.into()
1485 }
1486 }
1487 }
1488}
1489#[doc = "Builder for the [Delete By Query API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-delete-by-query.html)\n\nDeletes documents matching the provided query."]
1490#[derive(Clone, Debug)]
1491pub struct DeleteByQuery<'a, 'b, B> {
1492 transport: &'a Transport,
1493 parts: DeleteByQueryParts<'b>,
1494 allow_no_indices: Option<bool>,
1495 analyze_wildcard: Option<bool>,
1496 analyzer: Option<&'b str>,
1497 body: Option<B>,
1498 conflicts: Option<Conflicts>,
1499 default_operator: Option<DefaultOperator>,
1500 df: Option<&'b str>,
1501 error_trace: Option<bool>,
1502 expand_wildcards: Option<&'b [ExpandWildcards]>,
1503 filter_path: Option<&'b [&'b str]>,
1504 from: Option<i64>,
1505 headers: HeaderMap,
1506 human: Option<bool>,
1507 ignore_unavailable: Option<bool>,
1508 lenient: Option<bool>,
1509 max_docs: Option<i64>,
1510 preference: Option<&'b str>,
1511 pretty: Option<bool>,
1512 q: Option<&'b str>,
1513 refresh: Option<bool>,
1514 request_cache: Option<bool>,
1515 request_timeout: Option<Duration>,
1516 requests_per_second: Option<i64>,
1517 routing: Option<&'b [&'b str]>,
1518 scroll: Option<&'b str>,
1519 scroll_size: Option<i64>,
1520 search_timeout: Option<&'b str>,
1521 search_type: Option<SearchType>,
1522 slices: Option<Slices>,
1523 sort: Option<&'b [&'b str]>,
1524 source: Option<&'b str>,
1525 stats: Option<&'b [&'b str]>,
1526 terminate_after: Option<i64>,
1527 timeout: Option<&'b str>,
1528 version: Option<bool>,
1529 wait_for_active_shards: Option<&'b str>,
1530 wait_for_completion: Option<bool>,
1531}
1532impl<'a, 'b, B> DeleteByQuery<'a, 'b, B>
1533where
1534 B: Body,
1535{
1536 #[doc = "Creates a new instance of [DeleteByQuery] with the specified API parts"]
1537 pub fn new(transport: &'a Transport, parts: DeleteByQueryParts<'b>) -> Self {
1538 let headers = HeaderMap::new();
1539 DeleteByQuery {
1540 transport,
1541 parts,
1542 headers,
1543 allow_no_indices: None,
1544 analyze_wildcard: None,
1545 analyzer: None,
1546 body: None,
1547 conflicts: None,
1548 default_operator: None,
1549 df: None,
1550 error_trace: None,
1551 expand_wildcards: None,
1552 filter_path: None,
1553 from: None,
1554 human: None,
1555 ignore_unavailable: None,
1556 lenient: None,
1557 max_docs: None,
1558 preference: None,
1559 pretty: None,
1560 q: None,
1561 refresh: None,
1562 request_cache: None,
1563 request_timeout: None,
1564 requests_per_second: None,
1565 routing: None,
1566 scroll: None,
1567 scroll_size: None,
1568 search_timeout: None,
1569 search_type: None,
1570 slices: None,
1571 sort: None,
1572 source: None,
1573 stats: None,
1574 terminate_after: None,
1575 timeout: None,
1576 version: None,
1577 wait_for_active_shards: None,
1578 wait_for_completion: None,
1579 }
1580 }
1581 #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
1582 pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
1583 self.allow_no_indices = Some(allow_no_indices);
1584 self
1585 }
1586 #[doc = "Specify whether wildcard and prefix queries should be analyzed (default: false)"]
1587 pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
1588 self.analyze_wildcard = Some(analyze_wildcard);
1589 self
1590 }
1591 #[doc = "The analyzer to use for the query string"]
1592 pub fn analyzer(mut self, analyzer: &'b str) -> Self {
1593 self.analyzer = Some(analyzer);
1594 self
1595 }
1596 #[doc = "The body for the API call"]
1597 pub fn body<T>(self, body: T) -> DeleteByQuery<'a, 'b, JsonBody<T>>
1598 where
1599 T: Serialize,
1600 {
1601 DeleteByQuery {
1602 transport: self.transport,
1603 parts: self.parts,
1604 body: Some(body.into()),
1605 allow_no_indices: self.allow_no_indices,
1606 analyze_wildcard: self.analyze_wildcard,
1607 analyzer: self.analyzer,
1608 conflicts: self.conflicts,
1609 default_operator: self.default_operator,
1610 df: self.df,
1611 error_trace: self.error_trace,
1612 expand_wildcards: self.expand_wildcards,
1613 filter_path: self.filter_path,
1614 from: self.from,
1615 headers: self.headers,
1616 human: self.human,
1617 ignore_unavailable: self.ignore_unavailable,
1618 lenient: self.lenient,
1619 max_docs: self.max_docs,
1620 preference: self.preference,
1621 pretty: self.pretty,
1622 q: self.q,
1623 refresh: self.refresh,
1624 request_cache: self.request_cache,
1625 request_timeout: self.request_timeout,
1626 requests_per_second: self.requests_per_second,
1627 routing: self.routing,
1628 scroll: self.scroll,
1629 scroll_size: self.scroll_size,
1630 search_timeout: self.search_timeout,
1631 search_type: self.search_type,
1632 slices: self.slices,
1633 sort: self.sort,
1634 source: self.source,
1635 stats: self.stats,
1636 terminate_after: self.terminate_after,
1637 timeout: self.timeout,
1638 version: self.version,
1639 wait_for_active_shards: self.wait_for_active_shards,
1640 wait_for_completion: self.wait_for_completion,
1641 }
1642 }
1643 #[doc = "What to do when the delete by query hits version conflicts?"]
1644 pub fn conflicts(mut self, conflicts: Conflicts) -> Self {
1645 self.conflicts = Some(conflicts);
1646 self
1647 }
1648 #[doc = "The default operator for query string query (AND or OR)"]
1649 pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
1650 self.default_operator = Some(default_operator);
1651 self
1652 }
1653 #[doc = "The field to use as default where no field prefix is given in the query string"]
1654 pub fn df(mut self, df: &'b str) -> Self {
1655 self.df = Some(df);
1656 self
1657 }
1658 #[doc = "Include the stack trace of returned errors."]
1659 pub fn error_trace(mut self, error_trace: bool) -> Self {
1660 self.error_trace = Some(error_trace);
1661 self
1662 }
1663 #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
1664 pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
1665 self.expand_wildcards = Some(expand_wildcards);
1666 self
1667 }
1668 #[doc = "A comma-separated list of filters used to reduce the response."]
1669 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
1670 self.filter_path = Some(filter_path);
1671 self
1672 }
1673 #[doc = "Starting offset (default: 0)"]
1674 pub fn from(mut self, from: i64) -> Self {
1675 self.from = Some(from);
1676 self
1677 }
1678 #[doc = "Adds a HTTP header"]
1679 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
1680 self.headers.insert(key, value);
1681 self
1682 }
1683 #[doc = "Return human readable values for statistics."]
1684 pub fn human(mut self, human: bool) -> Self {
1685 self.human = Some(human);
1686 self
1687 }
1688 #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
1689 pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
1690 self.ignore_unavailable = Some(ignore_unavailable);
1691 self
1692 }
1693 #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
1694 pub fn lenient(mut self, lenient: bool) -> Self {
1695 self.lenient = Some(lenient);
1696 self
1697 }
1698 #[doc = "Maximum number of documents to process (default: all documents)"]
1699 pub fn max_docs(mut self, max_docs: i64) -> Self {
1700 self.max_docs = Some(max_docs);
1701 self
1702 }
1703 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
1704 pub fn preference(mut self, preference: &'b str) -> Self {
1705 self.preference = Some(preference);
1706 self
1707 }
1708 #[doc = "Pretty format the returned JSON response."]
1709 pub fn pretty(mut self, pretty: bool) -> Self {
1710 self.pretty = Some(pretty);
1711 self
1712 }
1713 #[doc = "Query in the Lucene query string syntax"]
1714 pub fn q(mut self, q: &'b str) -> Self {
1715 self.q = Some(q);
1716 self
1717 }
1718 #[doc = "Should the affected indexes be refreshed?"]
1719 pub fn refresh(mut self, refresh: bool) -> Self {
1720 self.refresh = Some(refresh);
1721 self
1722 }
1723 #[doc = "Specify if request cache should be used for this request or not, defaults to index level setting"]
1724 pub fn request_cache(mut self, request_cache: bool) -> Self {
1725 self.request_cache = Some(request_cache);
1726 self
1727 }
1728 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
1729 pub fn request_timeout(mut self, timeout: Duration) -> Self {
1730 self.request_timeout = Some(timeout);
1731 self
1732 }
1733 #[doc = "The throttle for this request in sub-requests per second. -1 means no throttle."]
1734 pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
1735 self.requests_per_second = Some(requests_per_second);
1736 self
1737 }
1738 #[doc = "A comma-separated list of specific routing values"]
1739 pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
1740 self.routing = Some(routing);
1741 self
1742 }
1743 #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
1744 pub fn scroll(mut self, scroll: &'b str) -> Self {
1745 self.scroll = Some(scroll);
1746 self
1747 }
1748 #[doc = "Size on the scroll request powering the delete by query"]
1749 pub fn scroll_size(mut self, scroll_size: i64) -> Self {
1750 self.scroll_size = Some(scroll_size);
1751 self
1752 }
1753 #[doc = "Explicit timeout for each search request. Defaults to no timeout."]
1754 pub fn search_timeout(mut self, search_timeout: &'b str) -> Self {
1755 self.search_timeout = Some(search_timeout);
1756 self
1757 }
1758 #[doc = "Search operation type"]
1759 pub fn search_type(mut self, search_type: SearchType) -> Self {
1760 self.search_type = Some(search_type);
1761 self
1762 }
1763 #[doc = "The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`."]
1764 pub fn slices(mut self, slices: Slices) -> Self {
1765 self.slices = Some(slices);
1766 self
1767 }
1768 #[doc = "A comma-separated list of <field>:<direction> pairs"]
1769 pub fn sort(mut self, sort: &'b [&'b str]) -> Self {
1770 self.sort = Some(sort);
1771 self
1772 }
1773 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
1774 pub fn source(mut self, source: &'b str) -> Self {
1775 self.source = Some(source);
1776 self
1777 }
1778 #[doc = "Specific 'tag' of the request for logging and statistical purposes"]
1779 pub fn stats(mut self, stats: &'b [&'b str]) -> Self {
1780 self.stats = Some(stats);
1781 self
1782 }
1783 #[doc = "The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early."]
1784 pub fn terminate_after(mut self, terminate_after: i64) -> Self {
1785 self.terminate_after = Some(terminate_after);
1786 self
1787 }
1788 #[doc = "Time each individual bulk request should wait for shards that are unavailable."]
1789 pub fn timeout(mut self, timeout: &'b str) -> Self {
1790 self.timeout = Some(timeout);
1791 self
1792 }
1793 #[doc = "Specify whether to return document version as part of a hit"]
1794 pub fn version(mut self, version: bool) -> Self {
1795 self.version = Some(version);
1796 self
1797 }
1798 #[doc = "Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"]
1799 pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
1800 self.wait_for_active_shards = Some(wait_for_active_shards);
1801 self
1802 }
1803 #[doc = "Should the request should block until the delete by query is complete."]
1804 pub fn wait_for_completion(mut self, wait_for_completion: bool) -> Self {
1805 self.wait_for_completion = Some(wait_for_completion);
1806 self
1807 }
1808 #[doc = "Creates an asynchronous call to the Delete By Query API that can be awaited"]
1809 pub async fn send(self) -> Result<Response, Error> {
1810 let path = self.parts.url();
1811 let method = http::Method::Post;
1812 let headers = self.headers;
1813 let timeout = self.request_timeout;
1814 let query_string = {
1815 #[serde_with::skip_serializing_none]
1816 #[derive(Serialize)]
1817 struct QueryParams<'b> {
1818 allow_no_indices: Option<bool>,
1819 analyze_wildcard: Option<bool>,
1820 analyzer: Option<&'b str>,
1821 conflicts: Option<Conflicts>,
1822 default_operator: Option<DefaultOperator>,
1823 df: Option<&'b str>,
1824 error_trace: Option<bool>,
1825 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1826 expand_wildcards: Option<&'b [ExpandWildcards]>,
1827 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1828 filter_path: Option<&'b [&'b str]>,
1829 from: Option<i64>,
1830 human: Option<bool>,
1831 ignore_unavailable: Option<bool>,
1832 lenient: Option<bool>,
1833 max_docs: Option<i64>,
1834 preference: Option<&'b str>,
1835 pretty: Option<bool>,
1836 q: Option<&'b str>,
1837 refresh: Option<bool>,
1838 request_cache: Option<bool>,
1839 requests_per_second: Option<i64>,
1840 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1841 routing: Option<&'b [&'b str]>,
1842 scroll: Option<&'b str>,
1843 scroll_size: Option<i64>,
1844 search_timeout: Option<&'b str>,
1845 search_type: Option<SearchType>,
1846 slices: Option<Slices>,
1847 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1848 sort: Option<&'b [&'b str]>,
1849 source: Option<&'b str>,
1850 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
1851 stats: Option<&'b [&'b str]>,
1852 terminate_after: Option<i64>,
1853 timeout: Option<&'b str>,
1854 version: Option<bool>,
1855 wait_for_active_shards: Option<&'b str>,
1856 wait_for_completion: Option<bool>,
1857 }
1858 let query_params = QueryParams {
1859 allow_no_indices: self.allow_no_indices,
1860 analyze_wildcard: self.analyze_wildcard,
1861 analyzer: self.analyzer,
1862 conflicts: self.conflicts,
1863 default_operator: self.default_operator,
1864 df: self.df,
1865 error_trace: self.error_trace,
1866 expand_wildcards: self.expand_wildcards,
1867 filter_path: self.filter_path,
1868 from: self.from,
1869 human: self.human,
1870 ignore_unavailable: self.ignore_unavailable,
1871 lenient: self.lenient,
1872 max_docs: self.max_docs,
1873 preference: self.preference,
1874 pretty: self.pretty,
1875 q: self.q,
1876 refresh: self.refresh,
1877 request_cache: self.request_cache,
1878 requests_per_second: self.requests_per_second,
1879 routing: self.routing,
1880 scroll: self.scroll,
1881 scroll_size: self.scroll_size,
1882 search_timeout: self.search_timeout,
1883 search_type: self.search_type,
1884 slices: self.slices,
1885 sort: self.sort,
1886 source: self.source,
1887 stats: self.stats,
1888 terminate_after: self.terminate_after,
1889 timeout: self.timeout,
1890 version: self.version,
1891 wait_for_active_shards: self.wait_for_active_shards,
1892 wait_for_completion: self.wait_for_completion,
1893 };
1894 Some(query_params)
1895 };
1896 let body = self.body;
1897 let response = self
1898 .transport
1899 .send(method, &path, headers, query_string.as_ref(), body, timeout)
1900 .await?;
1901 Ok(response)
1902 }
1903}
1904#[derive(Debug, Clone, PartialEq, Eq)]
1905#[doc = "API parts for the Delete By Query Rethrottle API"]
1906pub enum DeleteByQueryRethrottleParts<'b> {
1907 #[doc = "TaskId"]
1908 TaskId(&'b str),
1909}
1910impl<'b> DeleteByQueryRethrottleParts<'b> {
1911 #[doc = "Builds a relative URL path to the Delete By Query Rethrottle API"]
1912 pub fn url(self) -> Cow<'static, str> {
1913 match self {
1914 DeleteByQueryRethrottleParts::TaskId(task_id) => {
1915 let encoded_task_id: Cow<str> =
1916 percent_encode(task_id.as_bytes(), PARTS_ENCODED).into();
1917 let mut p = String::with_capacity(30usize + encoded_task_id.len());
1918 p.push_str("/_delete_by_query/");
1919 p.push_str(encoded_task_id.as_ref());
1920 p.push_str("/_rethrottle");
1921 p.into()
1922 }
1923 }
1924 }
1925}
1926#[doc = "Builder for the [Delete By Query Rethrottle API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-delete-by-query.html)\n\nChanges the number of requests per second for a particular Delete By Query operation."]
1927#[derive(Clone, Debug)]
1928pub struct DeleteByQueryRethrottle<'a, 'b, B> {
1929 transport: &'a Transport,
1930 parts: DeleteByQueryRethrottleParts<'b>,
1931 body: Option<B>,
1932 error_trace: Option<bool>,
1933 filter_path: Option<&'b [&'b str]>,
1934 headers: HeaderMap,
1935 human: Option<bool>,
1936 pretty: Option<bool>,
1937 request_timeout: Option<Duration>,
1938 requests_per_second: Option<i64>,
1939 source: Option<&'b str>,
1940}
1941impl<'a, 'b, B> DeleteByQueryRethrottle<'a, 'b, B>
1942where
1943 B: Body,
1944{
1945 #[doc = "Creates a new instance of [DeleteByQueryRethrottle] with the specified API parts"]
1946 pub fn new(transport: &'a Transport, parts: DeleteByQueryRethrottleParts<'b>) -> Self {
1947 let headers = HeaderMap::new();
1948 DeleteByQueryRethrottle {
1949 transport,
1950 parts,
1951 headers,
1952 body: None,
1953 error_trace: None,
1954 filter_path: None,
1955 human: None,
1956 pretty: None,
1957 request_timeout: None,
1958 requests_per_second: None,
1959 source: None,
1960 }
1961 }
1962 #[doc = "The body for the API call"]
1963 pub fn body<T>(self, body: T) -> DeleteByQueryRethrottle<'a, 'b, JsonBody<T>>
1964 where
1965 T: Serialize,
1966 {
1967 DeleteByQueryRethrottle {
1968 transport: self.transport,
1969 parts: self.parts,
1970 body: Some(body.into()),
1971 error_trace: self.error_trace,
1972 filter_path: self.filter_path,
1973 headers: self.headers,
1974 human: self.human,
1975 pretty: self.pretty,
1976 request_timeout: self.request_timeout,
1977 requests_per_second: self.requests_per_second,
1978 source: self.source,
1979 }
1980 }
1981 #[doc = "Include the stack trace of returned errors."]
1982 pub fn error_trace(mut self, error_trace: bool) -> Self {
1983 self.error_trace = Some(error_trace);
1984 self
1985 }
1986 #[doc = "A comma-separated list of filters used to reduce the response."]
1987 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
1988 self.filter_path = Some(filter_path);
1989 self
1990 }
1991 #[doc = "Adds a HTTP header"]
1992 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
1993 self.headers.insert(key, value);
1994 self
1995 }
1996 #[doc = "Return human readable values for statistics."]
1997 pub fn human(mut self, human: bool) -> Self {
1998 self.human = Some(human);
1999 self
2000 }
2001 #[doc = "Pretty format the returned JSON response."]
2002 pub fn pretty(mut self, pretty: bool) -> Self {
2003 self.pretty = Some(pretty);
2004 self
2005 }
2006 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
2007 pub fn request_timeout(mut self, timeout: Duration) -> Self {
2008 self.request_timeout = Some(timeout);
2009 self
2010 }
2011 #[doc = "The throttle to set on this request in floating sub-requests per second. -1 means set no throttle."]
2012 pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
2013 self.requests_per_second = Some(requests_per_second);
2014 self
2015 }
2016 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2017 pub fn source(mut self, source: &'b str) -> Self {
2018 self.source = Some(source);
2019 self
2020 }
2021 #[doc = "Creates an asynchronous call to the Delete By Query Rethrottle API that can be awaited"]
2022 pub async fn send(self) -> Result<Response, Error> {
2023 let path = self.parts.url();
2024 let method = http::Method::Post;
2025 let headers = self.headers;
2026 let timeout = self.request_timeout;
2027 let query_string = {
2028 #[serde_with::skip_serializing_none]
2029 #[derive(Serialize)]
2030 struct QueryParams<'b> {
2031 error_trace: Option<bool>,
2032 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2033 filter_path: Option<&'b [&'b str]>,
2034 human: Option<bool>,
2035 pretty: Option<bool>,
2036 requests_per_second: Option<i64>,
2037 source: Option<&'b str>,
2038 }
2039 let query_params = QueryParams {
2040 error_trace: self.error_trace,
2041 filter_path: self.filter_path,
2042 human: self.human,
2043 pretty: self.pretty,
2044 requests_per_second: self.requests_per_second,
2045 source: self.source,
2046 };
2047 Some(query_params)
2048 };
2049 let body = self.body;
2050 let response = self
2051 .transport
2052 .send(method, &path, headers, query_string.as_ref(), body, timeout)
2053 .await?;
2054 Ok(response)
2055 }
2056}
2057#[derive(Debug, Clone, PartialEq, Eq)]
2058#[doc = "API parts for the Delete Script API"]
2059pub enum DeleteScriptParts<'b> {
2060 #[doc = "Id"]
2061 Id(&'b str),
2062}
2063impl<'b> DeleteScriptParts<'b> {
2064 #[doc = "Builds a relative URL path to the Delete Script API"]
2065 pub fn url(self) -> Cow<'static, str> {
2066 match self {
2067 DeleteScriptParts::Id(id) => {
2068 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
2069 let mut p = String::with_capacity(10usize + encoded_id.len());
2070 p.push_str("/_scripts/");
2071 p.push_str(encoded_id.as_ref());
2072 p.into()
2073 }
2074 }
2075 }
2076}
2077#[doc = "Builder for the [Delete Script API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/modules-scripting.html)\n\nDeletes a script."]
2078#[derive(Clone, Debug)]
2079pub struct DeleteScript<'a, 'b> {
2080 transport: &'a Transport,
2081 parts: DeleteScriptParts<'b>,
2082 error_trace: Option<bool>,
2083 filter_path: Option<&'b [&'b str]>,
2084 headers: HeaderMap,
2085 human: Option<bool>,
2086 master_timeout: Option<&'b str>,
2087 pretty: Option<bool>,
2088 request_timeout: Option<Duration>,
2089 source: Option<&'b str>,
2090 timeout: Option<&'b str>,
2091}
2092impl<'a, 'b> DeleteScript<'a, 'b> {
2093 #[doc = "Creates a new instance of [DeleteScript] with the specified API parts"]
2094 pub fn new(transport: &'a Transport, parts: DeleteScriptParts<'b>) -> Self {
2095 let headers = HeaderMap::new();
2096 DeleteScript {
2097 transport,
2098 parts,
2099 headers,
2100 error_trace: None,
2101 filter_path: None,
2102 human: None,
2103 master_timeout: None,
2104 pretty: None,
2105 request_timeout: None,
2106 source: None,
2107 timeout: None,
2108 }
2109 }
2110 #[doc = "Include the stack trace of returned errors."]
2111 pub fn error_trace(mut self, error_trace: bool) -> Self {
2112 self.error_trace = Some(error_trace);
2113 self
2114 }
2115 #[doc = "A comma-separated list of filters used to reduce the response."]
2116 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2117 self.filter_path = Some(filter_path);
2118 self
2119 }
2120 #[doc = "Adds a HTTP header"]
2121 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2122 self.headers.insert(key, value);
2123 self
2124 }
2125 #[doc = "Return human readable values for statistics."]
2126 pub fn human(mut self, human: bool) -> Self {
2127 self.human = Some(human);
2128 self
2129 }
2130 #[doc = "Specify timeout for connection to master"]
2131 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
2132 self.master_timeout = Some(master_timeout);
2133 self
2134 }
2135 #[doc = "Pretty format the returned JSON response."]
2136 pub fn pretty(mut self, pretty: bool) -> Self {
2137 self.pretty = Some(pretty);
2138 self
2139 }
2140 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
2141 pub fn request_timeout(mut self, timeout: Duration) -> Self {
2142 self.request_timeout = Some(timeout);
2143 self
2144 }
2145 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2146 pub fn source(mut self, source: &'b str) -> Self {
2147 self.source = Some(source);
2148 self
2149 }
2150 #[doc = "Explicit operation timeout"]
2151 pub fn timeout(mut self, timeout: &'b str) -> Self {
2152 self.timeout = Some(timeout);
2153 self
2154 }
2155 #[doc = "Creates an asynchronous call to the Delete Script API that can be awaited"]
2156 pub async fn send(self) -> Result<Response, Error> {
2157 let path = self.parts.url();
2158 let method = http::Method::Delete;
2159 let headers = self.headers;
2160 let timeout = self.request_timeout;
2161 let query_string = {
2162 #[serde_with::skip_serializing_none]
2163 #[derive(Serialize)]
2164 struct QueryParams<'b> {
2165 error_trace: Option<bool>,
2166 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2167 filter_path: Option<&'b [&'b str]>,
2168 human: Option<bool>,
2169 master_timeout: Option<&'b str>,
2170 pretty: Option<bool>,
2171 source: Option<&'b str>,
2172 timeout: Option<&'b str>,
2173 }
2174 let query_params = QueryParams {
2175 error_trace: self.error_trace,
2176 filter_path: self.filter_path,
2177 human: self.human,
2178 master_timeout: self.master_timeout,
2179 pretty: self.pretty,
2180 source: self.source,
2181 timeout: self.timeout,
2182 };
2183 Some(query_params)
2184 };
2185 let body = Option::<()>::None;
2186 let response = self
2187 .transport
2188 .send(method, &path, headers, query_string.as_ref(), body, timeout)
2189 .await?;
2190 Ok(response)
2191 }
2192}
2193#[derive(Debug, Clone, PartialEq, Eq)]
2194#[doc = "API parts for the Exists API"]
2195pub enum ExistsParts<'b> {
2196 #[doc = "Index and Id"]
2197 IndexId(&'b str, &'b str),
2198}
2199impl<'b> ExistsParts<'b> {
2200 #[doc = "Builds a relative URL path to the Exists API"]
2201 pub fn url(self) -> Cow<'static, str> {
2202 match self {
2203 ExistsParts::IndexId(index, id) => {
2204 let encoded_index: Cow<str> =
2205 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
2206 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
2207 let mut p = String::with_capacity(7usize + encoded_index.len() + encoded_id.len());
2208 p.push('/');
2209 p.push_str(encoded_index.as_ref());
2210 p.push_str("/_doc/");
2211 p.push_str(encoded_id.as_ref());
2212 p.into()
2213 }
2214 }
2215 }
2216}
2217#[doc = "Builder for the [Exists API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-get.html)\n\nReturns information about whether a document exists in an index."]
2218#[derive(Clone, Debug)]
2219pub struct Exists<'a, 'b> {
2220 transport: &'a Transport,
2221 parts: ExistsParts<'b>,
2222 _source: Option<&'b [&'b str]>,
2223 _source_excludes: Option<&'b [&'b str]>,
2224 _source_includes: Option<&'b [&'b str]>,
2225 error_trace: Option<bool>,
2226 filter_path: Option<&'b [&'b str]>,
2227 headers: HeaderMap,
2228 human: Option<bool>,
2229 preference: Option<&'b str>,
2230 pretty: Option<bool>,
2231 realtime: Option<bool>,
2232 refresh: Option<bool>,
2233 request_timeout: Option<Duration>,
2234 routing: Option<&'b str>,
2235 source: Option<&'b str>,
2236 stored_fields: Option<&'b [&'b str]>,
2237 version: Option<i64>,
2238 version_type: Option<VersionType>,
2239}
2240impl<'a, 'b> Exists<'a, 'b> {
2241 #[doc = "Creates a new instance of [Exists] with the specified API parts"]
2242 pub fn new(transport: &'a Transport, parts: ExistsParts<'b>) -> Self {
2243 let headers = HeaderMap::new();
2244 Exists {
2245 transport,
2246 parts,
2247 headers,
2248 _source: None,
2249 _source_excludes: None,
2250 _source_includes: None,
2251 error_trace: None,
2252 filter_path: None,
2253 human: None,
2254 preference: None,
2255 pretty: None,
2256 realtime: None,
2257 refresh: None,
2258 request_timeout: None,
2259 routing: None,
2260 source: None,
2261 stored_fields: None,
2262 version: None,
2263 version_type: None,
2264 }
2265 }
2266 #[doc = "True or false to return the _source field or not, or a list of fields to return"]
2267 pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
2268 self._source = Some(_source);
2269 self
2270 }
2271 #[doc = "A list of fields to exclude from the returned _source field"]
2272 pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
2273 self._source_excludes = Some(_source_excludes);
2274 self
2275 }
2276 #[doc = "A list of fields to extract and return from the _source field"]
2277 pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
2278 self._source_includes = Some(_source_includes);
2279 self
2280 }
2281 #[doc = "Include the stack trace of returned errors."]
2282 pub fn error_trace(mut self, error_trace: bool) -> Self {
2283 self.error_trace = Some(error_trace);
2284 self
2285 }
2286 #[doc = "A comma-separated list of filters used to reduce the response."]
2287 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2288 self.filter_path = Some(filter_path);
2289 self
2290 }
2291 #[doc = "Adds a HTTP header"]
2292 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2293 self.headers.insert(key, value);
2294 self
2295 }
2296 #[doc = "Return human readable values for statistics."]
2297 pub fn human(mut self, human: bool) -> Self {
2298 self.human = Some(human);
2299 self
2300 }
2301 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
2302 pub fn preference(mut self, preference: &'b str) -> Self {
2303 self.preference = Some(preference);
2304 self
2305 }
2306 #[doc = "Pretty format the returned JSON response."]
2307 pub fn pretty(mut self, pretty: bool) -> Self {
2308 self.pretty = Some(pretty);
2309 self
2310 }
2311 #[doc = "Specify whether to perform the operation in realtime or search mode"]
2312 pub fn realtime(mut self, realtime: bool) -> Self {
2313 self.realtime = Some(realtime);
2314 self
2315 }
2316 #[doc = "Refresh the shard containing the document before performing the operation"]
2317 pub fn refresh(mut self, refresh: bool) -> Self {
2318 self.refresh = Some(refresh);
2319 self
2320 }
2321 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
2322 pub fn request_timeout(mut self, timeout: Duration) -> Self {
2323 self.request_timeout = Some(timeout);
2324 self
2325 }
2326 #[doc = "Specific routing value"]
2327 pub fn routing(mut self, routing: &'b str) -> Self {
2328 self.routing = Some(routing);
2329 self
2330 }
2331 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2332 pub fn source(mut self, source: &'b str) -> Self {
2333 self.source = Some(source);
2334 self
2335 }
2336 #[doc = "A comma-separated list of stored fields to return in the response"]
2337 pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
2338 self.stored_fields = Some(stored_fields);
2339 self
2340 }
2341 #[doc = "Explicit version number for concurrency control"]
2342 pub fn version(mut self, version: i64) -> Self {
2343 self.version = Some(version);
2344 self
2345 }
2346 #[doc = "Specific version type"]
2347 pub fn version_type(mut self, version_type: VersionType) -> Self {
2348 self.version_type = Some(version_type);
2349 self
2350 }
2351 #[doc = "Creates an asynchronous call to the Exists API that can be awaited"]
2352 pub async fn send(self) -> Result<Response, Error> {
2353 let path = self.parts.url();
2354 let method = http::Method::Head;
2355 let headers = self.headers;
2356 let timeout = self.request_timeout;
2357 let query_string = {
2358 #[serde_with::skip_serializing_none]
2359 #[derive(Serialize)]
2360 struct QueryParams<'b> {
2361 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2362 _source: Option<&'b [&'b str]>,
2363 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2364 _source_excludes: Option<&'b [&'b str]>,
2365 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2366 _source_includes: Option<&'b [&'b str]>,
2367 error_trace: Option<bool>,
2368 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2369 filter_path: Option<&'b [&'b str]>,
2370 human: Option<bool>,
2371 preference: Option<&'b str>,
2372 pretty: Option<bool>,
2373 realtime: Option<bool>,
2374 refresh: Option<bool>,
2375 routing: Option<&'b str>,
2376 source: Option<&'b str>,
2377 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2378 stored_fields: Option<&'b [&'b str]>,
2379 version: Option<i64>,
2380 version_type: Option<VersionType>,
2381 }
2382 let query_params = QueryParams {
2383 _source: self._source,
2384 _source_excludes: self._source_excludes,
2385 _source_includes: self._source_includes,
2386 error_trace: self.error_trace,
2387 filter_path: self.filter_path,
2388 human: self.human,
2389 preference: self.preference,
2390 pretty: self.pretty,
2391 realtime: self.realtime,
2392 refresh: self.refresh,
2393 routing: self.routing,
2394 source: self.source,
2395 stored_fields: self.stored_fields,
2396 version: self.version,
2397 version_type: self.version_type,
2398 };
2399 Some(query_params)
2400 };
2401 let body = Option::<()>::None;
2402 let response = self
2403 .transport
2404 .send(method, &path, headers, query_string.as_ref(), body, timeout)
2405 .await?;
2406 Ok(response)
2407 }
2408}
2409#[derive(Debug, Clone, PartialEq, Eq)]
2410#[doc = "API parts for the Exists Source API"]
2411pub enum ExistsSourceParts<'b> {
2412 #[doc = "Index and Id"]
2413 IndexId(&'b str, &'b str),
2414}
2415impl<'b> ExistsSourceParts<'b> {
2416 #[doc = "Builds a relative URL path to the Exists Source API"]
2417 pub fn url(self) -> Cow<'static, str> {
2418 match self {
2419 ExistsSourceParts::IndexId(index, id) => {
2420 let encoded_index: Cow<str> =
2421 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
2422 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
2423 let mut p = String::with_capacity(10usize + encoded_index.len() + encoded_id.len());
2424 p.push('/');
2425 p.push_str(encoded_index.as_ref());
2426 p.push_str("/_source/");
2427 p.push_str(encoded_id.as_ref());
2428 p.into()
2429 }
2430 }
2431 }
2432}
2433#[doc = "Builder for the [Exists Source API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-get.html)\n\nReturns information about whether a document source exists in an index."]
2434#[derive(Clone, Debug)]
2435pub struct ExistsSource<'a, 'b> {
2436 transport: &'a Transport,
2437 parts: ExistsSourceParts<'b>,
2438 _source: Option<&'b [&'b str]>,
2439 _source_excludes: Option<&'b [&'b str]>,
2440 _source_includes: Option<&'b [&'b str]>,
2441 error_trace: Option<bool>,
2442 filter_path: Option<&'b [&'b str]>,
2443 headers: HeaderMap,
2444 human: Option<bool>,
2445 preference: Option<&'b str>,
2446 pretty: Option<bool>,
2447 realtime: Option<bool>,
2448 refresh: Option<bool>,
2449 request_timeout: Option<Duration>,
2450 routing: Option<&'b str>,
2451 source: Option<&'b str>,
2452 version: Option<i64>,
2453 version_type: Option<VersionType>,
2454}
2455impl<'a, 'b> ExistsSource<'a, 'b> {
2456 #[doc = "Creates a new instance of [ExistsSource] with the specified API parts"]
2457 pub fn new(transport: &'a Transport, parts: ExistsSourceParts<'b>) -> Self {
2458 let headers = HeaderMap::new();
2459 ExistsSource {
2460 transport,
2461 parts,
2462 headers,
2463 _source: None,
2464 _source_excludes: None,
2465 _source_includes: None,
2466 error_trace: None,
2467 filter_path: None,
2468 human: None,
2469 preference: None,
2470 pretty: None,
2471 realtime: None,
2472 refresh: None,
2473 request_timeout: None,
2474 routing: None,
2475 source: None,
2476 version: None,
2477 version_type: None,
2478 }
2479 }
2480 #[doc = "True or false to return the _source field or not, or a list of fields to return"]
2481 pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
2482 self._source = Some(_source);
2483 self
2484 }
2485 #[doc = "A list of fields to exclude from the returned _source field"]
2486 pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
2487 self._source_excludes = Some(_source_excludes);
2488 self
2489 }
2490 #[doc = "A list of fields to extract and return from the _source field"]
2491 pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
2492 self._source_includes = Some(_source_includes);
2493 self
2494 }
2495 #[doc = "Include the stack trace of returned errors."]
2496 pub fn error_trace(mut self, error_trace: bool) -> Self {
2497 self.error_trace = Some(error_trace);
2498 self
2499 }
2500 #[doc = "A comma-separated list of filters used to reduce the response."]
2501 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2502 self.filter_path = Some(filter_path);
2503 self
2504 }
2505 #[doc = "Adds a HTTP header"]
2506 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2507 self.headers.insert(key, value);
2508 self
2509 }
2510 #[doc = "Return human readable values for statistics."]
2511 pub fn human(mut self, human: bool) -> Self {
2512 self.human = Some(human);
2513 self
2514 }
2515 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
2516 pub fn preference(mut self, preference: &'b str) -> Self {
2517 self.preference = Some(preference);
2518 self
2519 }
2520 #[doc = "Pretty format the returned JSON response."]
2521 pub fn pretty(mut self, pretty: bool) -> Self {
2522 self.pretty = Some(pretty);
2523 self
2524 }
2525 #[doc = "Specify whether to perform the operation in realtime or search mode"]
2526 pub fn realtime(mut self, realtime: bool) -> Self {
2527 self.realtime = Some(realtime);
2528 self
2529 }
2530 #[doc = "Refresh the shard containing the document before performing the operation"]
2531 pub fn refresh(mut self, refresh: bool) -> Self {
2532 self.refresh = Some(refresh);
2533 self
2534 }
2535 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
2536 pub fn request_timeout(mut self, timeout: Duration) -> Self {
2537 self.request_timeout = Some(timeout);
2538 self
2539 }
2540 #[doc = "Specific routing value"]
2541 pub fn routing(mut self, routing: &'b str) -> Self {
2542 self.routing = Some(routing);
2543 self
2544 }
2545 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2546 pub fn source(mut self, source: &'b str) -> Self {
2547 self.source = Some(source);
2548 self
2549 }
2550 #[doc = "Explicit version number for concurrency control"]
2551 pub fn version(mut self, version: i64) -> Self {
2552 self.version = Some(version);
2553 self
2554 }
2555 #[doc = "Specific version type"]
2556 pub fn version_type(mut self, version_type: VersionType) -> Self {
2557 self.version_type = Some(version_type);
2558 self
2559 }
2560 #[doc = "Creates an asynchronous call to the Exists Source API that can be awaited"]
2561 pub async fn send(self) -> Result<Response, Error> {
2562 let path = self.parts.url();
2563 let method = http::Method::Head;
2564 let headers = self.headers;
2565 let timeout = self.request_timeout;
2566 let query_string = {
2567 #[serde_with::skip_serializing_none]
2568 #[derive(Serialize)]
2569 struct QueryParams<'b> {
2570 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2571 _source: Option<&'b [&'b str]>,
2572 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2573 _source_excludes: Option<&'b [&'b str]>,
2574 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2575 _source_includes: Option<&'b [&'b str]>,
2576 error_trace: Option<bool>,
2577 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2578 filter_path: Option<&'b [&'b str]>,
2579 human: Option<bool>,
2580 preference: Option<&'b str>,
2581 pretty: Option<bool>,
2582 realtime: Option<bool>,
2583 refresh: Option<bool>,
2584 routing: Option<&'b str>,
2585 source: Option<&'b str>,
2586 version: Option<i64>,
2587 version_type: Option<VersionType>,
2588 }
2589 let query_params = QueryParams {
2590 _source: self._source,
2591 _source_excludes: self._source_excludes,
2592 _source_includes: self._source_includes,
2593 error_trace: self.error_trace,
2594 filter_path: self.filter_path,
2595 human: self.human,
2596 preference: self.preference,
2597 pretty: self.pretty,
2598 realtime: self.realtime,
2599 refresh: self.refresh,
2600 routing: self.routing,
2601 source: self.source,
2602 version: self.version,
2603 version_type: self.version_type,
2604 };
2605 Some(query_params)
2606 };
2607 let body = Option::<()>::None;
2608 let response = self
2609 .transport
2610 .send(method, &path, headers, query_string.as_ref(), body, timeout)
2611 .await?;
2612 Ok(response)
2613 }
2614}
2615#[derive(Debug, Clone, PartialEq, Eq)]
2616#[doc = "API parts for the Explain API"]
2617pub enum ExplainParts<'b> {
2618 #[doc = "Index and Id"]
2619 IndexId(&'b str, &'b str),
2620}
2621impl<'b> ExplainParts<'b> {
2622 #[doc = "Builds a relative URL path to the Explain API"]
2623 pub fn url(self) -> Cow<'static, str> {
2624 match self {
2625 ExplainParts::IndexId(index, id) => {
2626 let encoded_index: Cow<str> =
2627 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
2628 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
2629 let mut p = String::with_capacity(11usize + encoded_index.len() + encoded_id.len());
2630 p.push('/');
2631 p.push_str(encoded_index.as_ref());
2632 p.push_str("/_explain/");
2633 p.push_str(encoded_id.as_ref());
2634 p.into()
2635 }
2636 }
2637 }
2638}
2639#[doc = "Builder for the [Explain API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-explain.html)\n\nReturns information about why a specific matches (or doesn't match) a query."]
2640#[derive(Clone, Debug)]
2641pub struct Explain<'a, 'b, B> {
2642 transport: &'a Transport,
2643 parts: ExplainParts<'b>,
2644 _source: Option<&'b [&'b str]>,
2645 _source_excludes: Option<&'b [&'b str]>,
2646 _source_includes: Option<&'b [&'b str]>,
2647 analyze_wildcard: Option<bool>,
2648 analyzer: Option<&'b str>,
2649 body: Option<B>,
2650 default_operator: Option<DefaultOperator>,
2651 df: Option<&'b str>,
2652 error_trace: Option<bool>,
2653 filter_path: Option<&'b [&'b str]>,
2654 headers: HeaderMap,
2655 human: Option<bool>,
2656 lenient: Option<bool>,
2657 preference: Option<&'b str>,
2658 pretty: Option<bool>,
2659 q: Option<&'b str>,
2660 request_timeout: Option<Duration>,
2661 routing: Option<&'b str>,
2662 source: Option<&'b str>,
2663 stored_fields: Option<&'b [&'b str]>,
2664}
2665impl<'a, 'b, B> Explain<'a, 'b, B>
2666where
2667 B: Body,
2668{
2669 #[doc = "Creates a new instance of [Explain] with the specified API parts"]
2670 pub fn new(transport: &'a Transport, parts: ExplainParts<'b>) -> Self {
2671 let headers = HeaderMap::new();
2672 Explain {
2673 transport,
2674 parts,
2675 headers,
2676 _source: None,
2677 _source_excludes: None,
2678 _source_includes: None,
2679 analyze_wildcard: None,
2680 analyzer: None,
2681 body: None,
2682 default_operator: None,
2683 df: None,
2684 error_trace: None,
2685 filter_path: None,
2686 human: None,
2687 lenient: None,
2688 preference: None,
2689 pretty: None,
2690 q: None,
2691 request_timeout: None,
2692 routing: None,
2693 source: None,
2694 stored_fields: None,
2695 }
2696 }
2697 #[doc = "True or false to return the _source field or not, or a list of fields to return"]
2698 pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
2699 self._source = Some(_source);
2700 self
2701 }
2702 #[doc = "A list of fields to exclude from the returned _source field"]
2703 pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
2704 self._source_excludes = Some(_source_excludes);
2705 self
2706 }
2707 #[doc = "A list of fields to extract and return from the _source field"]
2708 pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
2709 self._source_includes = Some(_source_includes);
2710 self
2711 }
2712 #[doc = "Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)"]
2713 pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
2714 self.analyze_wildcard = Some(analyze_wildcard);
2715 self
2716 }
2717 #[doc = "The analyzer for the query string query"]
2718 pub fn analyzer(mut self, analyzer: &'b str) -> Self {
2719 self.analyzer = Some(analyzer);
2720 self
2721 }
2722 #[doc = "The body for the API call"]
2723 pub fn body<T>(self, body: T) -> Explain<'a, 'b, JsonBody<T>>
2724 where
2725 T: Serialize,
2726 {
2727 Explain {
2728 transport: self.transport,
2729 parts: self.parts,
2730 body: Some(body.into()),
2731 _source: self._source,
2732 _source_excludes: self._source_excludes,
2733 _source_includes: self._source_includes,
2734 analyze_wildcard: self.analyze_wildcard,
2735 analyzer: self.analyzer,
2736 default_operator: self.default_operator,
2737 df: self.df,
2738 error_trace: self.error_trace,
2739 filter_path: self.filter_path,
2740 headers: self.headers,
2741 human: self.human,
2742 lenient: self.lenient,
2743 preference: self.preference,
2744 pretty: self.pretty,
2745 q: self.q,
2746 request_timeout: self.request_timeout,
2747 routing: self.routing,
2748 source: self.source,
2749 stored_fields: self.stored_fields,
2750 }
2751 }
2752 #[doc = "The default operator for query string query (AND or OR)"]
2753 pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
2754 self.default_operator = Some(default_operator);
2755 self
2756 }
2757 #[doc = "The default field for query string query (default: _all)"]
2758 pub fn df(mut self, df: &'b str) -> Self {
2759 self.df = Some(df);
2760 self
2761 }
2762 #[doc = "Include the stack trace of returned errors."]
2763 pub fn error_trace(mut self, error_trace: bool) -> Self {
2764 self.error_trace = Some(error_trace);
2765 self
2766 }
2767 #[doc = "A comma-separated list of filters used to reduce the response."]
2768 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
2769 self.filter_path = Some(filter_path);
2770 self
2771 }
2772 #[doc = "Adds a HTTP header"]
2773 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
2774 self.headers.insert(key, value);
2775 self
2776 }
2777 #[doc = "Return human readable values for statistics."]
2778 pub fn human(mut self, human: bool) -> Self {
2779 self.human = Some(human);
2780 self
2781 }
2782 #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
2783 pub fn lenient(mut self, lenient: bool) -> Self {
2784 self.lenient = Some(lenient);
2785 self
2786 }
2787 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
2788 pub fn preference(mut self, preference: &'b str) -> Self {
2789 self.preference = Some(preference);
2790 self
2791 }
2792 #[doc = "Pretty format the returned JSON response."]
2793 pub fn pretty(mut self, pretty: bool) -> Self {
2794 self.pretty = Some(pretty);
2795 self
2796 }
2797 #[doc = "Query in the Lucene query string syntax"]
2798 pub fn q(mut self, q: &'b str) -> Self {
2799 self.q = Some(q);
2800 self
2801 }
2802 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
2803 pub fn request_timeout(mut self, timeout: Duration) -> Self {
2804 self.request_timeout = Some(timeout);
2805 self
2806 }
2807 #[doc = "Specific routing value"]
2808 pub fn routing(mut self, routing: &'b str) -> Self {
2809 self.routing = Some(routing);
2810 self
2811 }
2812 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
2813 pub fn source(mut self, source: &'b str) -> Self {
2814 self.source = Some(source);
2815 self
2816 }
2817 #[doc = "A comma-separated list of stored fields to return in the response"]
2818 pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
2819 self.stored_fields = Some(stored_fields);
2820 self
2821 }
2822 #[doc = "Creates an asynchronous call to the Explain API that can be awaited"]
2823 pub async fn send(self) -> Result<Response, Error> {
2824 let path = self.parts.url();
2825 let method = match self.body {
2826 Some(_) => http::Method::Post,
2827 None => http::Method::Get,
2828 };
2829 let headers = self.headers;
2830 let timeout = self.request_timeout;
2831 let query_string = {
2832 #[serde_with::skip_serializing_none]
2833 #[derive(Serialize)]
2834 struct QueryParams<'b> {
2835 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2836 _source: Option<&'b [&'b str]>,
2837 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2838 _source_excludes: Option<&'b [&'b str]>,
2839 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2840 _source_includes: Option<&'b [&'b str]>,
2841 analyze_wildcard: Option<bool>,
2842 analyzer: Option<&'b str>,
2843 default_operator: Option<DefaultOperator>,
2844 df: Option<&'b str>,
2845 error_trace: Option<bool>,
2846 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2847 filter_path: Option<&'b [&'b str]>,
2848 human: Option<bool>,
2849 lenient: Option<bool>,
2850 preference: Option<&'b str>,
2851 pretty: Option<bool>,
2852 q: Option<&'b str>,
2853 routing: Option<&'b str>,
2854 source: Option<&'b str>,
2855 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
2856 stored_fields: Option<&'b [&'b str]>,
2857 }
2858 let query_params = QueryParams {
2859 _source: self._source,
2860 _source_excludes: self._source_excludes,
2861 _source_includes: self._source_includes,
2862 analyze_wildcard: self.analyze_wildcard,
2863 analyzer: self.analyzer,
2864 default_operator: self.default_operator,
2865 df: self.df,
2866 error_trace: self.error_trace,
2867 filter_path: self.filter_path,
2868 human: self.human,
2869 lenient: self.lenient,
2870 preference: self.preference,
2871 pretty: self.pretty,
2872 q: self.q,
2873 routing: self.routing,
2874 source: self.source,
2875 stored_fields: self.stored_fields,
2876 };
2877 Some(query_params)
2878 };
2879 let body = self.body;
2880 let response = self
2881 .transport
2882 .send(method, &path, headers, query_string.as_ref(), body, timeout)
2883 .await?;
2884 Ok(response)
2885 }
2886}
2887#[derive(Debug, Clone, PartialEq, Eq)]
2888#[doc = "API parts for the Field Caps API"]
2889pub enum FieldCapsParts<'b> {
2890 #[doc = "No parts"]
2891 None,
2892 #[doc = "Index"]
2893 Index(&'b [&'b str]),
2894}
2895impl<'b> FieldCapsParts<'b> {
2896 #[doc = "Builds a relative URL path to the Field Caps API"]
2897 pub fn url(self) -> Cow<'static, str> {
2898 match self {
2899 FieldCapsParts::None => "/_field_caps".into(),
2900 FieldCapsParts::Index(index) => {
2901 let index_str = index.join(",");
2902 let encoded_index: Cow<str> =
2903 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
2904 let mut p = String::with_capacity(13usize + encoded_index.len());
2905 p.push('/');
2906 p.push_str(encoded_index.as_ref());
2907 p.push_str("/_field_caps");
2908 p.into()
2909 }
2910 }
2911 }
2912}
2913#[doc = "Builder for the [Field Caps API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-field-caps.html)\n\nReturns the information about the capabilities of fields among multiple indices."]
2914#[derive(Clone, Debug)]
2915pub struct FieldCaps<'a, 'b, B> {
2916 transport: &'a Transport,
2917 parts: FieldCapsParts<'b>,
2918 allow_no_indices: Option<bool>,
2919 body: Option<B>,
2920 error_trace: Option<bool>,
2921 expand_wildcards: Option<&'b [ExpandWildcards]>,
2922 fields: Option<&'b [&'b str]>,
2923 filter_path: Option<&'b [&'b str]>,
2924 filters: Option<&'b [&'b str]>,
2925 headers: HeaderMap,
2926 human: Option<bool>,
2927 ignore_unavailable: Option<bool>,
2928 include_empty_fields: Option<bool>,
2929 include_unmapped: Option<bool>,
2930 pretty: Option<bool>,
2931 request_timeout: Option<Duration>,
2932 source: Option<&'b str>,
2933 types: Option<&'b [&'b str]>,
2934}
2935impl<'a, 'b, B> FieldCaps<'a, 'b, B>
2936where
2937 B: Body,
2938{
2939 #[doc = "Creates a new instance of [FieldCaps] with the specified API parts"]
2940 pub fn new(transport: &'a Transport, parts: FieldCapsParts<'b>) -> Self {
2941 let headers = HeaderMap::new();
2942 FieldCaps {
2943 transport,
2944 parts,
2945 headers,
2946 allow_no_indices: None,
2947 body: None,
2948 error_trace: None,
2949 expand_wildcards: None,
2950 fields: None,
2951 filter_path: None,
2952 filters: None,
2953 human: None,
2954 ignore_unavailable: None,
2955 include_empty_fields: None,
2956 include_unmapped: None,
2957 pretty: None,
2958 request_timeout: None,
2959 source: None,
2960 types: None,
2961 }
2962 }
2963 #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
2964 pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
2965 self.allow_no_indices = Some(allow_no_indices);
2966 self
2967 }
2968 #[doc = "The body for the API call"]
2969 pub fn body<T>(self, body: T) -> FieldCaps<'a, 'b, JsonBody<T>>
2970 where
2971 T: Serialize,
2972 {
2973 FieldCaps {
2974 transport: self.transport,
2975 parts: self.parts,
2976 body: Some(body.into()),
2977 allow_no_indices: self.allow_no_indices,
2978 error_trace: self.error_trace,
2979 expand_wildcards: self.expand_wildcards,
2980 fields: self.fields,
2981 filter_path: self.filter_path,
2982 filters: self.filters,
2983 headers: self.headers,
2984 human: self.human,
2985 ignore_unavailable: self.ignore_unavailable,
2986 include_empty_fields: self.include_empty_fields,
2987 include_unmapped: self.include_unmapped,
2988 pretty: self.pretty,
2989 request_timeout: self.request_timeout,
2990 source: self.source,
2991 types: self.types,
2992 }
2993 }
2994 #[doc = "Include the stack trace of returned errors."]
2995 pub fn error_trace(mut self, error_trace: bool) -> Self {
2996 self.error_trace = Some(error_trace);
2997 self
2998 }
2999 #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
3000 pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
3001 self.expand_wildcards = Some(expand_wildcards);
3002 self
3003 }
3004 #[doc = "A comma-separated list of field names"]
3005 pub fn fields(mut self, fields: &'b [&'b str]) -> Self {
3006 self.fields = Some(fields);
3007 self
3008 }
3009 #[doc = "A comma-separated list of filters used to reduce the response."]
3010 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3011 self.filter_path = Some(filter_path);
3012 self
3013 }
3014 #[doc = "An optional set of filters: can include +metadata,-metadata,-nested,-multifield,-parent"]
3015 pub fn filters(mut self, filters: &'b [&'b str]) -> Self {
3016 self.filters = Some(filters);
3017 self
3018 }
3019 #[doc = "Adds a HTTP header"]
3020 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3021 self.headers.insert(key, value);
3022 self
3023 }
3024 #[doc = "Return human readable values for statistics."]
3025 pub fn human(mut self, human: bool) -> Self {
3026 self.human = Some(human);
3027 self
3028 }
3029 #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
3030 pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
3031 self.ignore_unavailable = Some(ignore_unavailable);
3032 self
3033 }
3034 #[doc = "Include empty fields in result"]
3035 pub fn include_empty_fields(mut self, include_empty_fields: bool) -> Self {
3036 self.include_empty_fields = Some(include_empty_fields);
3037 self
3038 }
3039 #[doc = "Indicates whether unmapped fields should be included in the response."]
3040 pub fn include_unmapped(mut self, include_unmapped: bool) -> Self {
3041 self.include_unmapped = Some(include_unmapped);
3042 self
3043 }
3044 #[doc = "Pretty format the returned JSON response."]
3045 pub fn pretty(mut self, pretty: bool) -> Self {
3046 self.pretty = Some(pretty);
3047 self
3048 }
3049 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
3050 pub fn request_timeout(mut self, timeout: Duration) -> Self {
3051 self.request_timeout = Some(timeout);
3052 self
3053 }
3054 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3055 pub fn source(mut self, source: &'b str) -> Self {
3056 self.source = Some(source);
3057 self
3058 }
3059 #[doc = "Only return results for fields that have one of the types in the list"]
3060 pub fn types(mut self, types: &'b [&'b str]) -> Self {
3061 self.types = Some(types);
3062 self
3063 }
3064 #[doc = "Creates an asynchronous call to the Field Caps API that can be awaited"]
3065 pub async fn send(self) -> Result<Response, Error> {
3066 let path = self.parts.url();
3067 let method = match self.body {
3068 Some(_) => http::Method::Post,
3069 None => http::Method::Get,
3070 };
3071 let headers = self.headers;
3072 let timeout = self.request_timeout;
3073 let query_string = {
3074 #[serde_with::skip_serializing_none]
3075 #[derive(Serialize)]
3076 struct QueryParams<'b> {
3077 allow_no_indices: Option<bool>,
3078 error_trace: Option<bool>,
3079 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3080 expand_wildcards: Option<&'b [ExpandWildcards]>,
3081 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3082 fields: Option<&'b [&'b str]>,
3083 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3084 filter_path: Option<&'b [&'b str]>,
3085 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3086 filters: Option<&'b [&'b str]>,
3087 human: Option<bool>,
3088 ignore_unavailable: Option<bool>,
3089 include_empty_fields: Option<bool>,
3090 include_unmapped: Option<bool>,
3091 pretty: Option<bool>,
3092 source: Option<&'b str>,
3093 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3094 types: Option<&'b [&'b str]>,
3095 }
3096 let query_params = QueryParams {
3097 allow_no_indices: self.allow_no_indices,
3098 error_trace: self.error_trace,
3099 expand_wildcards: self.expand_wildcards,
3100 fields: self.fields,
3101 filter_path: self.filter_path,
3102 filters: self.filters,
3103 human: self.human,
3104 ignore_unavailable: self.ignore_unavailable,
3105 include_empty_fields: self.include_empty_fields,
3106 include_unmapped: self.include_unmapped,
3107 pretty: self.pretty,
3108 source: self.source,
3109 types: self.types,
3110 };
3111 Some(query_params)
3112 };
3113 let body = self.body;
3114 let response = self
3115 .transport
3116 .send(method, &path, headers, query_string.as_ref(), body, timeout)
3117 .await?;
3118 Ok(response)
3119 }
3120}
3121#[derive(Debug, Clone, PartialEq, Eq)]
3122#[doc = "API parts for the Get API"]
3123pub enum GetParts<'b> {
3124 #[doc = "Index and Id"]
3125 IndexId(&'b str, &'b str),
3126}
3127impl<'b> GetParts<'b> {
3128 #[doc = "Builds a relative URL path to the Get API"]
3129 pub fn url(self) -> Cow<'static, str> {
3130 match self {
3131 GetParts::IndexId(index, id) => {
3132 let encoded_index: Cow<str> =
3133 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
3134 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
3135 let mut p = String::with_capacity(7usize + encoded_index.len() + encoded_id.len());
3136 p.push('/');
3137 p.push_str(encoded_index.as_ref());
3138 p.push_str("/_doc/");
3139 p.push_str(encoded_id.as_ref());
3140 p.into()
3141 }
3142 }
3143 }
3144}
3145#[doc = "Builder for the [Get API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-get.html)\n\nReturns a document."]
3146#[derive(Clone, Debug)]
3147pub struct Get<'a, 'b> {
3148 transport: &'a Transport,
3149 parts: GetParts<'b>,
3150 _source: Option<&'b [&'b str]>,
3151 _source_excludes: Option<&'b [&'b str]>,
3152 _source_includes: Option<&'b [&'b str]>,
3153 error_trace: Option<bool>,
3154 filter_path: Option<&'b [&'b str]>,
3155 force_synthetic_source: Option<bool>,
3156 headers: HeaderMap,
3157 human: Option<bool>,
3158 preference: Option<&'b str>,
3159 pretty: Option<bool>,
3160 realtime: Option<bool>,
3161 refresh: Option<bool>,
3162 request_timeout: Option<Duration>,
3163 routing: Option<&'b str>,
3164 source: Option<&'b str>,
3165 stored_fields: Option<&'b [&'b str]>,
3166 version: Option<i64>,
3167 version_type: Option<VersionType>,
3168}
3169impl<'a, 'b> Get<'a, 'b> {
3170 #[doc = "Creates a new instance of [Get] with the specified API parts"]
3171 pub fn new(transport: &'a Transport, parts: GetParts<'b>) -> Self {
3172 let headers = HeaderMap::new();
3173 Get {
3174 transport,
3175 parts,
3176 headers,
3177 _source: None,
3178 _source_excludes: None,
3179 _source_includes: None,
3180 error_trace: None,
3181 filter_path: None,
3182 force_synthetic_source: None,
3183 human: None,
3184 preference: None,
3185 pretty: None,
3186 realtime: None,
3187 refresh: None,
3188 request_timeout: None,
3189 routing: None,
3190 source: None,
3191 stored_fields: None,
3192 version: None,
3193 version_type: None,
3194 }
3195 }
3196 #[doc = "True or false to return the _source field or not, or a list of fields to return"]
3197 pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
3198 self._source = Some(_source);
3199 self
3200 }
3201 #[doc = "A list of fields to exclude from the returned _source field"]
3202 pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
3203 self._source_excludes = Some(_source_excludes);
3204 self
3205 }
3206 #[doc = "A list of fields to extract and return from the _source field"]
3207 pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
3208 self._source_includes = Some(_source_includes);
3209 self
3210 }
3211 #[doc = "Include the stack trace of returned errors."]
3212 pub fn error_trace(mut self, error_trace: bool) -> Self {
3213 self.error_trace = Some(error_trace);
3214 self
3215 }
3216 #[doc = "A comma-separated list of filters used to reduce the response."]
3217 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3218 self.filter_path = Some(filter_path);
3219 self
3220 }
3221 #[doc = "Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index."]
3222 pub fn force_synthetic_source(mut self, force_synthetic_source: bool) -> Self {
3223 self.force_synthetic_source = Some(force_synthetic_source);
3224 self
3225 }
3226 #[doc = "Adds a HTTP header"]
3227 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3228 self.headers.insert(key, value);
3229 self
3230 }
3231 #[doc = "Return human readable values for statistics."]
3232 pub fn human(mut self, human: bool) -> Self {
3233 self.human = Some(human);
3234 self
3235 }
3236 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
3237 pub fn preference(mut self, preference: &'b str) -> Self {
3238 self.preference = Some(preference);
3239 self
3240 }
3241 #[doc = "Pretty format the returned JSON response."]
3242 pub fn pretty(mut self, pretty: bool) -> Self {
3243 self.pretty = Some(pretty);
3244 self
3245 }
3246 #[doc = "Specify whether to perform the operation in realtime or search mode"]
3247 pub fn realtime(mut self, realtime: bool) -> Self {
3248 self.realtime = Some(realtime);
3249 self
3250 }
3251 #[doc = "Refresh the shard containing the document before performing the operation"]
3252 pub fn refresh(mut self, refresh: bool) -> Self {
3253 self.refresh = Some(refresh);
3254 self
3255 }
3256 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
3257 pub fn request_timeout(mut self, timeout: Duration) -> Self {
3258 self.request_timeout = Some(timeout);
3259 self
3260 }
3261 #[doc = "Specific routing value"]
3262 pub fn routing(mut self, routing: &'b str) -> Self {
3263 self.routing = Some(routing);
3264 self
3265 }
3266 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3267 pub fn source(mut self, source: &'b str) -> Self {
3268 self.source = Some(source);
3269 self
3270 }
3271 #[doc = "A comma-separated list of stored fields to return in the response"]
3272 pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
3273 self.stored_fields = Some(stored_fields);
3274 self
3275 }
3276 #[doc = "Explicit version number for concurrency control"]
3277 pub fn version(mut self, version: i64) -> Self {
3278 self.version = Some(version);
3279 self
3280 }
3281 #[doc = "Specific version type"]
3282 pub fn version_type(mut self, version_type: VersionType) -> Self {
3283 self.version_type = Some(version_type);
3284 self
3285 }
3286 #[doc = "Creates an asynchronous call to the Get API that can be awaited"]
3287 pub async fn send(self) -> Result<Response, Error> {
3288 let path = self.parts.url();
3289 let method = http::Method::Get;
3290 let headers = self.headers;
3291 let timeout = self.request_timeout;
3292 let query_string = {
3293 #[serde_with::skip_serializing_none]
3294 #[derive(Serialize)]
3295 struct QueryParams<'b> {
3296 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3297 _source: Option<&'b [&'b str]>,
3298 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3299 _source_excludes: Option<&'b [&'b str]>,
3300 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3301 _source_includes: Option<&'b [&'b str]>,
3302 error_trace: Option<bool>,
3303 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3304 filter_path: Option<&'b [&'b str]>,
3305 force_synthetic_source: Option<bool>,
3306 human: Option<bool>,
3307 preference: Option<&'b str>,
3308 pretty: Option<bool>,
3309 realtime: Option<bool>,
3310 refresh: Option<bool>,
3311 routing: Option<&'b str>,
3312 source: Option<&'b str>,
3313 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3314 stored_fields: Option<&'b [&'b str]>,
3315 version: Option<i64>,
3316 version_type: Option<VersionType>,
3317 }
3318 let query_params = QueryParams {
3319 _source: self._source,
3320 _source_excludes: self._source_excludes,
3321 _source_includes: self._source_includes,
3322 error_trace: self.error_trace,
3323 filter_path: self.filter_path,
3324 force_synthetic_source: self.force_synthetic_source,
3325 human: self.human,
3326 preference: self.preference,
3327 pretty: self.pretty,
3328 realtime: self.realtime,
3329 refresh: self.refresh,
3330 routing: self.routing,
3331 source: self.source,
3332 stored_fields: self.stored_fields,
3333 version: self.version,
3334 version_type: self.version_type,
3335 };
3336 Some(query_params)
3337 };
3338 let body = Option::<()>::None;
3339 let response = self
3340 .transport
3341 .send(method, &path, headers, query_string.as_ref(), body, timeout)
3342 .await?;
3343 Ok(response)
3344 }
3345}
3346#[derive(Debug, Clone, PartialEq, Eq)]
3347#[doc = "API parts for the Get Script API"]
3348pub enum GetScriptParts<'b> {
3349 #[doc = "Id"]
3350 Id(&'b str),
3351}
3352impl<'b> GetScriptParts<'b> {
3353 #[doc = "Builds a relative URL path to the Get Script API"]
3354 pub fn url(self) -> Cow<'static, str> {
3355 match self {
3356 GetScriptParts::Id(id) => {
3357 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
3358 let mut p = String::with_capacity(10usize + encoded_id.len());
3359 p.push_str("/_scripts/");
3360 p.push_str(encoded_id.as_ref());
3361 p.into()
3362 }
3363 }
3364 }
3365}
3366#[doc = "Builder for the [Get Script API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/modules-scripting.html)\n\nReturns a script."]
3367#[derive(Clone, Debug)]
3368pub struct GetScript<'a, 'b> {
3369 transport: &'a Transport,
3370 parts: GetScriptParts<'b>,
3371 error_trace: Option<bool>,
3372 filter_path: Option<&'b [&'b str]>,
3373 headers: HeaderMap,
3374 human: Option<bool>,
3375 master_timeout: Option<&'b str>,
3376 pretty: Option<bool>,
3377 request_timeout: Option<Duration>,
3378 source: Option<&'b str>,
3379}
3380impl<'a, 'b> GetScript<'a, 'b> {
3381 #[doc = "Creates a new instance of [GetScript] with the specified API parts"]
3382 pub fn new(transport: &'a Transport, parts: GetScriptParts<'b>) -> Self {
3383 let headers = HeaderMap::new();
3384 GetScript {
3385 transport,
3386 parts,
3387 headers,
3388 error_trace: None,
3389 filter_path: None,
3390 human: None,
3391 master_timeout: None,
3392 pretty: None,
3393 request_timeout: None,
3394 source: None,
3395 }
3396 }
3397 #[doc = "Include the stack trace of returned errors."]
3398 pub fn error_trace(mut self, error_trace: bool) -> Self {
3399 self.error_trace = Some(error_trace);
3400 self
3401 }
3402 #[doc = "A comma-separated list of filters used to reduce the response."]
3403 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3404 self.filter_path = Some(filter_path);
3405 self
3406 }
3407 #[doc = "Adds a HTTP header"]
3408 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3409 self.headers.insert(key, value);
3410 self
3411 }
3412 #[doc = "Return human readable values for statistics."]
3413 pub fn human(mut self, human: bool) -> Self {
3414 self.human = Some(human);
3415 self
3416 }
3417 #[doc = "Specify timeout for connection to master"]
3418 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
3419 self.master_timeout = Some(master_timeout);
3420 self
3421 }
3422 #[doc = "Pretty format the returned JSON response."]
3423 pub fn pretty(mut self, pretty: bool) -> Self {
3424 self.pretty = Some(pretty);
3425 self
3426 }
3427 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
3428 pub fn request_timeout(mut self, timeout: Duration) -> Self {
3429 self.request_timeout = Some(timeout);
3430 self
3431 }
3432 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3433 pub fn source(mut self, source: &'b str) -> Self {
3434 self.source = Some(source);
3435 self
3436 }
3437 #[doc = "Creates an asynchronous call to the Get Script API that can be awaited"]
3438 pub async fn send(self) -> Result<Response, Error> {
3439 let path = self.parts.url();
3440 let method = http::Method::Get;
3441 let headers = self.headers;
3442 let timeout = self.request_timeout;
3443 let query_string = {
3444 #[serde_with::skip_serializing_none]
3445 #[derive(Serialize)]
3446 struct QueryParams<'b> {
3447 error_trace: Option<bool>,
3448 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3449 filter_path: Option<&'b [&'b str]>,
3450 human: Option<bool>,
3451 master_timeout: Option<&'b str>,
3452 pretty: Option<bool>,
3453 source: Option<&'b str>,
3454 }
3455 let query_params = QueryParams {
3456 error_trace: self.error_trace,
3457 filter_path: self.filter_path,
3458 human: self.human,
3459 master_timeout: self.master_timeout,
3460 pretty: self.pretty,
3461 source: self.source,
3462 };
3463 Some(query_params)
3464 };
3465 let body = Option::<()>::None;
3466 let response = self
3467 .transport
3468 .send(method, &path, headers, query_string.as_ref(), body, timeout)
3469 .await?;
3470 Ok(response)
3471 }
3472}
3473#[derive(Debug, Clone, PartialEq, Eq)]
3474#[doc = "API parts for the Get Script Context API"]
3475pub enum GetScriptContextParts {
3476 #[doc = "No parts"]
3477 None,
3478}
3479impl GetScriptContextParts {
3480 #[doc = "Builds a relative URL path to the Get Script Context API"]
3481 pub fn url(self) -> Cow<'static, str> {
3482 match self {
3483 GetScriptContextParts::None => "/_script_context".into(),
3484 }
3485 }
3486}
3487#[doc = "Builder for the [Get Script Context API](https://www.elastic.co/guide/en/elasticsearch/painless/9.0/painless-contexts.html)\n\nReturns all script contexts."]
3488#[derive(Clone, Debug)]
3489pub struct GetScriptContext<'a, 'b> {
3490 transport: &'a Transport,
3491 parts: GetScriptContextParts,
3492 error_trace: Option<bool>,
3493 filter_path: Option<&'b [&'b str]>,
3494 headers: HeaderMap,
3495 human: Option<bool>,
3496 pretty: Option<bool>,
3497 request_timeout: Option<Duration>,
3498 source: Option<&'b str>,
3499}
3500impl<'a, 'b> GetScriptContext<'a, 'b> {
3501 #[doc = "Creates a new instance of [GetScriptContext]"]
3502 pub fn new(transport: &'a Transport) -> Self {
3503 let headers = HeaderMap::new();
3504 GetScriptContext {
3505 transport,
3506 parts: GetScriptContextParts::None,
3507 headers,
3508 error_trace: None,
3509 filter_path: None,
3510 human: None,
3511 pretty: None,
3512 request_timeout: None,
3513 source: None,
3514 }
3515 }
3516 #[doc = "Include the stack trace of returned errors."]
3517 pub fn error_trace(mut self, error_trace: bool) -> Self {
3518 self.error_trace = Some(error_trace);
3519 self
3520 }
3521 #[doc = "A comma-separated list of filters used to reduce the response."]
3522 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3523 self.filter_path = Some(filter_path);
3524 self
3525 }
3526 #[doc = "Adds a HTTP header"]
3527 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3528 self.headers.insert(key, value);
3529 self
3530 }
3531 #[doc = "Return human readable values for statistics."]
3532 pub fn human(mut self, human: bool) -> Self {
3533 self.human = Some(human);
3534 self
3535 }
3536 #[doc = "Pretty format the returned JSON response."]
3537 pub fn pretty(mut self, pretty: bool) -> Self {
3538 self.pretty = Some(pretty);
3539 self
3540 }
3541 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
3542 pub fn request_timeout(mut self, timeout: Duration) -> Self {
3543 self.request_timeout = Some(timeout);
3544 self
3545 }
3546 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3547 pub fn source(mut self, source: &'b str) -> Self {
3548 self.source = Some(source);
3549 self
3550 }
3551 #[doc = "Creates an asynchronous call to the Get Script Context API that can be awaited"]
3552 pub async fn send(self) -> Result<Response, Error> {
3553 let path = self.parts.url();
3554 let method = http::Method::Get;
3555 let headers = self.headers;
3556 let timeout = self.request_timeout;
3557 let query_string = {
3558 #[serde_with::skip_serializing_none]
3559 #[derive(Serialize)]
3560 struct QueryParams<'b> {
3561 error_trace: Option<bool>,
3562 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3563 filter_path: Option<&'b [&'b str]>,
3564 human: Option<bool>,
3565 pretty: Option<bool>,
3566 source: Option<&'b str>,
3567 }
3568 let query_params = QueryParams {
3569 error_trace: self.error_trace,
3570 filter_path: self.filter_path,
3571 human: self.human,
3572 pretty: self.pretty,
3573 source: self.source,
3574 };
3575 Some(query_params)
3576 };
3577 let body = Option::<()>::None;
3578 let response = self
3579 .transport
3580 .send(method, &path, headers, query_string.as_ref(), body, timeout)
3581 .await?;
3582 Ok(response)
3583 }
3584}
3585#[derive(Debug, Clone, PartialEq, Eq)]
3586#[doc = "API parts for the Get Script Languages API"]
3587pub enum GetScriptLanguagesParts {
3588 #[doc = "No parts"]
3589 None,
3590}
3591impl GetScriptLanguagesParts {
3592 #[doc = "Builds a relative URL path to the Get Script Languages API"]
3593 pub fn url(self) -> Cow<'static, str> {
3594 match self {
3595 GetScriptLanguagesParts::None => "/_script_language".into(),
3596 }
3597 }
3598}
3599#[doc = "Builder for the [Get Script Languages API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/modules-scripting.html)\n\nReturns available script types, languages and contexts"]
3600#[derive(Clone, Debug)]
3601pub struct GetScriptLanguages<'a, 'b> {
3602 transport: &'a Transport,
3603 parts: GetScriptLanguagesParts,
3604 error_trace: Option<bool>,
3605 filter_path: Option<&'b [&'b str]>,
3606 headers: HeaderMap,
3607 human: Option<bool>,
3608 pretty: Option<bool>,
3609 request_timeout: Option<Duration>,
3610 source: Option<&'b str>,
3611}
3612impl<'a, 'b> GetScriptLanguages<'a, 'b> {
3613 #[doc = "Creates a new instance of [GetScriptLanguages]"]
3614 pub fn new(transport: &'a Transport) -> Self {
3615 let headers = HeaderMap::new();
3616 GetScriptLanguages {
3617 transport,
3618 parts: GetScriptLanguagesParts::None,
3619 headers,
3620 error_trace: None,
3621 filter_path: None,
3622 human: None,
3623 pretty: None,
3624 request_timeout: None,
3625 source: None,
3626 }
3627 }
3628 #[doc = "Include the stack trace of returned errors."]
3629 pub fn error_trace(mut self, error_trace: bool) -> Self {
3630 self.error_trace = Some(error_trace);
3631 self
3632 }
3633 #[doc = "A comma-separated list of filters used to reduce the response."]
3634 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3635 self.filter_path = Some(filter_path);
3636 self
3637 }
3638 #[doc = "Adds a HTTP header"]
3639 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3640 self.headers.insert(key, value);
3641 self
3642 }
3643 #[doc = "Return human readable values for statistics."]
3644 pub fn human(mut self, human: bool) -> Self {
3645 self.human = Some(human);
3646 self
3647 }
3648 #[doc = "Pretty format the returned JSON response."]
3649 pub fn pretty(mut self, pretty: bool) -> Self {
3650 self.pretty = Some(pretty);
3651 self
3652 }
3653 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
3654 pub fn request_timeout(mut self, timeout: Duration) -> Self {
3655 self.request_timeout = Some(timeout);
3656 self
3657 }
3658 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3659 pub fn source(mut self, source: &'b str) -> Self {
3660 self.source = Some(source);
3661 self
3662 }
3663 #[doc = "Creates an asynchronous call to the Get Script Languages API that can be awaited"]
3664 pub async fn send(self) -> Result<Response, Error> {
3665 let path = self.parts.url();
3666 let method = http::Method::Get;
3667 let headers = self.headers;
3668 let timeout = self.request_timeout;
3669 let query_string = {
3670 #[serde_with::skip_serializing_none]
3671 #[derive(Serialize)]
3672 struct QueryParams<'b> {
3673 error_trace: Option<bool>,
3674 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3675 filter_path: Option<&'b [&'b str]>,
3676 human: Option<bool>,
3677 pretty: Option<bool>,
3678 source: Option<&'b str>,
3679 }
3680 let query_params = QueryParams {
3681 error_trace: self.error_trace,
3682 filter_path: self.filter_path,
3683 human: self.human,
3684 pretty: self.pretty,
3685 source: self.source,
3686 };
3687 Some(query_params)
3688 };
3689 let body = Option::<()>::None;
3690 let response = self
3691 .transport
3692 .send(method, &path, headers, query_string.as_ref(), body, timeout)
3693 .await?;
3694 Ok(response)
3695 }
3696}
3697#[derive(Debug, Clone, PartialEq, Eq)]
3698#[doc = "API parts for the Get Source API"]
3699pub enum GetSourceParts<'b> {
3700 #[doc = "Index and Id"]
3701 IndexId(&'b str, &'b str),
3702}
3703impl<'b> GetSourceParts<'b> {
3704 #[doc = "Builds a relative URL path to the Get Source API"]
3705 pub fn url(self) -> Cow<'static, str> {
3706 match self {
3707 GetSourceParts::IndexId(index, id) => {
3708 let encoded_index: Cow<str> =
3709 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
3710 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
3711 let mut p = String::with_capacity(10usize + encoded_index.len() + encoded_id.len());
3712 p.push('/');
3713 p.push_str(encoded_index.as_ref());
3714 p.push_str("/_source/");
3715 p.push_str(encoded_id.as_ref());
3716 p.into()
3717 }
3718 }
3719 }
3720}
3721#[doc = "Builder for the [Get Source API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-get.html)\n\nReturns the source of a document."]
3722#[derive(Clone, Debug)]
3723pub struct GetSource<'a, 'b> {
3724 transport: &'a Transport,
3725 parts: GetSourceParts<'b>,
3726 _source: Option<&'b [&'b str]>,
3727 _source_excludes: Option<&'b [&'b str]>,
3728 _source_includes: Option<&'b [&'b str]>,
3729 error_trace: Option<bool>,
3730 filter_path: Option<&'b [&'b str]>,
3731 headers: HeaderMap,
3732 human: Option<bool>,
3733 preference: Option<&'b str>,
3734 pretty: Option<bool>,
3735 realtime: Option<bool>,
3736 refresh: Option<bool>,
3737 request_timeout: Option<Duration>,
3738 routing: Option<&'b str>,
3739 source: Option<&'b str>,
3740 version: Option<i64>,
3741 version_type: Option<VersionType>,
3742}
3743impl<'a, 'b> GetSource<'a, 'b> {
3744 #[doc = "Creates a new instance of [GetSource] with the specified API parts"]
3745 pub fn new(transport: &'a Transport, parts: GetSourceParts<'b>) -> Self {
3746 let headers = HeaderMap::new();
3747 GetSource {
3748 transport,
3749 parts,
3750 headers,
3751 _source: None,
3752 _source_excludes: None,
3753 _source_includes: None,
3754 error_trace: None,
3755 filter_path: None,
3756 human: None,
3757 preference: None,
3758 pretty: None,
3759 realtime: None,
3760 refresh: None,
3761 request_timeout: None,
3762 routing: None,
3763 source: None,
3764 version: None,
3765 version_type: None,
3766 }
3767 }
3768 #[doc = "True or false to return the _source field or not, or a list of fields to return"]
3769 pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
3770 self._source = Some(_source);
3771 self
3772 }
3773 #[doc = "A list of fields to exclude from the returned _source field"]
3774 pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
3775 self._source_excludes = Some(_source_excludes);
3776 self
3777 }
3778 #[doc = "A list of fields to extract and return from the _source field"]
3779 pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
3780 self._source_includes = Some(_source_includes);
3781 self
3782 }
3783 #[doc = "Include the stack trace of returned errors."]
3784 pub fn error_trace(mut self, error_trace: bool) -> Self {
3785 self.error_trace = Some(error_trace);
3786 self
3787 }
3788 #[doc = "A comma-separated list of filters used to reduce the response."]
3789 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3790 self.filter_path = Some(filter_path);
3791 self
3792 }
3793 #[doc = "Adds a HTTP header"]
3794 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3795 self.headers.insert(key, value);
3796 self
3797 }
3798 #[doc = "Return human readable values for statistics."]
3799 pub fn human(mut self, human: bool) -> Self {
3800 self.human = Some(human);
3801 self
3802 }
3803 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
3804 pub fn preference(mut self, preference: &'b str) -> Self {
3805 self.preference = Some(preference);
3806 self
3807 }
3808 #[doc = "Pretty format the returned JSON response."]
3809 pub fn pretty(mut self, pretty: bool) -> Self {
3810 self.pretty = Some(pretty);
3811 self
3812 }
3813 #[doc = "Specify whether to perform the operation in realtime or search mode"]
3814 pub fn realtime(mut self, realtime: bool) -> Self {
3815 self.realtime = Some(realtime);
3816 self
3817 }
3818 #[doc = "Refresh the shard containing the document before performing the operation"]
3819 pub fn refresh(mut self, refresh: bool) -> Self {
3820 self.refresh = Some(refresh);
3821 self
3822 }
3823 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
3824 pub fn request_timeout(mut self, timeout: Duration) -> Self {
3825 self.request_timeout = Some(timeout);
3826 self
3827 }
3828 #[doc = "Specific routing value"]
3829 pub fn routing(mut self, routing: &'b str) -> Self {
3830 self.routing = Some(routing);
3831 self
3832 }
3833 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3834 pub fn source(mut self, source: &'b str) -> Self {
3835 self.source = Some(source);
3836 self
3837 }
3838 #[doc = "Explicit version number for concurrency control"]
3839 pub fn version(mut self, version: i64) -> Self {
3840 self.version = Some(version);
3841 self
3842 }
3843 #[doc = "Specific version type"]
3844 pub fn version_type(mut self, version_type: VersionType) -> Self {
3845 self.version_type = Some(version_type);
3846 self
3847 }
3848 #[doc = "Creates an asynchronous call to the Get Source API that can be awaited"]
3849 pub async fn send(self) -> Result<Response, Error> {
3850 let path = self.parts.url();
3851 let method = http::Method::Get;
3852 let headers = self.headers;
3853 let timeout = self.request_timeout;
3854 let query_string = {
3855 #[serde_with::skip_serializing_none]
3856 #[derive(Serialize)]
3857 struct QueryParams<'b> {
3858 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3859 _source: Option<&'b [&'b str]>,
3860 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3861 _source_excludes: Option<&'b [&'b str]>,
3862 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3863 _source_includes: Option<&'b [&'b str]>,
3864 error_trace: Option<bool>,
3865 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
3866 filter_path: Option<&'b [&'b str]>,
3867 human: Option<bool>,
3868 preference: Option<&'b str>,
3869 pretty: Option<bool>,
3870 realtime: Option<bool>,
3871 refresh: Option<bool>,
3872 routing: Option<&'b str>,
3873 source: Option<&'b str>,
3874 version: Option<i64>,
3875 version_type: Option<VersionType>,
3876 }
3877 let query_params = QueryParams {
3878 _source: self._source,
3879 _source_excludes: self._source_excludes,
3880 _source_includes: self._source_includes,
3881 error_trace: self.error_trace,
3882 filter_path: self.filter_path,
3883 human: self.human,
3884 preference: self.preference,
3885 pretty: self.pretty,
3886 realtime: self.realtime,
3887 refresh: self.refresh,
3888 routing: self.routing,
3889 source: self.source,
3890 version: self.version,
3891 version_type: self.version_type,
3892 };
3893 Some(query_params)
3894 };
3895 let body = Option::<()>::None;
3896 let response = self
3897 .transport
3898 .send(method, &path, headers, query_string.as_ref(), body, timeout)
3899 .await?;
3900 Ok(response)
3901 }
3902}
3903#[derive(Debug, Clone, PartialEq, Eq)]
3904#[doc = "API parts for the Health Report API"]
3905pub enum HealthReportParts<'b> {
3906 #[doc = "No parts"]
3907 None,
3908 #[doc = "Feature"]
3909 Feature(&'b str),
3910}
3911impl<'b> HealthReportParts<'b> {
3912 #[doc = "Builds a relative URL path to the Health Report API"]
3913 pub fn url(self) -> Cow<'static, str> {
3914 match self {
3915 HealthReportParts::None => "/_health_report".into(),
3916 HealthReportParts::Feature(feature) => {
3917 let encoded_feature: Cow<str> =
3918 percent_encode(feature.as_bytes(), PARTS_ENCODED).into();
3919 let mut p = String::with_capacity(16usize + encoded_feature.len());
3920 p.push_str("/_health_report/");
3921 p.push_str(encoded_feature.as_ref());
3922 p.into()
3923 }
3924 }
3925 }
3926}
3927#[doc = "Builder for the [Health Report API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/health-api.html)\n\nReturns the health of the cluster."]
3928#[derive(Clone, Debug)]
3929pub struct HealthReport<'a, 'b> {
3930 transport: &'a Transport,
3931 parts: HealthReportParts<'b>,
3932 error_trace: Option<bool>,
3933 filter_path: Option<&'b [&'b str]>,
3934 headers: HeaderMap,
3935 human: Option<bool>,
3936 pretty: Option<bool>,
3937 request_timeout: Option<Duration>,
3938 size: Option<i32>,
3939 source: Option<&'b str>,
3940 timeout: Option<&'b str>,
3941 verbose: Option<bool>,
3942}
3943impl<'a, 'b> HealthReport<'a, 'b> {
3944 #[doc = "Creates a new instance of [HealthReport] with the specified API parts"]
3945 pub fn new(transport: &'a Transport, parts: HealthReportParts<'b>) -> Self {
3946 let headers = HeaderMap::new();
3947 HealthReport {
3948 transport,
3949 parts,
3950 headers,
3951 error_trace: None,
3952 filter_path: None,
3953 human: None,
3954 pretty: None,
3955 request_timeout: None,
3956 size: None,
3957 source: None,
3958 timeout: None,
3959 verbose: None,
3960 }
3961 }
3962 #[doc = "Include the stack trace of returned errors."]
3963 pub fn error_trace(mut self, error_trace: bool) -> Self {
3964 self.error_trace = Some(error_trace);
3965 self
3966 }
3967 #[doc = "A comma-separated list of filters used to reduce the response."]
3968 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
3969 self.filter_path = Some(filter_path);
3970 self
3971 }
3972 #[doc = "Adds a HTTP header"]
3973 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
3974 self.headers.insert(key, value);
3975 self
3976 }
3977 #[doc = "Return human readable values for statistics."]
3978 pub fn human(mut self, human: bool) -> Self {
3979 self.human = Some(human);
3980 self
3981 }
3982 #[doc = "Pretty format the returned JSON response."]
3983 pub fn pretty(mut self, pretty: bool) -> Self {
3984 self.pretty = Some(pretty);
3985 self
3986 }
3987 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
3988 pub fn request_timeout(mut self, timeout: Duration) -> Self {
3989 self.request_timeout = Some(timeout);
3990 self
3991 }
3992 #[doc = "Limit the number of affected resources the health API returns"]
3993 pub fn size(mut self, size: i32) -> Self {
3994 self.size = Some(size);
3995 self
3996 }
3997 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
3998 pub fn source(mut self, source: &'b str) -> Self {
3999 self.source = Some(source);
4000 self
4001 }
4002 #[doc = "Explicit operation timeout"]
4003 pub fn timeout(mut self, timeout: &'b str) -> Self {
4004 self.timeout = Some(timeout);
4005 self
4006 }
4007 #[doc = "Opt in for more information about the health of the system"]
4008 pub fn verbose(mut self, verbose: bool) -> Self {
4009 self.verbose = Some(verbose);
4010 self
4011 }
4012 #[doc = "Creates an asynchronous call to the Health Report API that can be awaited"]
4013 pub async fn send(self) -> Result<Response, Error> {
4014 let path = self.parts.url();
4015 let method = http::Method::Get;
4016 let headers = self.headers;
4017 let timeout = self.request_timeout;
4018 let query_string = {
4019 #[serde_with::skip_serializing_none]
4020 #[derive(Serialize)]
4021 struct QueryParams<'b> {
4022 error_trace: Option<bool>,
4023 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4024 filter_path: Option<&'b [&'b str]>,
4025 human: Option<bool>,
4026 pretty: Option<bool>,
4027 size: Option<i32>,
4028 source: Option<&'b str>,
4029 timeout: Option<&'b str>,
4030 verbose: Option<bool>,
4031 }
4032 let query_params = QueryParams {
4033 error_trace: self.error_trace,
4034 filter_path: self.filter_path,
4035 human: self.human,
4036 pretty: self.pretty,
4037 size: self.size,
4038 source: self.source,
4039 timeout: self.timeout,
4040 verbose: self.verbose,
4041 };
4042 Some(query_params)
4043 };
4044 let body = Option::<()>::None;
4045 let response = self
4046 .transport
4047 .send(method, &path, headers, query_string.as_ref(), body, timeout)
4048 .await?;
4049 Ok(response)
4050 }
4051}
4052#[derive(Debug, Clone, PartialEq, Eq)]
4053#[doc = "API parts for the Index API"]
4054pub enum IndexParts<'b> {
4055 #[doc = "Index and Id"]
4056 IndexId(&'b str, &'b str),
4057 #[doc = "Index"]
4058 Index(&'b str),
4059}
4060impl<'b> IndexParts<'b> {
4061 #[doc = "Builds a relative URL path to the Index API"]
4062 pub fn url(self) -> Cow<'static, str> {
4063 match self {
4064 IndexParts::IndexId(index, id) => {
4065 let encoded_index: Cow<str> =
4066 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
4067 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
4068 let mut p = String::with_capacity(7usize + encoded_index.len() + encoded_id.len());
4069 p.push('/');
4070 p.push_str(encoded_index.as_ref());
4071 p.push_str("/_doc/");
4072 p.push_str(encoded_id.as_ref());
4073 p.into()
4074 }
4075 IndexParts::Index(index) => {
4076 let encoded_index: Cow<str> =
4077 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
4078 let mut p = String::with_capacity(6usize + encoded_index.len());
4079 p.push('/');
4080 p.push_str(encoded_index.as_ref());
4081 p.push_str("/_doc");
4082 p.into()
4083 }
4084 }
4085 }
4086}
4087#[doc = "Builder for the [Index API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-index_.html)\n\nCreates or updates a document in an index."]
4088#[derive(Clone, Debug)]
4089pub struct Index<'a, 'b, B> {
4090 transport: &'a Transport,
4091 parts: IndexParts<'b>,
4092 body: Option<B>,
4093 error_trace: Option<bool>,
4094 filter_path: Option<&'b [&'b str]>,
4095 headers: HeaderMap,
4096 human: Option<bool>,
4097 if_primary_term: Option<i64>,
4098 if_seq_no: Option<i64>,
4099 include_source_on_error: Option<bool>,
4100 op_type: Option<OpType>,
4101 pipeline: Option<&'b str>,
4102 pretty: Option<bool>,
4103 refresh: Option<Refresh>,
4104 request_timeout: Option<Duration>,
4105 require_alias: Option<bool>,
4106 require_data_stream: Option<bool>,
4107 routing: Option<&'b str>,
4108 source: Option<&'b str>,
4109 timeout: Option<&'b str>,
4110 version: Option<i64>,
4111 version_type: Option<VersionType>,
4112 wait_for_active_shards: Option<&'b str>,
4113}
4114impl<'a, 'b, B> Index<'a, 'b, B>
4115where
4116 B: Body,
4117{
4118 #[doc = "Creates a new instance of [Index] with the specified API parts"]
4119 pub fn new(transport: &'a Transport, parts: IndexParts<'b>) -> Self {
4120 let headers = HeaderMap::new();
4121 Index {
4122 transport,
4123 parts,
4124 headers,
4125 body: None,
4126 error_trace: None,
4127 filter_path: None,
4128 human: None,
4129 if_primary_term: None,
4130 if_seq_no: None,
4131 include_source_on_error: None,
4132 op_type: None,
4133 pipeline: None,
4134 pretty: None,
4135 refresh: None,
4136 request_timeout: None,
4137 require_alias: None,
4138 require_data_stream: None,
4139 routing: None,
4140 source: None,
4141 timeout: None,
4142 version: None,
4143 version_type: None,
4144 wait_for_active_shards: None,
4145 }
4146 }
4147 #[doc = "The body for the API call"]
4148 pub fn body<T>(self, body: T) -> Index<'a, 'b, JsonBody<T>>
4149 where
4150 T: Serialize,
4151 {
4152 Index {
4153 transport: self.transport,
4154 parts: self.parts,
4155 body: Some(body.into()),
4156 error_trace: self.error_trace,
4157 filter_path: self.filter_path,
4158 headers: self.headers,
4159 human: self.human,
4160 if_primary_term: self.if_primary_term,
4161 if_seq_no: self.if_seq_no,
4162 include_source_on_error: self.include_source_on_error,
4163 op_type: self.op_type,
4164 pipeline: self.pipeline,
4165 pretty: self.pretty,
4166 refresh: self.refresh,
4167 request_timeout: self.request_timeout,
4168 require_alias: self.require_alias,
4169 require_data_stream: self.require_data_stream,
4170 routing: self.routing,
4171 source: self.source,
4172 timeout: self.timeout,
4173 version: self.version,
4174 version_type: self.version_type,
4175 wait_for_active_shards: self.wait_for_active_shards,
4176 }
4177 }
4178 #[doc = "Include the stack trace of returned errors."]
4179 pub fn error_trace(mut self, error_trace: bool) -> Self {
4180 self.error_trace = Some(error_trace);
4181 self
4182 }
4183 #[doc = "A comma-separated list of filters used to reduce the response."]
4184 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
4185 self.filter_path = Some(filter_path);
4186 self
4187 }
4188 #[doc = "Adds a HTTP header"]
4189 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
4190 self.headers.insert(key, value);
4191 self
4192 }
4193 #[doc = "Return human readable values for statistics."]
4194 pub fn human(mut self, human: bool) -> Self {
4195 self.human = Some(human);
4196 self
4197 }
4198 #[doc = "only perform the index operation if the last operation that has changed the document has the specified primary term"]
4199 pub fn if_primary_term(mut self, if_primary_term: i64) -> Self {
4200 self.if_primary_term = Some(if_primary_term);
4201 self
4202 }
4203 #[doc = "only perform the index operation if the last operation that has changed the document has the specified sequence number"]
4204 pub fn if_seq_no(mut self, if_seq_no: i64) -> Self {
4205 self.if_seq_no = Some(if_seq_no);
4206 self
4207 }
4208 #[doc = "True or false if to include the document source in the error message in case of parsing errors. Defaults to true."]
4209 pub fn include_source_on_error(mut self, include_source_on_error: bool) -> Self {
4210 self.include_source_on_error = Some(include_source_on_error);
4211 self
4212 }
4213 #[doc = "Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID"]
4214 pub fn op_type(mut self, op_type: OpType) -> Self {
4215 self.op_type = Some(op_type);
4216 self
4217 }
4218 #[doc = "The pipeline id to preprocess incoming documents with"]
4219 pub fn pipeline(mut self, pipeline: &'b str) -> Self {
4220 self.pipeline = Some(pipeline);
4221 self
4222 }
4223 #[doc = "Pretty format the returned JSON response."]
4224 pub fn pretty(mut self, pretty: bool) -> Self {
4225 self.pretty = Some(pretty);
4226 self
4227 }
4228 #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
4229 pub fn refresh(mut self, refresh: Refresh) -> Self {
4230 self.refresh = Some(refresh);
4231 self
4232 }
4233 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
4234 pub fn request_timeout(mut self, timeout: Duration) -> Self {
4235 self.request_timeout = Some(timeout);
4236 self
4237 }
4238 #[doc = "When true, requires destination to be an alias. Default is false"]
4239 pub fn require_alias(mut self, require_alias: bool) -> Self {
4240 self.require_alias = Some(require_alias);
4241 self
4242 }
4243 #[doc = "When true, requires the destination to be a data stream (existing or to-be-created). Default is false"]
4244 pub fn require_data_stream(mut self, require_data_stream: bool) -> Self {
4245 self.require_data_stream = Some(require_data_stream);
4246 self
4247 }
4248 #[doc = "Specific routing value"]
4249 pub fn routing(mut self, routing: &'b str) -> Self {
4250 self.routing = Some(routing);
4251 self
4252 }
4253 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
4254 pub fn source(mut self, source: &'b str) -> Self {
4255 self.source = Some(source);
4256 self
4257 }
4258 #[doc = "Explicit operation timeout"]
4259 pub fn timeout(mut self, timeout: &'b str) -> Self {
4260 self.timeout = Some(timeout);
4261 self
4262 }
4263 #[doc = "Explicit version number for concurrency control"]
4264 pub fn version(mut self, version: i64) -> Self {
4265 self.version = Some(version);
4266 self
4267 }
4268 #[doc = "Specific version type"]
4269 pub fn version_type(mut self, version_type: VersionType) -> Self {
4270 self.version_type = Some(version_type);
4271 self
4272 }
4273 #[doc = "Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"]
4274 pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
4275 self.wait_for_active_shards = Some(wait_for_active_shards);
4276 self
4277 }
4278 #[doc = "Creates an asynchronous call to the Index API that can be awaited"]
4279 pub async fn send(self) -> Result<Response, Error> {
4280 let path = self.parts.url();
4281 let method = http::Method::Post;
4282 let headers = self.headers;
4283 let timeout = self.request_timeout;
4284 let query_string = {
4285 #[serde_with::skip_serializing_none]
4286 #[derive(Serialize)]
4287 struct QueryParams<'b> {
4288 error_trace: Option<bool>,
4289 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4290 filter_path: Option<&'b [&'b str]>,
4291 human: Option<bool>,
4292 if_primary_term: Option<i64>,
4293 if_seq_no: Option<i64>,
4294 include_source_on_error: Option<bool>,
4295 op_type: Option<OpType>,
4296 pipeline: Option<&'b str>,
4297 pretty: Option<bool>,
4298 refresh: Option<Refresh>,
4299 require_alias: Option<bool>,
4300 require_data_stream: Option<bool>,
4301 routing: Option<&'b str>,
4302 source: Option<&'b str>,
4303 timeout: Option<&'b str>,
4304 version: Option<i64>,
4305 version_type: Option<VersionType>,
4306 wait_for_active_shards: Option<&'b str>,
4307 }
4308 let query_params = QueryParams {
4309 error_trace: self.error_trace,
4310 filter_path: self.filter_path,
4311 human: self.human,
4312 if_primary_term: self.if_primary_term,
4313 if_seq_no: self.if_seq_no,
4314 include_source_on_error: self.include_source_on_error,
4315 op_type: self.op_type,
4316 pipeline: self.pipeline,
4317 pretty: self.pretty,
4318 refresh: self.refresh,
4319 require_alias: self.require_alias,
4320 require_data_stream: self.require_data_stream,
4321 routing: self.routing,
4322 source: self.source,
4323 timeout: self.timeout,
4324 version: self.version,
4325 version_type: self.version_type,
4326 wait_for_active_shards: self.wait_for_active_shards,
4327 };
4328 Some(query_params)
4329 };
4330 let body = self.body;
4331 let response = self
4332 .transport
4333 .send(method, &path, headers, query_string.as_ref(), body, timeout)
4334 .await?;
4335 Ok(response)
4336 }
4337}
4338#[derive(Debug, Clone, PartialEq, Eq)]
4339#[doc = "API parts for the Info API"]
4340pub enum InfoParts {
4341 #[doc = "No parts"]
4342 None,
4343}
4344impl InfoParts {
4345 #[doc = "Builds a relative URL path to the Info API"]
4346 pub fn url(self) -> Cow<'static, str> {
4347 match self {
4348 InfoParts::None => "/".into(),
4349 }
4350 }
4351}
4352#[doc = "Builder for the [Info API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/index.html)\n\nReturns basic information about the cluster."]
4353#[derive(Clone, Debug)]
4354pub struct Info<'a, 'b> {
4355 transport: &'a Transport,
4356 parts: InfoParts,
4357 error_trace: Option<bool>,
4358 filter_path: Option<&'b [&'b str]>,
4359 headers: HeaderMap,
4360 human: Option<bool>,
4361 pretty: Option<bool>,
4362 request_timeout: Option<Duration>,
4363 source: Option<&'b str>,
4364}
4365impl<'a, 'b> Info<'a, 'b> {
4366 #[doc = "Creates a new instance of [Info]"]
4367 pub fn new(transport: &'a Transport) -> Self {
4368 let headers = HeaderMap::new();
4369 Info {
4370 transport,
4371 parts: InfoParts::None,
4372 headers,
4373 error_trace: None,
4374 filter_path: None,
4375 human: None,
4376 pretty: None,
4377 request_timeout: None,
4378 source: None,
4379 }
4380 }
4381 #[doc = "Include the stack trace of returned errors."]
4382 pub fn error_trace(mut self, error_trace: bool) -> Self {
4383 self.error_trace = Some(error_trace);
4384 self
4385 }
4386 #[doc = "A comma-separated list of filters used to reduce the response."]
4387 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
4388 self.filter_path = Some(filter_path);
4389 self
4390 }
4391 #[doc = "Adds a HTTP header"]
4392 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
4393 self.headers.insert(key, value);
4394 self
4395 }
4396 #[doc = "Return human readable values for statistics."]
4397 pub fn human(mut self, human: bool) -> Self {
4398 self.human = Some(human);
4399 self
4400 }
4401 #[doc = "Pretty format the returned JSON response."]
4402 pub fn pretty(mut self, pretty: bool) -> Self {
4403 self.pretty = Some(pretty);
4404 self
4405 }
4406 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
4407 pub fn request_timeout(mut self, timeout: Duration) -> Self {
4408 self.request_timeout = Some(timeout);
4409 self
4410 }
4411 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
4412 pub fn source(mut self, source: &'b str) -> Self {
4413 self.source = Some(source);
4414 self
4415 }
4416 #[doc = "Creates an asynchronous call to the Info API that can be awaited"]
4417 pub async fn send(self) -> Result<Response, Error> {
4418 let path = self.parts.url();
4419 let method = http::Method::Get;
4420 let headers = self.headers;
4421 let timeout = self.request_timeout;
4422 let query_string = {
4423 #[serde_with::skip_serializing_none]
4424 #[derive(Serialize)]
4425 struct QueryParams<'b> {
4426 error_trace: Option<bool>,
4427 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4428 filter_path: Option<&'b [&'b str]>,
4429 human: Option<bool>,
4430 pretty: Option<bool>,
4431 source: Option<&'b str>,
4432 }
4433 let query_params = QueryParams {
4434 error_trace: self.error_trace,
4435 filter_path: self.filter_path,
4436 human: self.human,
4437 pretty: self.pretty,
4438 source: self.source,
4439 };
4440 Some(query_params)
4441 };
4442 let body = Option::<()>::None;
4443 let response = self
4444 .transport
4445 .send(method, &path, headers, query_string.as_ref(), body, timeout)
4446 .await?;
4447 Ok(response)
4448 }
4449}
4450#[derive(Debug, Clone, PartialEq, Eq)]
4451#[doc = "API parts for the Mget API"]
4452pub enum MgetParts<'b> {
4453 #[doc = "No parts"]
4454 None,
4455 #[doc = "Index"]
4456 Index(&'b str),
4457}
4458impl<'b> MgetParts<'b> {
4459 #[doc = "Builds a relative URL path to the Mget API"]
4460 pub fn url(self) -> Cow<'static, str> {
4461 match self {
4462 MgetParts::None => "/_mget".into(),
4463 MgetParts::Index(index) => {
4464 let encoded_index: Cow<str> =
4465 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
4466 let mut p = String::with_capacity(7usize + encoded_index.len());
4467 p.push('/');
4468 p.push_str(encoded_index.as_ref());
4469 p.push_str("/_mget");
4470 p.into()
4471 }
4472 }
4473 }
4474}
4475#[doc = "Builder for the [Mget API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-multi-get.html)\n\nAllows to get multiple documents in one request."]
4476#[derive(Clone, Debug)]
4477pub struct Mget<'a, 'b, B> {
4478 transport: &'a Transport,
4479 parts: MgetParts<'b>,
4480 _source: Option<&'b [&'b str]>,
4481 _source_excludes: Option<&'b [&'b str]>,
4482 _source_includes: Option<&'b [&'b str]>,
4483 body: Option<B>,
4484 error_trace: Option<bool>,
4485 filter_path: Option<&'b [&'b str]>,
4486 force_synthetic_source: Option<bool>,
4487 headers: HeaderMap,
4488 human: Option<bool>,
4489 preference: Option<&'b str>,
4490 pretty: Option<bool>,
4491 realtime: Option<bool>,
4492 refresh: Option<bool>,
4493 request_timeout: Option<Duration>,
4494 routing: Option<&'b str>,
4495 source: Option<&'b str>,
4496 stored_fields: Option<&'b [&'b str]>,
4497}
4498impl<'a, 'b, B> Mget<'a, 'b, B>
4499where
4500 B: Body,
4501{
4502 #[doc = "Creates a new instance of [Mget] with the specified API parts"]
4503 pub fn new(transport: &'a Transport, parts: MgetParts<'b>) -> Self {
4504 let headers = HeaderMap::new();
4505 Mget {
4506 transport,
4507 parts,
4508 headers,
4509 _source: None,
4510 _source_excludes: None,
4511 _source_includes: None,
4512 body: None,
4513 error_trace: None,
4514 filter_path: None,
4515 force_synthetic_source: None,
4516 human: None,
4517 preference: None,
4518 pretty: None,
4519 realtime: None,
4520 refresh: None,
4521 request_timeout: None,
4522 routing: None,
4523 source: None,
4524 stored_fields: None,
4525 }
4526 }
4527 #[doc = "True or false to return the _source field or not, or a list of fields to return"]
4528 pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
4529 self._source = Some(_source);
4530 self
4531 }
4532 #[doc = "A list of fields to exclude from the returned _source field"]
4533 pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
4534 self._source_excludes = Some(_source_excludes);
4535 self
4536 }
4537 #[doc = "A list of fields to extract and return from the _source field"]
4538 pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
4539 self._source_includes = Some(_source_includes);
4540 self
4541 }
4542 #[doc = "The body for the API call"]
4543 pub fn body<T>(self, body: T) -> Mget<'a, 'b, JsonBody<T>>
4544 where
4545 T: Serialize,
4546 {
4547 Mget {
4548 transport: self.transport,
4549 parts: self.parts,
4550 body: Some(body.into()),
4551 _source: self._source,
4552 _source_excludes: self._source_excludes,
4553 _source_includes: self._source_includes,
4554 error_trace: self.error_trace,
4555 filter_path: self.filter_path,
4556 force_synthetic_source: self.force_synthetic_source,
4557 headers: self.headers,
4558 human: self.human,
4559 preference: self.preference,
4560 pretty: self.pretty,
4561 realtime: self.realtime,
4562 refresh: self.refresh,
4563 request_timeout: self.request_timeout,
4564 routing: self.routing,
4565 source: self.source,
4566 stored_fields: self.stored_fields,
4567 }
4568 }
4569 #[doc = "Include the stack trace of returned errors."]
4570 pub fn error_trace(mut self, error_trace: bool) -> Self {
4571 self.error_trace = Some(error_trace);
4572 self
4573 }
4574 #[doc = "A comma-separated list of filters used to reduce the response."]
4575 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
4576 self.filter_path = Some(filter_path);
4577 self
4578 }
4579 #[doc = "Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index."]
4580 pub fn force_synthetic_source(mut self, force_synthetic_source: bool) -> Self {
4581 self.force_synthetic_source = Some(force_synthetic_source);
4582 self
4583 }
4584 #[doc = "Adds a HTTP header"]
4585 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
4586 self.headers.insert(key, value);
4587 self
4588 }
4589 #[doc = "Return human readable values for statistics."]
4590 pub fn human(mut self, human: bool) -> Self {
4591 self.human = Some(human);
4592 self
4593 }
4594 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
4595 pub fn preference(mut self, preference: &'b str) -> Self {
4596 self.preference = Some(preference);
4597 self
4598 }
4599 #[doc = "Pretty format the returned JSON response."]
4600 pub fn pretty(mut self, pretty: bool) -> Self {
4601 self.pretty = Some(pretty);
4602 self
4603 }
4604 #[doc = "Specify whether to perform the operation in realtime or search mode"]
4605 pub fn realtime(mut self, realtime: bool) -> Self {
4606 self.realtime = Some(realtime);
4607 self
4608 }
4609 #[doc = "Refresh the shard containing the document before performing the operation"]
4610 pub fn refresh(mut self, refresh: bool) -> Self {
4611 self.refresh = Some(refresh);
4612 self
4613 }
4614 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
4615 pub fn request_timeout(mut self, timeout: Duration) -> Self {
4616 self.request_timeout = Some(timeout);
4617 self
4618 }
4619 #[doc = "Specific routing value"]
4620 pub fn routing(mut self, routing: &'b str) -> Self {
4621 self.routing = Some(routing);
4622 self
4623 }
4624 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
4625 pub fn source(mut self, source: &'b str) -> Self {
4626 self.source = Some(source);
4627 self
4628 }
4629 #[doc = "A comma-separated list of stored fields to return in the response"]
4630 pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
4631 self.stored_fields = Some(stored_fields);
4632 self
4633 }
4634 #[doc = "Creates an asynchronous call to the Mget API that can be awaited"]
4635 pub async fn send(self) -> Result<Response, Error> {
4636 let path = self.parts.url();
4637 let method = match self.body {
4638 Some(_) => http::Method::Post,
4639 None => http::Method::Get,
4640 };
4641 let headers = self.headers;
4642 let timeout = self.request_timeout;
4643 let query_string = {
4644 #[serde_with::skip_serializing_none]
4645 #[derive(Serialize)]
4646 struct QueryParams<'b> {
4647 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4648 _source: Option<&'b [&'b str]>,
4649 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4650 _source_excludes: Option<&'b [&'b str]>,
4651 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4652 _source_includes: Option<&'b [&'b str]>,
4653 error_trace: Option<bool>,
4654 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4655 filter_path: Option<&'b [&'b str]>,
4656 force_synthetic_source: Option<bool>,
4657 human: Option<bool>,
4658 preference: Option<&'b str>,
4659 pretty: Option<bool>,
4660 realtime: Option<bool>,
4661 refresh: Option<bool>,
4662 routing: Option<&'b str>,
4663 source: Option<&'b str>,
4664 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4665 stored_fields: Option<&'b [&'b str]>,
4666 }
4667 let query_params = QueryParams {
4668 _source: self._source,
4669 _source_excludes: self._source_excludes,
4670 _source_includes: self._source_includes,
4671 error_trace: self.error_trace,
4672 filter_path: self.filter_path,
4673 force_synthetic_source: self.force_synthetic_source,
4674 human: self.human,
4675 preference: self.preference,
4676 pretty: self.pretty,
4677 realtime: self.realtime,
4678 refresh: self.refresh,
4679 routing: self.routing,
4680 source: self.source,
4681 stored_fields: self.stored_fields,
4682 };
4683 Some(query_params)
4684 };
4685 let body = self.body;
4686 let response = self
4687 .transport
4688 .send(method, &path, headers, query_string.as_ref(), body, timeout)
4689 .await?;
4690 Ok(response)
4691 }
4692}
4693#[derive(Debug, Clone, PartialEq, Eq)]
4694#[doc = "API parts for the Msearch API"]
4695pub enum MsearchParts<'b> {
4696 #[doc = "No parts"]
4697 None,
4698 #[doc = "Index"]
4699 Index(&'b [&'b str]),
4700}
4701impl<'b> MsearchParts<'b> {
4702 #[doc = "Builds a relative URL path to the Msearch API"]
4703 pub fn url(self) -> Cow<'static, str> {
4704 match self {
4705 MsearchParts::None => "/_msearch".into(),
4706 MsearchParts::Index(index) => {
4707 let index_str = index.join(",");
4708 let encoded_index: Cow<str> =
4709 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
4710 let mut p = String::with_capacity(10usize + encoded_index.len());
4711 p.push('/');
4712 p.push_str(encoded_index.as_ref());
4713 p.push_str("/_msearch");
4714 p.into()
4715 }
4716 }
4717 }
4718}
4719#[doc = "Builder for the [Msearch API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-multi-search.html)\n\nAllows to execute several search operations in one request."]
4720#[derive(Clone, Debug)]
4721pub struct Msearch<'a, 'b, B> {
4722 transport: &'a Transport,
4723 parts: MsearchParts<'b>,
4724 body: Option<B>,
4725 ccs_minimize_roundtrips: Option<bool>,
4726 error_trace: Option<bool>,
4727 filter_path: Option<&'b [&'b str]>,
4728 headers: HeaderMap,
4729 human: Option<bool>,
4730 max_concurrent_searches: Option<i64>,
4731 max_concurrent_shard_requests: Option<i64>,
4732 pre_filter_shard_size: Option<i64>,
4733 pretty: Option<bool>,
4734 request_timeout: Option<Duration>,
4735 rest_total_hits_as_int: Option<bool>,
4736 search_type: Option<SearchType>,
4737 source: Option<&'b str>,
4738 typed_keys: Option<bool>,
4739}
4740impl<'a, 'b, B> Msearch<'a, 'b, B>
4741where
4742 B: Body,
4743{
4744 #[doc = "Creates a new instance of [Msearch] with the specified API parts"]
4745 pub fn new(transport: &'a Transport, parts: MsearchParts<'b>) -> Self {
4746 let headers = HeaderMap::new();
4747 Msearch {
4748 transport,
4749 parts,
4750 headers,
4751 body: None,
4752 ccs_minimize_roundtrips: None,
4753 error_trace: None,
4754 filter_path: None,
4755 human: None,
4756 max_concurrent_searches: None,
4757 max_concurrent_shard_requests: None,
4758 pre_filter_shard_size: None,
4759 pretty: None,
4760 request_timeout: None,
4761 rest_total_hits_as_int: None,
4762 search_type: None,
4763 source: None,
4764 typed_keys: None,
4765 }
4766 }
4767 #[doc = "The body for the API call"]
4768 pub fn body<T>(self, body: Vec<T>) -> Msearch<'a, 'b, NdBody<T>>
4769 where
4770 T: Body,
4771 {
4772 Msearch {
4773 transport: self.transport,
4774 parts: self.parts,
4775 body: Some(NdBody::new(body)),
4776 ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
4777 error_trace: self.error_trace,
4778 filter_path: self.filter_path,
4779 headers: self.headers,
4780 human: self.human,
4781 max_concurrent_searches: self.max_concurrent_searches,
4782 max_concurrent_shard_requests: self.max_concurrent_shard_requests,
4783 pre_filter_shard_size: self.pre_filter_shard_size,
4784 pretty: self.pretty,
4785 request_timeout: self.request_timeout,
4786 rest_total_hits_as_int: self.rest_total_hits_as_int,
4787 search_type: self.search_type,
4788 source: self.source,
4789 typed_keys: self.typed_keys,
4790 }
4791 }
4792 #[doc = "Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution"]
4793 pub fn ccs_minimize_roundtrips(mut self, ccs_minimize_roundtrips: bool) -> Self {
4794 self.ccs_minimize_roundtrips = Some(ccs_minimize_roundtrips);
4795 self
4796 }
4797 #[doc = "Include the stack trace of returned errors."]
4798 pub fn error_trace(mut self, error_trace: bool) -> Self {
4799 self.error_trace = Some(error_trace);
4800 self
4801 }
4802 #[doc = "A comma-separated list of filters used to reduce the response."]
4803 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
4804 self.filter_path = Some(filter_path);
4805 self
4806 }
4807 #[doc = "Adds a HTTP header"]
4808 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
4809 self.headers.insert(key, value);
4810 self
4811 }
4812 #[doc = "Return human readable values for statistics."]
4813 pub fn human(mut self, human: bool) -> Self {
4814 self.human = Some(human);
4815 self
4816 }
4817 #[doc = "Controls the maximum number of concurrent searches the multi search api will execute"]
4818 pub fn max_concurrent_searches(mut self, max_concurrent_searches: i64) -> Self {
4819 self.max_concurrent_searches = Some(max_concurrent_searches);
4820 self
4821 }
4822 #[doc = "The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests"]
4823 pub fn max_concurrent_shard_requests(mut self, max_concurrent_shard_requests: i64) -> Self {
4824 self.max_concurrent_shard_requests = Some(max_concurrent_shard_requests);
4825 self
4826 }
4827 #[doc = "A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the\u{a0}number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint."]
4828 pub fn pre_filter_shard_size(mut self, pre_filter_shard_size: i64) -> Self {
4829 self.pre_filter_shard_size = Some(pre_filter_shard_size);
4830 self
4831 }
4832 #[doc = "Pretty format the returned JSON response."]
4833 pub fn pretty(mut self, pretty: bool) -> Self {
4834 self.pretty = Some(pretty);
4835 self
4836 }
4837 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
4838 pub fn request_timeout(mut self, timeout: Duration) -> Self {
4839 self.request_timeout = Some(timeout);
4840 self
4841 }
4842 #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
4843 pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
4844 self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
4845 self
4846 }
4847 #[doc = "Search operation type"]
4848 pub fn search_type(mut self, search_type: SearchType) -> Self {
4849 self.search_type = Some(search_type);
4850 self
4851 }
4852 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
4853 pub fn source(mut self, source: &'b str) -> Self {
4854 self.source = Some(source);
4855 self
4856 }
4857 #[doc = "Specify whether aggregation and suggester names should be prefixed by their respective types in the response"]
4858 pub fn typed_keys(mut self, typed_keys: bool) -> Self {
4859 self.typed_keys = Some(typed_keys);
4860 self
4861 }
4862 #[doc = "Creates an asynchronous call to the Msearch API that can be awaited"]
4863 pub async fn send(self) -> Result<Response, Error> {
4864 let path = self.parts.url();
4865 let method = match self.body {
4866 Some(_) => http::Method::Post,
4867 None => http::Method::Get,
4868 };
4869 let headers = self.headers;
4870 let timeout = self.request_timeout;
4871 let query_string = {
4872 #[serde_with::skip_serializing_none]
4873 #[derive(Serialize)]
4874 struct QueryParams<'b> {
4875 ccs_minimize_roundtrips: Option<bool>,
4876 error_trace: Option<bool>,
4877 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
4878 filter_path: Option<&'b [&'b str]>,
4879 human: Option<bool>,
4880 max_concurrent_searches: Option<i64>,
4881 max_concurrent_shard_requests: Option<i64>,
4882 pre_filter_shard_size: Option<i64>,
4883 pretty: Option<bool>,
4884 rest_total_hits_as_int: Option<bool>,
4885 search_type: Option<SearchType>,
4886 source: Option<&'b str>,
4887 typed_keys: Option<bool>,
4888 }
4889 let query_params = QueryParams {
4890 ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
4891 error_trace: self.error_trace,
4892 filter_path: self.filter_path,
4893 human: self.human,
4894 max_concurrent_searches: self.max_concurrent_searches,
4895 max_concurrent_shard_requests: self.max_concurrent_shard_requests,
4896 pre_filter_shard_size: self.pre_filter_shard_size,
4897 pretty: self.pretty,
4898 rest_total_hits_as_int: self.rest_total_hits_as_int,
4899 search_type: self.search_type,
4900 source: self.source,
4901 typed_keys: self.typed_keys,
4902 };
4903 Some(query_params)
4904 };
4905 let body = self.body;
4906 let response = self
4907 .transport
4908 .send(method, &path, headers, query_string.as_ref(), body, timeout)
4909 .await?;
4910 Ok(response)
4911 }
4912}
4913#[derive(Debug, Clone, PartialEq, Eq)]
4914#[doc = "API parts for the Msearch Template API"]
4915pub enum MsearchTemplateParts<'b> {
4916 #[doc = "No parts"]
4917 None,
4918 #[doc = "Index"]
4919 Index(&'b [&'b str]),
4920}
4921impl<'b> MsearchTemplateParts<'b> {
4922 #[doc = "Builds a relative URL path to the Msearch Template API"]
4923 pub fn url(self) -> Cow<'static, str> {
4924 match self {
4925 MsearchTemplateParts::None => "/_msearch/template".into(),
4926 MsearchTemplateParts::Index(index) => {
4927 let index_str = index.join(",");
4928 let encoded_index: Cow<str> =
4929 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
4930 let mut p = String::with_capacity(19usize + encoded_index.len());
4931 p.push('/');
4932 p.push_str(encoded_index.as_ref());
4933 p.push_str("/_msearch/template");
4934 p.into()
4935 }
4936 }
4937 }
4938}
4939#[doc = "Builder for the [Msearch Template API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-multi-search.html)\n\nAllows to execute several search template operations in one request."]
4940#[derive(Clone, Debug)]
4941pub struct MsearchTemplate<'a, 'b, B> {
4942 transport: &'a Transport,
4943 parts: MsearchTemplateParts<'b>,
4944 body: Option<B>,
4945 ccs_minimize_roundtrips: Option<bool>,
4946 error_trace: Option<bool>,
4947 filter_path: Option<&'b [&'b str]>,
4948 headers: HeaderMap,
4949 human: Option<bool>,
4950 max_concurrent_searches: Option<i64>,
4951 pretty: Option<bool>,
4952 request_timeout: Option<Duration>,
4953 rest_total_hits_as_int: Option<bool>,
4954 search_type: Option<SearchType>,
4955 source: Option<&'b str>,
4956 typed_keys: Option<bool>,
4957}
4958impl<'a, 'b, B> MsearchTemplate<'a, 'b, B>
4959where
4960 B: Body,
4961{
4962 #[doc = "Creates a new instance of [MsearchTemplate] with the specified API parts"]
4963 pub fn new(transport: &'a Transport, parts: MsearchTemplateParts<'b>) -> Self {
4964 let headers = HeaderMap::new();
4965 MsearchTemplate {
4966 transport,
4967 parts,
4968 headers,
4969 body: None,
4970 ccs_minimize_roundtrips: None,
4971 error_trace: None,
4972 filter_path: None,
4973 human: None,
4974 max_concurrent_searches: None,
4975 pretty: None,
4976 request_timeout: None,
4977 rest_total_hits_as_int: None,
4978 search_type: None,
4979 source: None,
4980 typed_keys: None,
4981 }
4982 }
4983 #[doc = "The body for the API call"]
4984 pub fn body<T>(self, body: Vec<T>) -> MsearchTemplate<'a, 'b, NdBody<T>>
4985 where
4986 T: Body,
4987 {
4988 MsearchTemplate {
4989 transport: self.transport,
4990 parts: self.parts,
4991 body: Some(NdBody::new(body)),
4992 ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
4993 error_trace: self.error_trace,
4994 filter_path: self.filter_path,
4995 headers: self.headers,
4996 human: self.human,
4997 max_concurrent_searches: self.max_concurrent_searches,
4998 pretty: self.pretty,
4999 request_timeout: self.request_timeout,
5000 rest_total_hits_as_int: self.rest_total_hits_as_int,
5001 search_type: self.search_type,
5002 source: self.source,
5003 typed_keys: self.typed_keys,
5004 }
5005 }
5006 #[doc = "Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution"]
5007 pub fn ccs_minimize_roundtrips(mut self, ccs_minimize_roundtrips: bool) -> Self {
5008 self.ccs_minimize_roundtrips = Some(ccs_minimize_roundtrips);
5009 self
5010 }
5011 #[doc = "Include the stack trace of returned errors."]
5012 pub fn error_trace(mut self, error_trace: bool) -> Self {
5013 self.error_trace = Some(error_trace);
5014 self
5015 }
5016 #[doc = "A comma-separated list of filters used to reduce the response."]
5017 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5018 self.filter_path = Some(filter_path);
5019 self
5020 }
5021 #[doc = "Adds a HTTP header"]
5022 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5023 self.headers.insert(key, value);
5024 self
5025 }
5026 #[doc = "Return human readable values for statistics."]
5027 pub fn human(mut self, human: bool) -> Self {
5028 self.human = Some(human);
5029 self
5030 }
5031 #[doc = "Controls the maximum number of concurrent searches the multi search api will execute"]
5032 pub fn max_concurrent_searches(mut self, max_concurrent_searches: i64) -> Self {
5033 self.max_concurrent_searches = Some(max_concurrent_searches);
5034 self
5035 }
5036 #[doc = "Pretty format the returned JSON response."]
5037 pub fn pretty(mut self, pretty: bool) -> Self {
5038 self.pretty = Some(pretty);
5039 self
5040 }
5041 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
5042 pub fn request_timeout(mut self, timeout: Duration) -> Self {
5043 self.request_timeout = Some(timeout);
5044 self
5045 }
5046 #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
5047 pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
5048 self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
5049 self
5050 }
5051 #[doc = "Search operation type"]
5052 pub fn search_type(mut self, search_type: SearchType) -> Self {
5053 self.search_type = Some(search_type);
5054 self
5055 }
5056 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5057 pub fn source(mut self, source: &'b str) -> Self {
5058 self.source = Some(source);
5059 self
5060 }
5061 #[doc = "Specify whether aggregation and suggester names should be prefixed by their respective types in the response"]
5062 pub fn typed_keys(mut self, typed_keys: bool) -> Self {
5063 self.typed_keys = Some(typed_keys);
5064 self
5065 }
5066 #[doc = "Creates an asynchronous call to the Msearch Template API that can be awaited"]
5067 pub async fn send(self) -> Result<Response, Error> {
5068 let path = self.parts.url();
5069 let method = match self.body {
5070 Some(_) => http::Method::Post,
5071 None => http::Method::Get,
5072 };
5073 let headers = self.headers;
5074 let timeout = self.request_timeout;
5075 let query_string = {
5076 #[serde_with::skip_serializing_none]
5077 #[derive(Serialize)]
5078 struct QueryParams<'b> {
5079 ccs_minimize_roundtrips: Option<bool>,
5080 error_trace: Option<bool>,
5081 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5082 filter_path: Option<&'b [&'b str]>,
5083 human: Option<bool>,
5084 max_concurrent_searches: Option<i64>,
5085 pretty: Option<bool>,
5086 rest_total_hits_as_int: Option<bool>,
5087 search_type: Option<SearchType>,
5088 source: Option<&'b str>,
5089 typed_keys: Option<bool>,
5090 }
5091 let query_params = QueryParams {
5092 ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
5093 error_trace: self.error_trace,
5094 filter_path: self.filter_path,
5095 human: self.human,
5096 max_concurrent_searches: self.max_concurrent_searches,
5097 pretty: self.pretty,
5098 rest_total_hits_as_int: self.rest_total_hits_as_int,
5099 search_type: self.search_type,
5100 source: self.source,
5101 typed_keys: self.typed_keys,
5102 };
5103 Some(query_params)
5104 };
5105 let body = self.body;
5106 let response = self
5107 .transport
5108 .send(method, &path, headers, query_string.as_ref(), body, timeout)
5109 .await?;
5110 Ok(response)
5111 }
5112}
5113#[derive(Debug, Clone, PartialEq, Eq)]
5114#[doc = "API parts for the Mtermvectors API"]
5115pub enum MtermvectorsParts<'b> {
5116 #[doc = "No parts"]
5117 None,
5118 #[doc = "Index"]
5119 Index(&'b str),
5120}
5121impl<'b> MtermvectorsParts<'b> {
5122 #[doc = "Builds a relative URL path to the Mtermvectors API"]
5123 pub fn url(self) -> Cow<'static, str> {
5124 match self {
5125 MtermvectorsParts::None => "/_mtermvectors".into(),
5126 MtermvectorsParts::Index(index) => {
5127 let encoded_index: Cow<str> =
5128 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
5129 let mut p = String::with_capacity(15usize + encoded_index.len());
5130 p.push('/');
5131 p.push_str(encoded_index.as_ref());
5132 p.push_str("/_mtermvectors");
5133 p.into()
5134 }
5135 }
5136 }
5137}
5138#[doc = "Builder for the [Mtermvectors API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-multi-termvectors.html)\n\nReturns multiple termvectors in one request."]
5139#[derive(Clone, Debug)]
5140pub struct Mtermvectors<'a, 'b, B> {
5141 transport: &'a Transport,
5142 parts: MtermvectorsParts<'b>,
5143 body: Option<B>,
5144 error_trace: Option<bool>,
5145 field_statistics: Option<bool>,
5146 fields: Option<&'b [&'b str]>,
5147 filter_path: Option<&'b [&'b str]>,
5148 headers: HeaderMap,
5149 human: Option<bool>,
5150 ids: Option<&'b [&'b str]>,
5151 offsets: Option<bool>,
5152 payloads: Option<bool>,
5153 positions: Option<bool>,
5154 preference: Option<&'b str>,
5155 pretty: Option<bool>,
5156 realtime: Option<bool>,
5157 request_timeout: Option<Duration>,
5158 routing: Option<&'b str>,
5159 source: Option<&'b str>,
5160 term_statistics: Option<bool>,
5161 version: Option<i64>,
5162 version_type: Option<VersionType>,
5163}
5164impl<'a, 'b, B> Mtermvectors<'a, 'b, B>
5165where
5166 B: Body,
5167{
5168 #[doc = "Creates a new instance of [Mtermvectors] with the specified API parts"]
5169 pub fn new(transport: &'a Transport, parts: MtermvectorsParts<'b>) -> Self {
5170 let headers = HeaderMap::new();
5171 Mtermvectors {
5172 transport,
5173 parts,
5174 headers,
5175 body: None,
5176 error_trace: None,
5177 field_statistics: None,
5178 fields: None,
5179 filter_path: None,
5180 human: None,
5181 ids: None,
5182 offsets: None,
5183 payloads: None,
5184 positions: None,
5185 preference: None,
5186 pretty: None,
5187 realtime: None,
5188 request_timeout: None,
5189 routing: None,
5190 source: None,
5191 term_statistics: None,
5192 version: None,
5193 version_type: None,
5194 }
5195 }
5196 #[doc = "The body for the API call"]
5197 pub fn body<T>(self, body: T) -> Mtermvectors<'a, 'b, JsonBody<T>>
5198 where
5199 T: Serialize,
5200 {
5201 Mtermvectors {
5202 transport: self.transport,
5203 parts: self.parts,
5204 body: Some(body.into()),
5205 error_trace: self.error_trace,
5206 field_statistics: self.field_statistics,
5207 fields: self.fields,
5208 filter_path: self.filter_path,
5209 headers: self.headers,
5210 human: self.human,
5211 ids: self.ids,
5212 offsets: self.offsets,
5213 payloads: self.payloads,
5214 positions: self.positions,
5215 preference: self.preference,
5216 pretty: self.pretty,
5217 realtime: self.realtime,
5218 request_timeout: self.request_timeout,
5219 routing: self.routing,
5220 source: self.source,
5221 term_statistics: self.term_statistics,
5222 version: self.version,
5223 version_type: self.version_type,
5224 }
5225 }
5226 #[doc = "Include the stack trace of returned errors."]
5227 pub fn error_trace(mut self, error_trace: bool) -> Self {
5228 self.error_trace = Some(error_trace);
5229 self
5230 }
5231 #[doc = "Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5232 pub fn field_statistics(mut self, field_statistics: bool) -> Self {
5233 self.field_statistics = Some(field_statistics);
5234 self
5235 }
5236 #[doc = "A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5237 pub fn fields(mut self, fields: &'b [&'b str]) -> Self {
5238 self.fields = Some(fields);
5239 self
5240 }
5241 #[doc = "A comma-separated list of filters used to reduce the response."]
5242 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5243 self.filter_path = Some(filter_path);
5244 self
5245 }
5246 #[doc = "Adds a HTTP header"]
5247 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5248 self.headers.insert(key, value);
5249 self
5250 }
5251 #[doc = "Return human readable values for statistics."]
5252 pub fn human(mut self, human: bool) -> Self {
5253 self.human = Some(human);
5254 self
5255 }
5256 #[doc = "A comma-separated list of documents ids. You must define ids as parameter or set \"ids\" or \"docs\" in the request body"]
5257 pub fn ids(mut self, ids: &'b [&'b str]) -> Self {
5258 self.ids = Some(ids);
5259 self
5260 }
5261 #[doc = "Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5262 pub fn offsets(mut self, offsets: bool) -> Self {
5263 self.offsets = Some(offsets);
5264 self
5265 }
5266 #[doc = "Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5267 pub fn payloads(mut self, payloads: bool) -> Self {
5268 self.payloads = Some(payloads);
5269 self
5270 }
5271 #[doc = "Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5272 pub fn positions(mut self, positions: bool) -> Self {
5273 self.positions = Some(positions);
5274 self
5275 }
5276 #[doc = "Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5277 pub fn preference(mut self, preference: &'b str) -> Self {
5278 self.preference = Some(preference);
5279 self
5280 }
5281 #[doc = "Pretty format the returned JSON response."]
5282 pub fn pretty(mut self, pretty: bool) -> Self {
5283 self.pretty = Some(pretty);
5284 self
5285 }
5286 #[doc = "Specifies if requests are real-time as opposed to near-real-time (default: true)."]
5287 pub fn realtime(mut self, realtime: bool) -> Self {
5288 self.realtime = Some(realtime);
5289 self
5290 }
5291 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
5292 pub fn request_timeout(mut self, timeout: Duration) -> Self {
5293 self.request_timeout = Some(timeout);
5294 self
5295 }
5296 #[doc = "Specific routing value. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5297 pub fn routing(mut self, routing: &'b str) -> Self {
5298 self.routing = Some(routing);
5299 self
5300 }
5301 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5302 pub fn source(mut self, source: &'b str) -> Self {
5303 self.source = Some(source);
5304 self
5305 }
5306 #[doc = "Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body \"params\" or \"docs\"."]
5307 pub fn term_statistics(mut self, term_statistics: bool) -> Self {
5308 self.term_statistics = Some(term_statistics);
5309 self
5310 }
5311 #[doc = "Explicit version number for concurrency control"]
5312 pub fn version(mut self, version: i64) -> Self {
5313 self.version = Some(version);
5314 self
5315 }
5316 #[doc = "Specific version type"]
5317 pub fn version_type(mut self, version_type: VersionType) -> Self {
5318 self.version_type = Some(version_type);
5319 self
5320 }
5321 #[doc = "Creates an asynchronous call to the Mtermvectors API that can be awaited"]
5322 pub async fn send(self) -> Result<Response, Error> {
5323 let path = self.parts.url();
5324 let method = match self.body {
5325 Some(_) => http::Method::Post,
5326 None => http::Method::Get,
5327 };
5328 let headers = self.headers;
5329 let timeout = self.request_timeout;
5330 let query_string = {
5331 #[serde_with::skip_serializing_none]
5332 #[derive(Serialize)]
5333 struct QueryParams<'b> {
5334 error_trace: Option<bool>,
5335 field_statistics: Option<bool>,
5336 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5337 fields: Option<&'b [&'b str]>,
5338 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5339 filter_path: Option<&'b [&'b str]>,
5340 human: Option<bool>,
5341 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5342 ids: Option<&'b [&'b str]>,
5343 offsets: Option<bool>,
5344 payloads: Option<bool>,
5345 positions: Option<bool>,
5346 preference: Option<&'b str>,
5347 pretty: Option<bool>,
5348 realtime: Option<bool>,
5349 routing: Option<&'b str>,
5350 source: Option<&'b str>,
5351 term_statistics: Option<bool>,
5352 version: Option<i64>,
5353 version_type: Option<VersionType>,
5354 }
5355 let query_params = QueryParams {
5356 error_trace: self.error_trace,
5357 field_statistics: self.field_statistics,
5358 fields: self.fields,
5359 filter_path: self.filter_path,
5360 human: self.human,
5361 ids: self.ids,
5362 offsets: self.offsets,
5363 payloads: self.payloads,
5364 positions: self.positions,
5365 preference: self.preference,
5366 pretty: self.pretty,
5367 realtime: self.realtime,
5368 routing: self.routing,
5369 source: self.source,
5370 term_statistics: self.term_statistics,
5371 version: self.version,
5372 version_type: self.version_type,
5373 };
5374 Some(query_params)
5375 };
5376 let body = self.body;
5377 let response = self
5378 .transport
5379 .send(method, &path, headers, query_string.as_ref(), body, timeout)
5380 .await?;
5381 Ok(response)
5382 }
5383}
5384#[derive(Debug, Clone, PartialEq, Eq)]
5385#[doc = "API parts for the Open Point In Time API"]
5386pub enum OpenPointInTimeParts<'b> {
5387 #[doc = "Index"]
5388 Index(&'b [&'b str]),
5389}
5390impl<'b> OpenPointInTimeParts<'b> {
5391 #[doc = "Builds a relative URL path to the Open Point In Time API"]
5392 pub fn url(self) -> Cow<'static, str> {
5393 match self {
5394 OpenPointInTimeParts::Index(index) => {
5395 let index_str = index.join(",");
5396 let encoded_index: Cow<str> =
5397 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
5398 let mut p = String::with_capacity(6usize + encoded_index.len());
5399 p.push('/');
5400 p.push_str(encoded_index.as_ref());
5401 p.push_str("/_pit");
5402 p.into()
5403 }
5404 }
5405 }
5406}
5407#[doc = "Builder for the [Open Point In Time API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/point-in-time-api.html)\n\nOpen a point in time that can be used in subsequent searches"]
5408#[derive(Clone, Debug)]
5409pub struct OpenPointInTime<'a, 'b, B> {
5410 transport: &'a Transport,
5411 parts: OpenPointInTimeParts<'b>,
5412 allow_partial_search_results: Option<bool>,
5413 body: Option<B>,
5414 error_trace: Option<bool>,
5415 expand_wildcards: Option<&'b [ExpandWildcards]>,
5416 filter_path: Option<&'b [&'b str]>,
5417 headers: HeaderMap,
5418 human: Option<bool>,
5419 ignore_unavailable: Option<bool>,
5420 keep_alive: Option<&'b str>,
5421 preference: Option<&'b str>,
5422 pretty: Option<bool>,
5423 request_timeout: Option<Duration>,
5424 routing: Option<&'b str>,
5425 source: Option<&'b str>,
5426}
5427impl<'a, 'b, B> OpenPointInTime<'a, 'b, B>
5428where
5429 B: Body,
5430{
5431 #[doc = "Creates a new instance of [OpenPointInTime] with the specified API parts"]
5432 pub fn new(transport: &'a Transport, parts: OpenPointInTimeParts<'b>) -> Self {
5433 let headers = HeaderMap::new();
5434 OpenPointInTime {
5435 transport,
5436 parts,
5437 headers,
5438 allow_partial_search_results: None,
5439 body: None,
5440 error_trace: None,
5441 expand_wildcards: None,
5442 filter_path: None,
5443 human: None,
5444 ignore_unavailable: None,
5445 keep_alive: None,
5446 preference: None,
5447 pretty: None,
5448 request_timeout: None,
5449 routing: None,
5450 source: None,
5451 }
5452 }
5453 #[doc = "Specify whether to tolerate shards missing when creating the point-in-time, or otherwise throw an exception. (default: false)"]
5454 pub fn allow_partial_search_results(mut self, allow_partial_search_results: bool) -> Self {
5455 self.allow_partial_search_results = Some(allow_partial_search_results);
5456 self
5457 }
5458 #[doc = "The body for the API call"]
5459 pub fn body<T>(self, body: T) -> OpenPointInTime<'a, 'b, JsonBody<T>>
5460 where
5461 T: Serialize,
5462 {
5463 OpenPointInTime {
5464 transport: self.transport,
5465 parts: self.parts,
5466 body: Some(body.into()),
5467 allow_partial_search_results: self.allow_partial_search_results,
5468 error_trace: self.error_trace,
5469 expand_wildcards: self.expand_wildcards,
5470 filter_path: self.filter_path,
5471 headers: self.headers,
5472 human: self.human,
5473 ignore_unavailable: self.ignore_unavailable,
5474 keep_alive: self.keep_alive,
5475 preference: self.preference,
5476 pretty: self.pretty,
5477 request_timeout: self.request_timeout,
5478 routing: self.routing,
5479 source: self.source,
5480 }
5481 }
5482 #[doc = "Include the stack trace of returned errors."]
5483 pub fn error_trace(mut self, error_trace: bool) -> Self {
5484 self.error_trace = Some(error_trace);
5485 self
5486 }
5487 #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
5488 pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
5489 self.expand_wildcards = Some(expand_wildcards);
5490 self
5491 }
5492 #[doc = "A comma-separated list of filters used to reduce the response."]
5493 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5494 self.filter_path = Some(filter_path);
5495 self
5496 }
5497 #[doc = "Adds a HTTP header"]
5498 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5499 self.headers.insert(key, value);
5500 self
5501 }
5502 #[doc = "Return human readable values for statistics."]
5503 pub fn human(mut self, human: bool) -> Self {
5504 self.human = Some(human);
5505 self
5506 }
5507 #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
5508 pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
5509 self.ignore_unavailable = Some(ignore_unavailable);
5510 self
5511 }
5512 #[doc = "Specific the time to live for the point in time"]
5513 pub fn keep_alive(mut self, keep_alive: &'b str) -> Self {
5514 self.keep_alive = Some(keep_alive);
5515 self
5516 }
5517 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
5518 pub fn preference(mut self, preference: &'b str) -> Self {
5519 self.preference = Some(preference);
5520 self
5521 }
5522 #[doc = "Pretty format the returned JSON response."]
5523 pub fn pretty(mut self, pretty: bool) -> Self {
5524 self.pretty = Some(pretty);
5525 self
5526 }
5527 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
5528 pub fn request_timeout(mut self, timeout: Duration) -> Self {
5529 self.request_timeout = Some(timeout);
5530 self
5531 }
5532 #[doc = "Specific routing value"]
5533 pub fn routing(mut self, routing: &'b str) -> Self {
5534 self.routing = Some(routing);
5535 self
5536 }
5537 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5538 pub fn source(mut self, source: &'b str) -> Self {
5539 self.source = Some(source);
5540 self
5541 }
5542 #[doc = "Creates an asynchronous call to the Open Point In Time API that can be awaited"]
5543 pub async fn send(self) -> Result<Response, Error> {
5544 let path = self.parts.url();
5545 let method = http::Method::Post;
5546 let headers = self.headers;
5547 let timeout = self.request_timeout;
5548 let query_string = {
5549 #[serde_with::skip_serializing_none]
5550 #[derive(Serialize)]
5551 struct QueryParams<'b> {
5552 allow_partial_search_results: Option<bool>,
5553 error_trace: Option<bool>,
5554 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5555 expand_wildcards: Option<&'b [ExpandWildcards]>,
5556 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5557 filter_path: Option<&'b [&'b str]>,
5558 human: Option<bool>,
5559 ignore_unavailable: Option<bool>,
5560 keep_alive: Option<&'b str>,
5561 preference: Option<&'b str>,
5562 pretty: Option<bool>,
5563 routing: Option<&'b str>,
5564 source: Option<&'b str>,
5565 }
5566 let query_params = QueryParams {
5567 allow_partial_search_results: self.allow_partial_search_results,
5568 error_trace: self.error_trace,
5569 expand_wildcards: self.expand_wildcards,
5570 filter_path: self.filter_path,
5571 human: self.human,
5572 ignore_unavailable: self.ignore_unavailable,
5573 keep_alive: self.keep_alive,
5574 preference: self.preference,
5575 pretty: self.pretty,
5576 routing: self.routing,
5577 source: self.source,
5578 };
5579 Some(query_params)
5580 };
5581 let body = self.body;
5582 let response = self
5583 .transport
5584 .send(method, &path, headers, query_string.as_ref(), body, timeout)
5585 .await?;
5586 Ok(response)
5587 }
5588}
5589#[derive(Debug, Clone, PartialEq, Eq)]
5590#[doc = "API parts for the Ping API"]
5591pub enum PingParts {
5592 #[doc = "No parts"]
5593 None,
5594}
5595impl PingParts {
5596 #[doc = "Builds a relative URL path to the Ping API"]
5597 pub fn url(self) -> Cow<'static, str> {
5598 match self {
5599 PingParts::None => "/".into(),
5600 }
5601 }
5602}
5603#[doc = "Builder for the [Ping API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/index.html)\n\nReturns whether the cluster is running."]
5604#[derive(Clone, Debug)]
5605pub struct Ping<'a, 'b> {
5606 transport: &'a Transport,
5607 parts: PingParts,
5608 error_trace: Option<bool>,
5609 filter_path: Option<&'b [&'b str]>,
5610 headers: HeaderMap,
5611 human: Option<bool>,
5612 pretty: Option<bool>,
5613 request_timeout: Option<Duration>,
5614 source: Option<&'b str>,
5615}
5616impl<'a, 'b> Ping<'a, 'b> {
5617 #[doc = "Creates a new instance of [Ping]"]
5618 pub fn new(transport: &'a Transport) -> Self {
5619 let headers = HeaderMap::new();
5620 Ping {
5621 transport,
5622 parts: PingParts::None,
5623 headers,
5624 error_trace: None,
5625 filter_path: None,
5626 human: None,
5627 pretty: None,
5628 request_timeout: None,
5629 source: None,
5630 }
5631 }
5632 #[doc = "Include the stack trace of returned errors."]
5633 pub fn error_trace(mut self, error_trace: bool) -> Self {
5634 self.error_trace = Some(error_trace);
5635 self
5636 }
5637 #[doc = "A comma-separated list of filters used to reduce the response."]
5638 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5639 self.filter_path = Some(filter_path);
5640 self
5641 }
5642 #[doc = "Adds a HTTP header"]
5643 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5644 self.headers.insert(key, value);
5645 self
5646 }
5647 #[doc = "Return human readable values for statistics."]
5648 pub fn human(mut self, human: bool) -> Self {
5649 self.human = Some(human);
5650 self
5651 }
5652 #[doc = "Pretty format the returned JSON response."]
5653 pub fn pretty(mut self, pretty: bool) -> Self {
5654 self.pretty = Some(pretty);
5655 self
5656 }
5657 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
5658 pub fn request_timeout(mut self, timeout: Duration) -> Self {
5659 self.request_timeout = Some(timeout);
5660 self
5661 }
5662 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5663 pub fn source(mut self, source: &'b str) -> Self {
5664 self.source = Some(source);
5665 self
5666 }
5667 #[doc = "Creates an asynchronous call to the Ping API that can be awaited"]
5668 pub async fn send(self) -> Result<Response, Error> {
5669 let path = self.parts.url();
5670 let method = http::Method::Head;
5671 let headers = self.headers;
5672 let timeout = self.request_timeout;
5673 let query_string = {
5674 #[serde_with::skip_serializing_none]
5675 #[derive(Serialize)]
5676 struct QueryParams<'b> {
5677 error_trace: Option<bool>,
5678 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5679 filter_path: Option<&'b [&'b str]>,
5680 human: Option<bool>,
5681 pretty: Option<bool>,
5682 source: Option<&'b str>,
5683 }
5684 let query_params = QueryParams {
5685 error_trace: self.error_trace,
5686 filter_path: self.filter_path,
5687 human: self.human,
5688 pretty: self.pretty,
5689 source: self.source,
5690 };
5691 Some(query_params)
5692 };
5693 let body = Option::<()>::None;
5694 let response = self
5695 .transport
5696 .send(method, &path, headers, query_string.as_ref(), body, timeout)
5697 .await?;
5698 Ok(response)
5699 }
5700}
5701#[derive(Debug, Clone, PartialEq, Eq)]
5702#[doc = "API parts for the Put Script API"]
5703pub enum PutScriptParts<'b> {
5704 #[doc = "Id"]
5705 Id(&'b str),
5706 #[doc = "Id and Context"]
5707 IdContext(&'b str, &'b str),
5708}
5709impl<'b> PutScriptParts<'b> {
5710 #[doc = "Builds a relative URL path to the Put Script API"]
5711 pub fn url(self) -> Cow<'static, str> {
5712 match self {
5713 PutScriptParts::Id(id) => {
5714 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
5715 let mut p = String::with_capacity(10usize + encoded_id.len());
5716 p.push_str("/_scripts/");
5717 p.push_str(encoded_id.as_ref());
5718 p.into()
5719 }
5720 PutScriptParts::IdContext(id, context) => {
5721 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
5722 let encoded_context: Cow<str> =
5723 percent_encode(context.as_bytes(), PARTS_ENCODED).into();
5724 let mut p =
5725 String::with_capacity(11usize + encoded_id.len() + encoded_context.len());
5726 p.push_str("/_scripts/");
5727 p.push_str(encoded_id.as_ref());
5728 p.push('/');
5729 p.push_str(encoded_context.as_ref());
5730 p.into()
5731 }
5732 }
5733 }
5734}
5735#[doc = "Builder for the [Put Script API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/modules-scripting.html)\n\nCreates or updates a script."]
5736#[derive(Clone, Debug)]
5737pub struct PutScript<'a, 'b, B> {
5738 transport: &'a Transport,
5739 parts: PutScriptParts<'b>,
5740 body: Option<B>,
5741 context: Option<&'b str>,
5742 error_trace: Option<bool>,
5743 filter_path: Option<&'b [&'b str]>,
5744 headers: HeaderMap,
5745 human: Option<bool>,
5746 master_timeout: Option<&'b str>,
5747 pretty: Option<bool>,
5748 request_timeout: Option<Duration>,
5749 source: Option<&'b str>,
5750 timeout: Option<&'b str>,
5751}
5752impl<'a, 'b, B> PutScript<'a, 'b, B>
5753where
5754 B: Body,
5755{
5756 #[doc = "Creates a new instance of [PutScript] with the specified API parts"]
5757 pub fn new(transport: &'a Transport, parts: PutScriptParts<'b>) -> Self {
5758 let headers = HeaderMap::new();
5759 PutScript {
5760 transport,
5761 parts,
5762 headers,
5763 body: None,
5764 context: None,
5765 error_trace: None,
5766 filter_path: None,
5767 human: None,
5768 master_timeout: None,
5769 pretty: None,
5770 request_timeout: None,
5771 source: None,
5772 timeout: None,
5773 }
5774 }
5775 #[doc = "The body for the API call"]
5776 pub fn body<T>(self, body: T) -> PutScript<'a, 'b, JsonBody<T>>
5777 where
5778 T: Serialize,
5779 {
5780 PutScript {
5781 transport: self.transport,
5782 parts: self.parts,
5783 body: Some(body.into()),
5784 context: self.context,
5785 error_trace: self.error_trace,
5786 filter_path: self.filter_path,
5787 headers: self.headers,
5788 human: self.human,
5789 master_timeout: self.master_timeout,
5790 pretty: self.pretty,
5791 request_timeout: self.request_timeout,
5792 source: self.source,
5793 timeout: self.timeout,
5794 }
5795 }
5796 #[doc = "Context name to compile script against"]
5797 pub fn context(mut self, context: &'b str) -> Self {
5798 self.context = Some(context);
5799 self
5800 }
5801 #[doc = "Include the stack trace of returned errors."]
5802 pub fn error_trace(mut self, error_trace: bool) -> Self {
5803 self.error_trace = Some(error_trace);
5804 self
5805 }
5806 #[doc = "A comma-separated list of filters used to reduce the response."]
5807 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5808 self.filter_path = Some(filter_path);
5809 self
5810 }
5811 #[doc = "Adds a HTTP header"]
5812 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5813 self.headers.insert(key, value);
5814 self
5815 }
5816 #[doc = "Return human readable values for statistics."]
5817 pub fn human(mut self, human: bool) -> Self {
5818 self.human = Some(human);
5819 self
5820 }
5821 #[doc = "Specify timeout for connection to master"]
5822 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
5823 self.master_timeout = Some(master_timeout);
5824 self
5825 }
5826 #[doc = "Pretty format the returned JSON response."]
5827 pub fn pretty(mut self, pretty: bool) -> Self {
5828 self.pretty = Some(pretty);
5829 self
5830 }
5831 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
5832 pub fn request_timeout(mut self, timeout: Duration) -> Self {
5833 self.request_timeout = Some(timeout);
5834 self
5835 }
5836 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
5837 pub fn source(mut self, source: &'b str) -> Self {
5838 self.source = Some(source);
5839 self
5840 }
5841 #[doc = "Explicit operation timeout"]
5842 pub fn timeout(mut self, timeout: &'b str) -> Self {
5843 self.timeout = Some(timeout);
5844 self
5845 }
5846 #[doc = "Creates an asynchronous call to the Put Script API that can be awaited"]
5847 pub async fn send(self) -> Result<Response, Error> {
5848 let path = self.parts.url();
5849 let method = http::Method::Put;
5850 let headers = self.headers;
5851 let timeout = self.request_timeout;
5852 let query_string = {
5853 #[serde_with::skip_serializing_none]
5854 #[derive(Serialize)]
5855 struct QueryParams<'b> {
5856 context: Option<&'b str>,
5857 error_trace: Option<bool>,
5858 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
5859 filter_path: Option<&'b [&'b str]>,
5860 human: Option<bool>,
5861 master_timeout: Option<&'b str>,
5862 pretty: Option<bool>,
5863 source: Option<&'b str>,
5864 timeout: Option<&'b str>,
5865 }
5866 let query_params = QueryParams {
5867 context: self.context,
5868 error_trace: self.error_trace,
5869 filter_path: self.filter_path,
5870 human: self.human,
5871 master_timeout: self.master_timeout,
5872 pretty: self.pretty,
5873 source: self.source,
5874 timeout: self.timeout,
5875 };
5876 Some(query_params)
5877 };
5878 let body = self.body;
5879 let response = self
5880 .transport
5881 .send(method, &path, headers, query_string.as_ref(), body, timeout)
5882 .await?;
5883 Ok(response)
5884 }
5885}
5886#[derive(Debug, Clone, PartialEq, Eq)]
5887#[doc = "API parts for the Rank Eval API"]
5888pub enum RankEvalParts<'b> {
5889 #[doc = "No parts"]
5890 None,
5891 #[doc = "Index"]
5892 Index(&'b [&'b str]),
5893}
5894impl<'b> RankEvalParts<'b> {
5895 #[doc = "Builds a relative URL path to the Rank Eval API"]
5896 pub fn url(self) -> Cow<'static, str> {
5897 match self {
5898 RankEvalParts::None => "/_rank_eval".into(),
5899 RankEvalParts::Index(index) => {
5900 let index_str = index.join(",");
5901 let encoded_index: Cow<str> =
5902 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
5903 let mut p = String::with_capacity(12usize + encoded_index.len());
5904 p.push('/');
5905 p.push_str(encoded_index.as_ref());
5906 p.push_str("/_rank_eval");
5907 p.into()
5908 }
5909 }
5910 }
5911}
5912#[doc = "Builder for the [Rank Eval API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-rank-eval.html)\n\nAllows to evaluate the quality of ranked search results over a set of typical search queries"]
5913#[derive(Clone, Debug)]
5914pub struct RankEval<'a, 'b, B> {
5915 transport: &'a Transport,
5916 parts: RankEvalParts<'b>,
5917 allow_no_indices: Option<bool>,
5918 body: Option<B>,
5919 error_trace: Option<bool>,
5920 expand_wildcards: Option<&'b [ExpandWildcards]>,
5921 filter_path: Option<&'b [&'b str]>,
5922 headers: HeaderMap,
5923 human: Option<bool>,
5924 ignore_unavailable: Option<bool>,
5925 pretty: Option<bool>,
5926 request_timeout: Option<Duration>,
5927 search_type: Option<SearchType>,
5928 source: Option<&'b str>,
5929}
5930impl<'a, 'b, B> RankEval<'a, 'b, B>
5931where
5932 B: Body,
5933{
5934 #[doc = "Creates a new instance of [RankEval] with the specified API parts"]
5935 pub fn new(transport: &'a Transport, parts: RankEvalParts<'b>) -> Self {
5936 let headers = HeaderMap::new();
5937 RankEval {
5938 transport,
5939 parts,
5940 headers,
5941 allow_no_indices: None,
5942 body: None,
5943 error_trace: None,
5944 expand_wildcards: None,
5945 filter_path: None,
5946 human: None,
5947 ignore_unavailable: None,
5948 pretty: None,
5949 request_timeout: None,
5950 search_type: None,
5951 source: None,
5952 }
5953 }
5954 #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
5955 pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
5956 self.allow_no_indices = Some(allow_no_indices);
5957 self
5958 }
5959 #[doc = "The body for the API call"]
5960 pub fn body<T>(self, body: T) -> RankEval<'a, 'b, JsonBody<T>>
5961 where
5962 T: Serialize,
5963 {
5964 RankEval {
5965 transport: self.transport,
5966 parts: self.parts,
5967 body: Some(body.into()),
5968 allow_no_indices: self.allow_no_indices,
5969 error_trace: self.error_trace,
5970 expand_wildcards: self.expand_wildcards,
5971 filter_path: self.filter_path,
5972 headers: self.headers,
5973 human: self.human,
5974 ignore_unavailable: self.ignore_unavailable,
5975 pretty: self.pretty,
5976 request_timeout: self.request_timeout,
5977 search_type: self.search_type,
5978 source: self.source,
5979 }
5980 }
5981 #[doc = "Include the stack trace of returned errors."]
5982 pub fn error_trace(mut self, error_trace: bool) -> Self {
5983 self.error_trace = Some(error_trace);
5984 self
5985 }
5986 #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
5987 pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
5988 self.expand_wildcards = Some(expand_wildcards);
5989 self
5990 }
5991 #[doc = "A comma-separated list of filters used to reduce the response."]
5992 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
5993 self.filter_path = Some(filter_path);
5994 self
5995 }
5996 #[doc = "Adds a HTTP header"]
5997 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
5998 self.headers.insert(key, value);
5999 self
6000 }
6001 #[doc = "Return human readable values for statistics."]
6002 pub fn human(mut self, human: bool) -> Self {
6003 self.human = Some(human);
6004 self
6005 }
6006 #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
6007 pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
6008 self.ignore_unavailable = Some(ignore_unavailable);
6009 self
6010 }
6011 #[doc = "Pretty format the returned JSON response."]
6012 pub fn pretty(mut self, pretty: bool) -> Self {
6013 self.pretty = Some(pretty);
6014 self
6015 }
6016 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
6017 pub fn request_timeout(mut self, timeout: Duration) -> Self {
6018 self.request_timeout = Some(timeout);
6019 self
6020 }
6021 #[doc = "Search operation type"]
6022 pub fn search_type(mut self, search_type: SearchType) -> Self {
6023 self.search_type = Some(search_type);
6024 self
6025 }
6026 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6027 pub fn source(mut self, source: &'b str) -> Self {
6028 self.source = Some(source);
6029 self
6030 }
6031 #[doc = "Creates an asynchronous call to the Rank Eval API that can be awaited"]
6032 pub async fn send(self) -> Result<Response, Error> {
6033 let path = self.parts.url();
6034 let method = match self.body {
6035 Some(_) => http::Method::Post,
6036 None => http::Method::Get,
6037 };
6038 let headers = self.headers;
6039 let timeout = self.request_timeout;
6040 let query_string = {
6041 #[serde_with::skip_serializing_none]
6042 #[derive(Serialize)]
6043 struct QueryParams<'b> {
6044 allow_no_indices: Option<bool>,
6045 error_trace: Option<bool>,
6046 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6047 expand_wildcards: Option<&'b [ExpandWildcards]>,
6048 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6049 filter_path: Option<&'b [&'b str]>,
6050 human: Option<bool>,
6051 ignore_unavailable: Option<bool>,
6052 pretty: Option<bool>,
6053 search_type: Option<SearchType>,
6054 source: Option<&'b str>,
6055 }
6056 let query_params = QueryParams {
6057 allow_no_indices: self.allow_no_indices,
6058 error_trace: self.error_trace,
6059 expand_wildcards: self.expand_wildcards,
6060 filter_path: self.filter_path,
6061 human: self.human,
6062 ignore_unavailable: self.ignore_unavailable,
6063 pretty: self.pretty,
6064 search_type: self.search_type,
6065 source: self.source,
6066 };
6067 Some(query_params)
6068 };
6069 let body = self.body;
6070 let response = self
6071 .transport
6072 .send(method, &path, headers, query_string.as_ref(), body, timeout)
6073 .await?;
6074 Ok(response)
6075 }
6076}
6077#[derive(Debug, Clone, PartialEq, Eq)]
6078#[doc = "API parts for the Reindex API"]
6079pub enum ReindexParts {
6080 #[doc = "No parts"]
6081 None,
6082}
6083impl ReindexParts {
6084 #[doc = "Builds a relative URL path to the Reindex API"]
6085 pub fn url(self) -> Cow<'static, str> {
6086 match self {
6087 ReindexParts::None => "/_reindex".into(),
6088 }
6089 }
6090}
6091#[doc = "Builder for the [Reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-reindex.html)\n\nAllows to copy documents from one index to another, optionally filtering the source\ndocuments by a query, changing the destination index settings, or fetching the\ndocuments from a remote cluster."]
6092#[derive(Clone, Debug)]
6093pub struct Reindex<'a, 'b, B> {
6094 transport: &'a Transport,
6095 parts: ReindexParts,
6096 body: Option<B>,
6097 error_trace: Option<bool>,
6098 filter_path: Option<&'b [&'b str]>,
6099 headers: HeaderMap,
6100 human: Option<bool>,
6101 max_docs: Option<i64>,
6102 pretty: Option<bool>,
6103 refresh: Option<bool>,
6104 request_timeout: Option<Duration>,
6105 requests_per_second: Option<i64>,
6106 scroll: Option<&'b str>,
6107 slices: Option<Slices>,
6108 source: Option<&'b str>,
6109 timeout: Option<&'b str>,
6110 wait_for_active_shards: Option<&'b str>,
6111 wait_for_completion: Option<bool>,
6112}
6113impl<'a, 'b, B> Reindex<'a, 'b, B>
6114where
6115 B: Body,
6116{
6117 #[doc = "Creates a new instance of [Reindex]"]
6118 pub fn new(transport: &'a Transport) -> Self {
6119 let headers = HeaderMap::new();
6120 Reindex {
6121 transport,
6122 parts: ReindexParts::None,
6123 headers,
6124 body: None,
6125 error_trace: None,
6126 filter_path: None,
6127 human: None,
6128 max_docs: None,
6129 pretty: None,
6130 refresh: None,
6131 request_timeout: None,
6132 requests_per_second: None,
6133 scroll: None,
6134 slices: None,
6135 source: None,
6136 timeout: None,
6137 wait_for_active_shards: None,
6138 wait_for_completion: None,
6139 }
6140 }
6141 #[doc = "The body for the API call"]
6142 pub fn body<T>(self, body: T) -> Reindex<'a, 'b, JsonBody<T>>
6143 where
6144 T: Serialize,
6145 {
6146 Reindex {
6147 transport: self.transport,
6148 parts: self.parts,
6149 body: Some(body.into()),
6150 error_trace: self.error_trace,
6151 filter_path: self.filter_path,
6152 headers: self.headers,
6153 human: self.human,
6154 max_docs: self.max_docs,
6155 pretty: self.pretty,
6156 refresh: self.refresh,
6157 request_timeout: self.request_timeout,
6158 requests_per_second: self.requests_per_second,
6159 scroll: self.scroll,
6160 slices: self.slices,
6161 source: self.source,
6162 timeout: self.timeout,
6163 wait_for_active_shards: self.wait_for_active_shards,
6164 wait_for_completion: self.wait_for_completion,
6165 }
6166 }
6167 #[doc = "Include the stack trace of returned errors."]
6168 pub fn error_trace(mut self, error_trace: bool) -> Self {
6169 self.error_trace = Some(error_trace);
6170 self
6171 }
6172 #[doc = "A comma-separated list of filters used to reduce the response."]
6173 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6174 self.filter_path = Some(filter_path);
6175 self
6176 }
6177 #[doc = "Adds a HTTP header"]
6178 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6179 self.headers.insert(key, value);
6180 self
6181 }
6182 #[doc = "Return human readable values for statistics."]
6183 pub fn human(mut self, human: bool) -> Self {
6184 self.human = Some(human);
6185 self
6186 }
6187 #[doc = "Maximum number of documents to process (default: all documents)"]
6188 pub fn max_docs(mut self, max_docs: i64) -> Self {
6189 self.max_docs = Some(max_docs);
6190 self
6191 }
6192 #[doc = "Pretty format the returned JSON response."]
6193 pub fn pretty(mut self, pretty: bool) -> Self {
6194 self.pretty = Some(pretty);
6195 self
6196 }
6197 #[doc = "Should the affected indexes be refreshed?"]
6198 pub fn refresh(mut self, refresh: bool) -> Self {
6199 self.refresh = Some(refresh);
6200 self
6201 }
6202 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
6203 pub fn request_timeout(mut self, timeout: Duration) -> Self {
6204 self.request_timeout = Some(timeout);
6205 self
6206 }
6207 #[doc = "The throttle to set on this request in sub-requests per second. -1 means no throttle."]
6208 pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
6209 self.requests_per_second = Some(requests_per_second);
6210 self
6211 }
6212 #[doc = "Control how long to keep the search context alive"]
6213 pub fn scroll(mut self, scroll: &'b str) -> Self {
6214 self.scroll = Some(scroll);
6215 self
6216 }
6217 #[doc = "The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`."]
6218 pub fn slices(mut self, slices: Slices) -> Self {
6219 self.slices = Some(slices);
6220 self
6221 }
6222 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6223 pub fn source(mut self, source: &'b str) -> Self {
6224 self.source = Some(source);
6225 self
6226 }
6227 #[doc = "Time each individual bulk request should wait for shards that are unavailable."]
6228 pub fn timeout(mut self, timeout: &'b str) -> Self {
6229 self.timeout = Some(timeout);
6230 self
6231 }
6232 #[doc = "Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"]
6233 pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
6234 self.wait_for_active_shards = Some(wait_for_active_shards);
6235 self
6236 }
6237 #[doc = "Should the request should block until the reindex is complete."]
6238 pub fn wait_for_completion(mut self, wait_for_completion: bool) -> Self {
6239 self.wait_for_completion = Some(wait_for_completion);
6240 self
6241 }
6242 #[doc = "Creates an asynchronous call to the Reindex API that can be awaited"]
6243 pub async fn send(self) -> Result<Response, Error> {
6244 let path = self.parts.url();
6245 let method = http::Method::Post;
6246 let headers = self.headers;
6247 let timeout = self.request_timeout;
6248 let query_string = {
6249 #[serde_with::skip_serializing_none]
6250 #[derive(Serialize)]
6251 struct QueryParams<'b> {
6252 error_trace: Option<bool>,
6253 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6254 filter_path: Option<&'b [&'b str]>,
6255 human: Option<bool>,
6256 max_docs: Option<i64>,
6257 pretty: Option<bool>,
6258 refresh: Option<bool>,
6259 requests_per_second: Option<i64>,
6260 scroll: Option<&'b str>,
6261 slices: Option<Slices>,
6262 source: Option<&'b str>,
6263 timeout: Option<&'b str>,
6264 wait_for_active_shards: Option<&'b str>,
6265 wait_for_completion: Option<bool>,
6266 }
6267 let query_params = QueryParams {
6268 error_trace: self.error_trace,
6269 filter_path: self.filter_path,
6270 human: self.human,
6271 max_docs: self.max_docs,
6272 pretty: self.pretty,
6273 refresh: self.refresh,
6274 requests_per_second: self.requests_per_second,
6275 scroll: self.scroll,
6276 slices: self.slices,
6277 source: self.source,
6278 timeout: self.timeout,
6279 wait_for_active_shards: self.wait_for_active_shards,
6280 wait_for_completion: self.wait_for_completion,
6281 };
6282 Some(query_params)
6283 };
6284 let body = self.body;
6285 let response = self
6286 .transport
6287 .send(method, &path, headers, query_string.as_ref(), body, timeout)
6288 .await?;
6289 Ok(response)
6290 }
6291}
6292#[derive(Debug, Clone, PartialEq, Eq)]
6293#[doc = "API parts for the Reindex Rethrottle API"]
6294pub enum ReindexRethrottleParts<'b> {
6295 #[doc = "TaskId"]
6296 TaskId(&'b str),
6297}
6298impl<'b> ReindexRethrottleParts<'b> {
6299 #[doc = "Builds a relative URL path to the Reindex Rethrottle API"]
6300 pub fn url(self) -> Cow<'static, str> {
6301 match self {
6302 ReindexRethrottleParts::TaskId(task_id) => {
6303 let encoded_task_id: Cow<str> =
6304 percent_encode(task_id.as_bytes(), PARTS_ENCODED).into();
6305 let mut p = String::with_capacity(22usize + encoded_task_id.len());
6306 p.push_str("/_reindex/");
6307 p.push_str(encoded_task_id.as_ref());
6308 p.push_str("/_rethrottle");
6309 p.into()
6310 }
6311 }
6312 }
6313}
6314#[doc = "Builder for the [Reindex Rethrottle API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-reindex.html)\n\nChanges the number of requests per second for a particular Reindex operation."]
6315#[derive(Clone, Debug)]
6316pub struct ReindexRethrottle<'a, 'b, B> {
6317 transport: &'a Transport,
6318 parts: ReindexRethrottleParts<'b>,
6319 body: Option<B>,
6320 error_trace: Option<bool>,
6321 filter_path: Option<&'b [&'b str]>,
6322 headers: HeaderMap,
6323 human: Option<bool>,
6324 pretty: Option<bool>,
6325 request_timeout: Option<Duration>,
6326 requests_per_second: Option<i64>,
6327 source: Option<&'b str>,
6328}
6329impl<'a, 'b, B> ReindexRethrottle<'a, 'b, B>
6330where
6331 B: Body,
6332{
6333 #[doc = "Creates a new instance of [ReindexRethrottle] with the specified API parts"]
6334 pub fn new(transport: &'a Transport, parts: ReindexRethrottleParts<'b>) -> Self {
6335 let headers = HeaderMap::new();
6336 ReindexRethrottle {
6337 transport,
6338 parts,
6339 headers,
6340 body: None,
6341 error_trace: None,
6342 filter_path: None,
6343 human: None,
6344 pretty: None,
6345 request_timeout: None,
6346 requests_per_second: None,
6347 source: None,
6348 }
6349 }
6350 #[doc = "The body for the API call"]
6351 pub fn body<T>(self, body: T) -> ReindexRethrottle<'a, 'b, JsonBody<T>>
6352 where
6353 T: Serialize,
6354 {
6355 ReindexRethrottle {
6356 transport: self.transport,
6357 parts: self.parts,
6358 body: Some(body.into()),
6359 error_trace: self.error_trace,
6360 filter_path: self.filter_path,
6361 headers: self.headers,
6362 human: self.human,
6363 pretty: self.pretty,
6364 request_timeout: self.request_timeout,
6365 requests_per_second: self.requests_per_second,
6366 source: self.source,
6367 }
6368 }
6369 #[doc = "Include the stack trace of returned errors."]
6370 pub fn error_trace(mut self, error_trace: bool) -> Self {
6371 self.error_trace = Some(error_trace);
6372 self
6373 }
6374 #[doc = "A comma-separated list of filters used to reduce the response."]
6375 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6376 self.filter_path = Some(filter_path);
6377 self
6378 }
6379 #[doc = "Adds a HTTP header"]
6380 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6381 self.headers.insert(key, value);
6382 self
6383 }
6384 #[doc = "Return human readable values for statistics."]
6385 pub fn human(mut self, human: bool) -> Self {
6386 self.human = Some(human);
6387 self
6388 }
6389 #[doc = "Pretty format the returned JSON response."]
6390 pub fn pretty(mut self, pretty: bool) -> Self {
6391 self.pretty = Some(pretty);
6392 self
6393 }
6394 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
6395 pub fn request_timeout(mut self, timeout: Duration) -> Self {
6396 self.request_timeout = Some(timeout);
6397 self
6398 }
6399 #[doc = "The throttle to set on this request in floating sub-requests per second. -1 means set no throttle."]
6400 pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
6401 self.requests_per_second = Some(requests_per_second);
6402 self
6403 }
6404 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6405 pub fn source(mut self, source: &'b str) -> Self {
6406 self.source = Some(source);
6407 self
6408 }
6409 #[doc = "Creates an asynchronous call to the Reindex Rethrottle API that can be awaited"]
6410 pub async fn send(self) -> Result<Response, Error> {
6411 let path = self.parts.url();
6412 let method = http::Method::Post;
6413 let headers = self.headers;
6414 let timeout = self.request_timeout;
6415 let query_string = {
6416 #[serde_with::skip_serializing_none]
6417 #[derive(Serialize)]
6418 struct QueryParams<'b> {
6419 error_trace: Option<bool>,
6420 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6421 filter_path: Option<&'b [&'b str]>,
6422 human: Option<bool>,
6423 pretty: Option<bool>,
6424 requests_per_second: Option<i64>,
6425 source: Option<&'b str>,
6426 }
6427 let query_params = QueryParams {
6428 error_trace: self.error_trace,
6429 filter_path: self.filter_path,
6430 human: self.human,
6431 pretty: self.pretty,
6432 requests_per_second: self.requests_per_second,
6433 source: self.source,
6434 };
6435 Some(query_params)
6436 };
6437 let body = self.body;
6438 let response = self
6439 .transport
6440 .send(method, &path, headers, query_string.as_ref(), body, timeout)
6441 .await?;
6442 Ok(response)
6443 }
6444}
6445#[derive(Debug, Clone, PartialEq, Eq)]
6446#[doc = "API parts for the Render Search Template API"]
6447pub enum RenderSearchTemplateParts<'b> {
6448 #[doc = "No parts"]
6449 None,
6450 #[doc = "Id"]
6451 Id(&'b str),
6452}
6453impl<'b> RenderSearchTemplateParts<'b> {
6454 #[doc = "Builds a relative URL path to the Render Search Template API"]
6455 pub fn url(self) -> Cow<'static, str> {
6456 match self {
6457 RenderSearchTemplateParts::None => "/_render/template".into(),
6458 RenderSearchTemplateParts::Id(id) => {
6459 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
6460 let mut p = String::with_capacity(18usize + encoded_id.len());
6461 p.push_str("/_render/template/");
6462 p.push_str(encoded_id.as_ref());
6463 p.into()
6464 }
6465 }
6466 }
6467}
6468#[doc = "Builder for the [Render Search Template API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/render-search-template-api.html)\n\nAllows to use the Mustache language to pre-render a search definition."]
6469#[derive(Clone, Debug)]
6470pub struct RenderSearchTemplate<'a, 'b, B> {
6471 transport: &'a Transport,
6472 parts: RenderSearchTemplateParts<'b>,
6473 body: Option<B>,
6474 error_trace: Option<bool>,
6475 filter_path: Option<&'b [&'b str]>,
6476 headers: HeaderMap,
6477 human: Option<bool>,
6478 pretty: Option<bool>,
6479 request_timeout: Option<Duration>,
6480 source: Option<&'b str>,
6481}
6482impl<'a, 'b, B> RenderSearchTemplate<'a, 'b, B>
6483where
6484 B: Body,
6485{
6486 #[doc = "Creates a new instance of [RenderSearchTemplate] with the specified API parts"]
6487 pub fn new(transport: &'a Transport, parts: RenderSearchTemplateParts<'b>) -> Self {
6488 let headers = HeaderMap::new();
6489 RenderSearchTemplate {
6490 transport,
6491 parts,
6492 headers,
6493 body: None,
6494 error_trace: None,
6495 filter_path: None,
6496 human: None,
6497 pretty: None,
6498 request_timeout: None,
6499 source: None,
6500 }
6501 }
6502 #[doc = "The body for the API call"]
6503 pub fn body<T>(self, body: T) -> RenderSearchTemplate<'a, 'b, JsonBody<T>>
6504 where
6505 T: Serialize,
6506 {
6507 RenderSearchTemplate {
6508 transport: self.transport,
6509 parts: self.parts,
6510 body: Some(body.into()),
6511 error_trace: self.error_trace,
6512 filter_path: self.filter_path,
6513 headers: self.headers,
6514 human: self.human,
6515 pretty: self.pretty,
6516 request_timeout: self.request_timeout,
6517 source: self.source,
6518 }
6519 }
6520 #[doc = "Include the stack trace of returned errors."]
6521 pub fn error_trace(mut self, error_trace: bool) -> Self {
6522 self.error_trace = Some(error_trace);
6523 self
6524 }
6525 #[doc = "A comma-separated list of filters used to reduce the response."]
6526 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6527 self.filter_path = Some(filter_path);
6528 self
6529 }
6530 #[doc = "Adds a HTTP header"]
6531 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6532 self.headers.insert(key, value);
6533 self
6534 }
6535 #[doc = "Return human readable values for statistics."]
6536 pub fn human(mut self, human: bool) -> Self {
6537 self.human = Some(human);
6538 self
6539 }
6540 #[doc = "Pretty format the returned JSON response."]
6541 pub fn pretty(mut self, pretty: bool) -> Self {
6542 self.pretty = Some(pretty);
6543 self
6544 }
6545 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
6546 pub fn request_timeout(mut self, timeout: Duration) -> Self {
6547 self.request_timeout = Some(timeout);
6548 self
6549 }
6550 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6551 pub fn source(mut self, source: &'b str) -> Self {
6552 self.source = Some(source);
6553 self
6554 }
6555 #[doc = "Creates an asynchronous call to the Render Search Template API that can be awaited"]
6556 pub async fn send(self) -> Result<Response, Error> {
6557 let path = self.parts.url();
6558 let method = match self.body {
6559 Some(_) => http::Method::Post,
6560 None => http::Method::Get,
6561 };
6562 let headers = self.headers;
6563 let timeout = self.request_timeout;
6564 let query_string = {
6565 #[serde_with::skip_serializing_none]
6566 #[derive(Serialize)]
6567 struct QueryParams<'b> {
6568 error_trace: Option<bool>,
6569 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6570 filter_path: Option<&'b [&'b str]>,
6571 human: Option<bool>,
6572 pretty: Option<bool>,
6573 source: Option<&'b str>,
6574 }
6575 let query_params = QueryParams {
6576 error_trace: self.error_trace,
6577 filter_path: self.filter_path,
6578 human: self.human,
6579 pretty: self.pretty,
6580 source: self.source,
6581 };
6582 Some(query_params)
6583 };
6584 let body = self.body;
6585 let response = self
6586 .transport
6587 .send(method, &path, headers, query_string.as_ref(), body, timeout)
6588 .await?;
6589 Ok(response)
6590 }
6591}
6592#[cfg(feature = "experimental-apis")]
6593#[derive(Debug, Clone, PartialEq, Eq)]
6594#[doc = "API parts for the Scripts Painless Execute API"]
6595pub enum ScriptsPainlessExecuteParts {
6596 #[doc = "No parts"]
6597 None,
6598}
6599#[cfg(feature = "experimental-apis")]
6600impl ScriptsPainlessExecuteParts {
6601 #[doc = "Builds a relative URL path to the Scripts Painless Execute API"]
6602 pub fn url(self) -> Cow<'static, str> {
6603 match self {
6604 ScriptsPainlessExecuteParts::None => "/_scripts/painless/_execute".into(),
6605 }
6606 }
6607}
6608#[doc = "Builder for the [Scripts Painless Execute API](https://www.elastic.co/guide/en/elasticsearch/painless/9.0/painless-execute-api.html)\n\nAllows an arbitrary script to be executed and a result to be returned"]
6609#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "]
6610#[cfg(feature = "experimental-apis")]
6611#[derive(Clone, Debug)]
6612pub struct ScriptsPainlessExecute<'a, 'b, B> {
6613 transport: &'a Transport,
6614 parts: ScriptsPainlessExecuteParts,
6615 body: Option<B>,
6616 error_trace: Option<bool>,
6617 filter_path: Option<&'b [&'b str]>,
6618 headers: HeaderMap,
6619 human: Option<bool>,
6620 pretty: Option<bool>,
6621 request_timeout: Option<Duration>,
6622 source: Option<&'b str>,
6623}
6624#[cfg(feature = "experimental-apis")]
6625impl<'a, 'b, B> ScriptsPainlessExecute<'a, 'b, B>
6626where
6627 B: Body,
6628{
6629 #[doc = "Creates a new instance of [ScriptsPainlessExecute]"]
6630 pub fn new(transport: &'a Transport) -> Self {
6631 let headers = HeaderMap::new();
6632 ScriptsPainlessExecute {
6633 transport,
6634 parts: ScriptsPainlessExecuteParts::None,
6635 headers,
6636 body: None,
6637 error_trace: None,
6638 filter_path: None,
6639 human: None,
6640 pretty: None,
6641 request_timeout: None,
6642 source: None,
6643 }
6644 }
6645 #[doc = "The body for the API call"]
6646 pub fn body<T>(self, body: T) -> ScriptsPainlessExecute<'a, 'b, JsonBody<T>>
6647 where
6648 T: Serialize,
6649 {
6650 ScriptsPainlessExecute {
6651 transport: self.transport,
6652 parts: self.parts,
6653 body: Some(body.into()),
6654 error_trace: self.error_trace,
6655 filter_path: self.filter_path,
6656 headers: self.headers,
6657 human: self.human,
6658 pretty: self.pretty,
6659 request_timeout: self.request_timeout,
6660 source: self.source,
6661 }
6662 }
6663 #[doc = "Include the stack trace of returned errors."]
6664 pub fn error_trace(mut self, error_trace: bool) -> Self {
6665 self.error_trace = Some(error_trace);
6666 self
6667 }
6668 #[doc = "A comma-separated list of filters used to reduce the response."]
6669 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6670 self.filter_path = Some(filter_path);
6671 self
6672 }
6673 #[doc = "Adds a HTTP header"]
6674 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6675 self.headers.insert(key, value);
6676 self
6677 }
6678 #[doc = "Return human readable values for statistics."]
6679 pub fn human(mut self, human: bool) -> Self {
6680 self.human = Some(human);
6681 self
6682 }
6683 #[doc = "Pretty format the returned JSON response."]
6684 pub fn pretty(mut self, pretty: bool) -> Self {
6685 self.pretty = Some(pretty);
6686 self
6687 }
6688 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
6689 pub fn request_timeout(mut self, timeout: Duration) -> Self {
6690 self.request_timeout = Some(timeout);
6691 self
6692 }
6693 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6694 pub fn source(mut self, source: &'b str) -> Self {
6695 self.source = Some(source);
6696 self
6697 }
6698 #[doc = "Creates an asynchronous call to the Scripts Painless Execute API that can be awaited"]
6699 pub async fn send(self) -> Result<Response, Error> {
6700 let path = self.parts.url();
6701 let method = match self.body {
6702 Some(_) => http::Method::Post,
6703 None => http::Method::Get,
6704 };
6705 let headers = self.headers;
6706 let timeout = self.request_timeout;
6707 let query_string = {
6708 #[serde_with::skip_serializing_none]
6709 #[derive(Serialize)]
6710 struct QueryParams<'b> {
6711 error_trace: Option<bool>,
6712 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6713 filter_path: Option<&'b [&'b str]>,
6714 human: Option<bool>,
6715 pretty: Option<bool>,
6716 source: Option<&'b str>,
6717 }
6718 let query_params = QueryParams {
6719 error_trace: self.error_trace,
6720 filter_path: self.filter_path,
6721 human: self.human,
6722 pretty: self.pretty,
6723 source: self.source,
6724 };
6725 Some(query_params)
6726 };
6727 let body = self.body;
6728 let response = self
6729 .transport
6730 .send(method, &path, headers, query_string.as_ref(), body, timeout)
6731 .await?;
6732 Ok(response)
6733 }
6734}
6735#[derive(Debug, Clone, PartialEq, Eq)]
6736#[doc = "API parts for the Scroll API"]
6737pub enum ScrollParts<'b> {
6738 #[doc = "No parts"]
6739 None,
6740 #[doc = "ScrollId"]
6741 ScrollId(&'b str),
6742}
6743impl<'b> ScrollParts<'b> {
6744 #[doc = "Builds a relative URL path to the Scroll API"]
6745 pub fn url(self) -> Cow<'static, str> {
6746 match self {
6747 ScrollParts::None => "/_search/scroll".into(),
6748 ScrollParts::ScrollId(scroll_id) => {
6749 let encoded_scroll_id: Cow<str> =
6750 percent_encode(scroll_id.as_bytes(), PARTS_ENCODED).into();
6751 let mut p = String::with_capacity(16usize + encoded_scroll_id.len());
6752 p.push_str("/_search/scroll/");
6753 p.push_str(encoded_scroll_id.as_ref());
6754 p.into()
6755 }
6756 }
6757 }
6758}
6759#[doc = "Builder for the [Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-request-body.html#request-body-search-scroll)\n\nAllows to retrieve a large numbers of results from a single search request."]
6760#[derive(Clone, Debug)]
6761pub struct Scroll<'a, 'b, B> {
6762 transport: &'a Transport,
6763 parts: ScrollParts<'b>,
6764 body: Option<B>,
6765 error_trace: Option<bool>,
6766 filter_path: Option<&'b [&'b str]>,
6767 headers: HeaderMap,
6768 human: Option<bool>,
6769 pretty: Option<bool>,
6770 request_timeout: Option<Duration>,
6771 rest_total_hits_as_int: Option<bool>,
6772 scroll: Option<&'b str>,
6773 scroll_id: Option<&'b str>,
6774 source: Option<&'b str>,
6775}
6776impl<'a, 'b, B> Scroll<'a, 'b, B>
6777where
6778 B: Body,
6779{
6780 #[doc = "Creates a new instance of [Scroll] with the specified API parts"]
6781 pub fn new(transport: &'a Transport, parts: ScrollParts<'b>) -> Self {
6782 let headers = HeaderMap::new();
6783 Scroll {
6784 transport,
6785 parts,
6786 headers,
6787 body: None,
6788 error_trace: None,
6789 filter_path: None,
6790 human: None,
6791 pretty: None,
6792 request_timeout: None,
6793 rest_total_hits_as_int: None,
6794 scroll: None,
6795 scroll_id: None,
6796 source: None,
6797 }
6798 }
6799 #[doc = "The body for the API call"]
6800 pub fn body<T>(self, body: T) -> Scroll<'a, 'b, JsonBody<T>>
6801 where
6802 T: Serialize,
6803 {
6804 Scroll {
6805 transport: self.transport,
6806 parts: self.parts,
6807 body: Some(body.into()),
6808 error_trace: self.error_trace,
6809 filter_path: self.filter_path,
6810 headers: self.headers,
6811 human: self.human,
6812 pretty: self.pretty,
6813 request_timeout: self.request_timeout,
6814 rest_total_hits_as_int: self.rest_total_hits_as_int,
6815 scroll: self.scroll,
6816 scroll_id: self.scroll_id,
6817 source: self.source,
6818 }
6819 }
6820 #[doc = "Include the stack trace of returned errors."]
6821 pub fn error_trace(mut self, error_trace: bool) -> Self {
6822 self.error_trace = Some(error_trace);
6823 self
6824 }
6825 #[doc = "A comma-separated list of filters used to reduce the response."]
6826 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
6827 self.filter_path = Some(filter_path);
6828 self
6829 }
6830 #[doc = "Adds a HTTP header"]
6831 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
6832 self.headers.insert(key, value);
6833 self
6834 }
6835 #[doc = "Return human readable values for statistics."]
6836 pub fn human(mut self, human: bool) -> Self {
6837 self.human = Some(human);
6838 self
6839 }
6840 #[doc = "Pretty format the returned JSON response."]
6841 pub fn pretty(mut self, pretty: bool) -> Self {
6842 self.pretty = Some(pretty);
6843 self
6844 }
6845 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
6846 pub fn request_timeout(mut self, timeout: Duration) -> Self {
6847 self.request_timeout = Some(timeout);
6848 self
6849 }
6850 #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
6851 pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
6852 self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
6853 self
6854 }
6855 #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
6856 pub fn scroll(mut self, scroll: &'b str) -> Self {
6857 self.scroll = Some(scroll);
6858 self
6859 }
6860 #[doc = "The scroll ID for scrolled search"]
6861 pub fn scroll_id(mut self, scroll_id: &'b str) -> Self {
6862 self.scroll_id = Some(scroll_id);
6863 self
6864 }
6865 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
6866 pub fn source(mut self, source: &'b str) -> Self {
6867 self.source = Some(source);
6868 self
6869 }
6870 #[doc = "Creates an asynchronous call to the Scroll API that can be awaited"]
6871 pub async fn send(self) -> Result<Response, Error> {
6872 let path = self.parts.url();
6873 let method = match self.body {
6874 Some(_) => http::Method::Post,
6875 None => http::Method::Get,
6876 };
6877 let headers = self.headers;
6878 let timeout = self.request_timeout;
6879 let query_string = {
6880 #[serde_with::skip_serializing_none]
6881 #[derive(Serialize)]
6882 struct QueryParams<'b> {
6883 error_trace: Option<bool>,
6884 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
6885 filter_path: Option<&'b [&'b str]>,
6886 human: Option<bool>,
6887 pretty: Option<bool>,
6888 rest_total_hits_as_int: Option<bool>,
6889 scroll: Option<&'b str>,
6890 scroll_id: Option<&'b str>,
6891 source: Option<&'b str>,
6892 }
6893 let query_params = QueryParams {
6894 error_trace: self.error_trace,
6895 filter_path: self.filter_path,
6896 human: self.human,
6897 pretty: self.pretty,
6898 rest_total_hits_as_int: self.rest_total_hits_as_int,
6899 scroll: self.scroll,
6900 scroll_id: self.scroll_id,
6901 source: self.source,
6902 };
6903 Some(query_params)
6904 };
6905 let body = self.body;
6906 let response = self
6907 .transport
6908 .send(method, &path, headers, query_string.as_ref(), body, timeout)
6909 .await?;
6910 Ok(response)
6911 }
6912}
6913#[derive(Debug, Clone, PartialEq, Eq)]
6914#[doc = "API parts for the Search API"]
6915pub enum SearchParts<'b> {
6916 #[doc = "No parts"]
6917 None,
6918 #[doc = "Index"]
6919 Index(&'b [&'b str]),
6920}
6921impl<'b> SearchParts<'b> {
6922 #[doc = "Builds a relative URL path to the Search API"]
6923 pub fn url(self) -> Cow<'static, str> {
6924 match self {
6925 SearchParts::None => "/_search".into(),
6926 SearchParts::Index(index) => {
6927 let index_str = index.join(",");
6928 let encoded_index: Cow<str> =
6929 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
6930 let mut p = String::with_capacity(9usize + encoded_index.len());
6931 p.push('/');
6932 p.push_str(encoded_index.as_ref());
6933 p.push_str("/_search");
6934 p.into()
6935 }
6936 }
6937 }
6938}
6939#[doc = "Builder for the [Search API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-search.html)\n\nReturns results matching a query."]
6940#[derive(Clone, Debug)]
6941pub struct Search<'a, 'b, B> {
6942 transport: &'a Transport,
6943 parts: SearchParts<'b>,
6944 _source: Option<&'b [&'b str]>,
6945 _source_excludes: Option<&'b [&'b str]>,
6946 _source_includes: Option<&'b [&'b str]>,
6947 allow_no_indices: Option<bool>,
6948 allow_partial_search_results: Option<bool>,
6949 analyze_wildcard: Option<bool>,
6950 analyzer: Option<&'b str>,
6951 batched_reduce_size: Option<i64>,
6952 body: Option<B>,
6953 ccs_minimize_roundtrips: Option<bool>,
6954 default_operator: Option<DefaultOperator>,
6955 df: Option<&'b str>,
6956 docvalue_fields: Option<&'b [&'b str]>,
6957 error_trace: Option<bool>,
6958 expand_wildcards: Option<&'b [ExpandWildcards]>,
6959 explain: Option<bool>,
6960 filter_path: Option<&'b [&'b str]>,
6961 force_synthetic_source: Option<bool>,
6962 from: Option<i64>,
6963 headers: HeaderMap,
6964 human: Option<bool>,
6965 ignore_throttled: Option<bool>,
6966 ignore_unavailable: Option<bool>,
6967 include_named_queries_score: Option<bool>,
6968 lenient: Option<bool>,
6969 max_concurrent_shard_requests: Option<i64>,
6970 pre_filter_shard_size: Option<i64>,
6971 preference: Option<&'b str>,
6972 pretty: Option<bool>,
6973 q: Option<&'b str>,
6974 request_cache: Option<bool>,
6975 request_timeout: Option<Duration>,
6976 rest_total_hits_as_int: Option<bool>,
6977 routing: Option<&'b [&'b str]>,
6978 scroll: Option<&'b str>,
6979 search_type: Option<SearchType>,
6980 seq_no_primary_term: Option<bool>,
6981 size: Option<i64>,
6982 sort: Option<&'b [&'b str]>,
6983 source: Option<&'b str>,
6984 stats: Option<&'b [&'b str]>,
6985 stored_fields: Option<&'b [&'b str]>,
6986 suggest_field: Option<&'b str>,
6987 suggest_mode: Option<SuggestMode>,
6988 suggest_size: Option<i64>,
6989 suggest_text: Option<&'b str>,
6990 terminate_after: Option<i64>,
6991 timeout: Option<&'b str>,
6992 track_scores: Option<bool>,
6993 track_total_hits: Option<TrackTotalHits>,
6994 typed_keys: Option<bool>,
6995 version: Option<bool>,
6996}
6997impl<'a, 'b, B> Search<'a, 'b, B>
6998where
6999 B: Body,
7000{
7001 #[doc = "Creates a new instance of [Search] with the specified API parts"]
7002 pub fn new(transport: &'a Transport, parts: SearchParts<'b>) -> Self {
7003 let headers = HeaderMap::new();
7004 Search {
7005 transport,
7006 parts,
7007 headers,
7008 _source: None,
7009 _source_excludes: None,
7010 _source_includes: None,
7011 allow_no_indices: None,
7012 allow_partial_search_results: None,
7013 analyze_wildcard: None,
7014 analyzer: None,
7015 batched_reduce_size: None,
7016 body: None,
7017 ccs_minimize_roundtrips: None,
7018 default_operator: None,
7019 df: None,
7020 docvalue_fields: None,
7021 error_trace: None,
7022 expand_wildcards: None,
7023 explain: None,
7024 filter_path: None,
7025 force_synthetic_source: None,
7026 from: None,
7027 human: None,
7028 ignore_throttled: None,
7029 ignore_unavailable: None,
7030 include_named_queries_score: None,
7031 lenient: None,
7032 max_concurrent_shard_requests: None,
7033 pre_filter_shard_size: None,
7034 preference: None,
7035 pretty: None,
7036 q: None,
7037 request_cache: None,
7038 request_timeout: None,
7039 rest_total_hits_as_int: None,
7040 routing: None,
7041 scroll: None,
7042 search_type: None,
7043 seq_no_primary_term: None,
7044 size: None,
7045 sort: None,
7046 source: None,
7047 stats: None,
7048 stored_fields: None,
7049 suggest_field: None,
7050 suggest_mode: None,
7051 suggest_size: None,
7052 suggest_text: None,
7053 terminate_after: None,
7054 timeout: None,
7055 track_scores: None,
7056 track_total_hits: None,
7057 typed_keys: None,
7058 version: None,
7059 }
7060 }
7061 #[doc = "True or false to return the _source field or not, or a list of fields to return"]
7062 pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
7063 self._source = Some(_source);
7064 self
7065 }
7066 #[doc = "A list of fields to exclude from the returned _source field"]
7067 pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
7068 self._source_excludes = Some(_source_excludes);
7069 self
7070 }
7071 #[doc = "A list of fields to extract and return from the _source field"]
7072 pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
7073 self._source_includes = Some(_source_includes);
7074 self
7075 }
7076 #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
7077 pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
7078 self.allow_no_indices = Some(allow_no_indices);
7079 self
7080 }
7081 #[doc = "Indicate if an error should be returned if there is a partial search failure or timeout"]
7082 pub fn allow_partial_search_results(mut self, allow_partial_search_results: bool) -> Self {
7083 self.allow_partial_search_results = Some(allow_partial_search_results);
7084 self
7085 }
7086 #[doc = "Specify whether wildcard and prefix queries should be analyzed (default: false)"]
7087 pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
7088 self.analyze_wildcard = Some(analyze_wildcard);
7089 self
7090 }
7091 #[doc = "The analyzer to use for the query string"]
7092 pub fn analyzer(mut self, analyzer: &'b str) -> Self {
7093 self.analyzer = Some(analyzer);
7094 self
7095 }
7096 #[doc = "The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large."]
7097 pub fn batched_reduce_size(mut self, batched_reduce_size: i64) -> Self {
7098 self.batched_reduce_size = Some(batched_reduce_size);
7099 self
7100 }
7101 #[doc = "The body for the API call"]
7102 pub fn body<T>(self, body: T) -> Search<'a, 'b, JsonBody<T>>
7103 where
7104 T: Serialize,
7105 {
7106 Search {
7107 transport: self.transport,
7108 parts: self.parts,
7109 body: Some(body.into()),
7110 _source: self._source,
7111 _source_excludes: self._source_excludes,
7112 _source_includes: self._source_includes,
7113 allow_no_indices: self.allow_no_indices,
7114 allow_partial_search_results: self.allow_partial_search_results,
7115 analyze_wildcard: self.analyze_wildcard,
7116 analyzer: self.analyzer,
7117 batched_reduce_size: self.batched_reduce_size,
7118 ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
7119 default_operator: self.default_operator,
7120 df: self.df,
7121 docvalue_fields: self.docvalue_fields,
7122 error_trace: self.error_trace,
7123 expand_wildcards: self.expand_wildcards,
7124 explain: self.explain,
7125 filter_path: self.filter_path,
7126 force_synthetic_source: self.force_synthetic_source,
7127 from: self.from,
7128 headers: self.headers,
7129 human: self.human,
7130 ignore_throttled: self.ignore_throttled,
7131 ignore_unavailable: self.ignore_unavailable,
7132 include_named_queries_score: self.include_named_queries_score,
7133 lenient: self.lenient,
7134 max_concurrent_shard_requests: self.max_concurrent_shard_requests,
7135 pre_filter_shard_size: self.pre_filter_shard_size,
7136 preference: self.preference,
7137 pretty: self.pretty,
7138 q: self.q,
7139 request_cache: self.request_cache,
7140 request_timeout: self.request_timeout,
7141 rest_total_hits_as_int: self.rest_total_hits_as_int,
7142 routing: self.routing,
7143 scroll: self.scroll,
7144 search_type: self.search_type,
7145 seq_no_primary_term: self.seq_no_primary_term,
7146 size: self.size,
7147 sort: self.sort,
7148 source: self.source,
7149 stats: self.stats,
7150 stored_fields: self.stored_fields,
7151 suggest_field: self.suggest_field,
7152 suggest_mode: self.suggest_mode,
7153 suggest_size: self.suggest_size,
7154 suggest_text: self.suggest_text,
7155 terminate_after: self.terminate_after,
7156 timeout: self.timeout,
7157 track_scores: self.track_scores,
7158 track_total_hits: self.track_total_hits,
7159 typed_keys: self.typed_keys,
7160 version: self.version,
7161 }
7162 }
7163 #[doc = "Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution"]
7164 pub fn ccs_minimize_roundtrips(mut self, ccs_minimize_roundtrips: bool) -> Self {
7165 self.ccs_minimize_roundtrips = Some(ccs_minimize_roundtrips);
7166 self
7167 }
7168 #[doc = "The default operator for query string query (AND or OR)"]
7169 pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
7170 self.default_operator = Some(default_operator);
7171 self
7172 }
7173 #[doc = "The field to use as default where no field prefix is given in the query string"]
7174 pub fn df(mut self, df: &'b str) -> Self {
7175 self.df = Some(df);
7176 self
7177 }
7178 #[doc = "A comma-separated list of fields to return as the docvalue representation of a field for each hit"]
7179 pub fn docvalue_fields(mut self, docvalue_fields: &'b [&'b str]) -> Self {
7180 self.docvalue_fields = Some(docvalue_fields);
7181 self
7182 }
7183 #[doc = "Include the stack trace of returned errors."]
7184 pub fn error_trace(mut self, error_trace: bool) -> Self {
7185 self.error_trace = Some(error_trace);
7186 self
7187 }
7188 #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
7189 pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
7190 self.expand_wildcards = Some(expand_wildcards);
7191 self
7192 }
7193 #[doc = "Specify whether to return detailed information about score computation as part of a hit"]
7194 pub fn explain(mut self, explain: bool) -> Self {
7195 self.explain = Some(explain);
7196 self
7197 }
7198 #[doc = "A comma-separated list of filters used to reduce the response."]
7199 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
7200 self.filter_path = Some(filter_path);
7201 self
7202 }
7203 #[doc = "Should this request force synthetic _source? Use this to test if the mapping supports synthetic _source and to get a sense of the worst case performance. Fetches with this enabled will be slower the enabling synthetic source natively in the index."]
7204 pub fn force_synthetic_source(mut self, force_synthetic_source: bool) -> Self {
7205 self.force_synthetic_source = Some(force_synthetic_source);
7206 self
7207 }
7208 #[doc = "Starting offset (default: 0)"]
7209 pub fn from(mut self, from: i64) -> Self {
7210 self.from = Some(from);
7211 self
7212 }
7213 #[doc = "Adds a HTTP header"]
7214 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
7215 self.headers.insert(key, value);
7216 self
7217 }
7218 #[doc = "Return human readable values for statistics."]
7219 pub fn human(mut self, human: bool) -> Self {
7220 self.human = Some(human);
7221 self
7222 }
7223 #[doc = "Whether specified concrete, expanded or aliased indices should be ignored when throttled"]
7224 pub fn ignore_throttled(mut self, ignore_throttled: bool) -> Self {
7225 self.ignore_throttled = Some(ignore_throttled);
7226 self
7227 }
7228 #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
7229 pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
7230 self.ignore_unavailable = Some(ignore_unavailable);
7231 self
7232 }
7233 #[doc = "Indicates whether hit.matched_queries should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false)"]
7234 pub fn include_named_queries_score(mut self, include_named_queries_score: bool) -> Self {
7235 self.include_named_queries_score = Some(include_named_queries_score);
7236 self
7237 }
7238 #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
7239 pub fn lenient(mut self, lenient: bool) -> Self {
7240 self.lenient = Some(lenient);
7241 self
7242 }
7243 #[doc = "The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests"]
7244 pub fn max_concurrent_shard_requests(mut self, max_concurrent_shard_requests: i64) -> Self {
7245 self.max_concurrent_shard_requests = Some(max_concurrent_shard_requests);
7246 self
7247 }
7248 #[doc = "A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the\u{a0}number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint."]
7249 pub fn pre_filter_shard_size(mut self, pre_filter_shard_size: i64) -> Self {
7250 self.pre_filter_shard_size = Some(pre_filter_shard_size);
7251 self
7252 }
7253 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
7254 pub fn preference(mut self, preference: &'b str) -> Self {
7255 self.preference = Some(preference);
7256 self
7257 }
7258 #[doc = "Pretty format the returned JSON response."]
7259 pub fn pretty(mut self, pretty: bool) -> Self {
7260 self.pretty = Some(pretty);
7261 self
7262 }
7263 #[doc = "Query in the Lucene query string syntax"]
7264 pub fn q(mut self, q: &'b str) -> Self {
7265 self.q = Some(q);
7266 self
7267 }
7268 #[doc = "Specify if request cache should be used for this request or not, defaults to index level setting"]
7269 pub fn request_cache(mut self, request_cache: bool) -> Self {
7270 self.request_cache = Some(request_cache);
7271 self
7272 }
7273 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
7274 pub fn request_timeout(mut self, timeout: Duration) -> Self {
7275 self.request_timeout = Some(timeout);
7276 self
7277 }
7278 #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
7279 pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
7280 self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
7281 self
7282 }
7283 #[doc = "A comma-separated list of specific routing values"]
7284 pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
7285 self.routing = Some(routing);
7286 self
7287 }
7288 #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
7289 pub fn scroll(mut self, scroll: &'b str) -> Self {
7290 self.scroll = Some(scroll);
7291 self
7292 }
7293 #[doc = "Search operation type"]
7294 pub fn search_type(mut self, search_type: SearchType) -> Self {
7295 self.search_type = Some(search_type);
7296 self
7297 }
7298 #[doc = "Specify whether to return sequence number and primary term of the last modification of each hit"]
7299 pub fn seq_no_primary_term(mut self, seq_no_primary_term: bool) -> Self {
7300 self.seq_no_primary_term = Some(seq_no_primary_term);
7301 self
7302 }
7303 #[doc = "Number of hits to return (default: 10)"]
7304 pub fn size(mut self, size: i64) -> Self {
7305 self.size = Some(size);
7306 self
7307 }
7308 #[doc = "A comma-separated list of <field>:<direction> pairs"]
7309 pub fn sort(mut self, sort: &'b [&'b str]) -> Self {
7310 self.sort = Some(sort);
7311 self
7312 }
7313 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
7314 pub fn source(mut self, source: &'b str) -> Self {
7315 self.source = Some(source);
7316 self
7317 }
7318 #[doc = "Specific 'tag' of the request for logging and statistical purposes"]
7319 pub fn stats(mut self, stats: &'b [&'b str]) -> Self {
7320 self.stats = Some(stats);
7321 self
7322 }
7323 #[doc = "A comma-separated list of stored fields to return as part of a hit"]
7324 pub fn stored_fields(mut self, stored_fields: &'b [&'b str]) -> Self {
7325 self.stored_fields = Some(stored_fields);
7326 self
7327 }
7328 #[doc = "Specify which field to use for suggestions"]
7329 pub fn suggest_field(mut self, suggest_field: &'b str) -> Self {
7330 self.suggest_field = Some(suggest_field);
7331 self
7332 }
7333 #[doc = "Specify suggest mode"]
7334 pub fn suggest_mode(mut self, suggest_mode: SuggestMode) -> Self {
7335 self.suggest_mode = Some(suggest_mode);
7336 self
7337 }
7338 #[doc = "How many suggestions to return in response"]
7339 pub fn suggest_size(mut self, suggest_size: i64) -> Self {
7340 self.suggest_size = Some(suggest_size);
7341 self
7342 }
7343 #[doc = "The source text for which the suggestions should be returned"]
7344 pub fn suggest_text(mut self, suggest_text: &'b str) -> Self {
7345 self.suggest_text = Some(suggest_text);
7346 self
7347 }
7348 #[doc = "The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early."]
7349 pub fn terminate_after(mut self, terminate_after: i64) -> Self {
7350 self.terminate_after = Some(terminate_after);
7351 self
7352 }
7353 #[doc = "Explicit operation timeout"]
7354 pub fn timeout(mut self, timeout: &'b str) -> Self {
7355 self.timeout = Some(timeout);
7356 self
7357 }
7358 #[doc = "Whether to calculate and return scores even if they are not used for sorting"]
7359 pub fn track_scores(mut self, track_scores: bool) -> Self {
7360 self.track_scores = Some(track_scores);
7361 self
7362 }
7363 #[doc = "Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number."]
7364 pub fn track_total_hits<T: Into<TrackTotalHits>>(mut self, track_total_hits: T) -> Self {
7365 self.track_total_hits = Some(track_total_hits.into());
7366 self
7367 }
7368 #[doc = "Specify whether aggregation and suggester names should be prefixed by their respective types in the response"]
7369 pub fn typed_keys(mut self, typed_keys: bool) -> Self {
7370 self.typed_keys = Some(typed_keys);
7371 self
7372 }
7373 #[doc = "Specify whether to return document version as part of a hit"]
7374 pub fn version(mut self, version: bool) -> Self {
7375 self.version = Some(version);
7376 self
7377 }
7378 #[doc = "Creates an asynchronous call to the Search API that can be awaited"]
7379 pub async fn send(self) -> Result<Response, Error> {
7380 let path = self.parts.url();
7381 let method = match self.body {
7382 Some(_) => http::Method::Post,
7383 None => http::Method::Get,
7384 };
7385 let headers = self.headers;
7386 let timeout = self.request_timeout;
7387 let query_string = {
7388 #[serde_with::skip_serializing_none]
7389 #[derive(Serialize)]
7390 struct QueryParams<'b> {
7391 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7392 _source: Option<&'b [&'b str]>,
7393 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7394 _source_excludes: Option<&'b [&'b str]>,
7395 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7396 _source_includes: Option<&'b [&'b str]>,
7397 allow_no_indices: Option<bool>,
7398 allow_partial_search_results: Option<bool>,
7399 analyze_wildcard: Option<bool>,
7400 analyzer: Option<&'b str>,
7401 batched_reduce_size: Option<i64>,
7402 ccs_minimize_roundtrips: Option<bool>,
7403 default_operator: Option<DefaultOperator>,
7404 df: Option<&'b str>,
7405 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7406 docvalue_fields: Option<&'b [&'b str]>,
7407 error_trace: Option<bool>,
7408 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7409 expand_wildcards: Option<&'b [ExpandWildcards]>,
7410 explain: Option<bool>,
7411 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7412 filter_path: Option<&'b [&'b str]>,
7413 force_synthetic_source: Option<bool>,
7414 from: Option<i64>,
7415 human: Option<bool>,
7416 ignore_throttled: Option<bool>,
7417 ignore_unavailable: Option<bool>,
7418 include_named_queries_score: Option<bool>,
7419 lenient: Option<bool>,
7420 max_concurrent_shard_requests: Option<i64>,
7421 pre_filter_shard_size: Option<i64>,
7422 preference: Option<&'b str>,
7423 pretty: Option<bool>,
7424 q: Option<&'b str>,
7425 request_cache: Option<bool>,
7426 rest_total_hits_as_int: Option<bool>,
7427 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7428 routing: Option<&'b [&'b str]>,
7429 scroll: Option<&'b str>,
7430 search_type: Option<SearchType>,
7431 seq_no_primary_term: Option<bool>,
7432 size: Option<i64>,
7433 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7434 sort: Option<&'b [&'b str]>,
7435 source: Option<&'b str>,
7436 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7437 stats: Option<&'b [&'b str]>,
7438 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7439 stored_fields: Option<&'b [&'b str]>,
7440 suggest_field: Option<&'b str>,
7441 suggest_mode: Option<SuggestMode>,
7442 suggest_size: Option<i64>,
7443 suggest_text: Option<&'b str>,
7444 terminate_after: Option<i64>,
7445 timeout: Option<&'b str>,
7446 track_scores: Option<bool>,
7447 track_total_hits: Option<TrackTotalHits>,
7448 typed_keys: Option<bool>,
7449 version: Option<bool>,
7450 }
7451 let query_params = QueryParams {
7452 _source: self._source,
7453 _source_excludes: self._source_excludes,
7454 _source_includes: self._source_includes,
7455 allow_no_indices: self.allow_no_indices,
7456 allow_partial_search_results: self.allow_partial_search_results,
7457 analyze_wildcard: self.analyze_wildcard,
7458 analyzer: self.analyzer,
7459 batched_reduce_size: self.batched_reduce_size,
7460 ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
7461 default_operator: self.default_operator,
7462 df: self.df,
7463 docvalue_fields: self.docvalue_fields,
7464 error_trace: self.error_trace,
7465 expand_wildcards: self.expand_wildcards,
7466 explain: self.explain,
7467 filter_path: self.filter_path,
7468 force_synthetic_source: self.force_synthetic_source,
7469 from: self.from,
7470 human: self.human,
7471 ignore_throttled: self.ignore_throttled,
7472 ignore_unavailable: self.ignore_unavailable,
7473 include_named_queries_score: self.include_named_queries_score,
7474 lenient: self.lenient,
7475 max_concurrent_shard_requests: self.max_concurrent_shard_requests,
7476 pre_filter_shard_size: self.pre_filter_shard_size,
7477 preference: self.preference,
7478 pretty: self.pretty,
7479 q: self.q,
7480 request_cache: self.request_cache,
7481 rest_total_hits_as_int: self.rest_total_hits_as_int,
7482 routing: self.routing,
7483 scroll: self.scroll,
7484 search_type: self.search_type,
7485 seq_no_primary_term: self.seq_no_primary_term,
7486 size: self.size,
7487 sort: self.sort,
7488 source: self.source,
7489 stats: self.stats,
7490 stored_fields: self.stored_fields,
7491 suggest_field: self.suggest_field,
7492 suggest_mode: self.suggest_mode,
7493 suggest_size: self.suggest_size,
7494 suggest_text: self.suggest_text,
7495 terminate_after: self.terminate_after,
7496 timeout: self.timeout,
7497 track_scores: self.track_scores,
7498 track_total_hits: self.track_total_hits,
7499 typed_keys: self.typed_keys,
7500 version: self.version,
7501 };
7502 Some(query_params)
7503 };
7504 let body = self.body;
7505 let response = self
7506 .transport
7507 .send(method, &path, headers, query_string.as_ref(), body, timeout)
7508 .await?;
7509 Ok(response)
7510 }
7511}
7512#[cfg(feature = "experimental-apis")]
7513#[derive(Debug, Clone, PartialEq, Eq)]
7514#[doc = "API parts for the Search Mvt API"]
7515pub enum SearchMvtParts<'b> {
7516 #[doc = "Index, Field, Zoom, X and Y"]
7517 IndexFieldZoomXY(&'b [&'b str], &'b str, i32, i32, i32),
7518}
7519#[cfg(feature = "experimental-apis")]
7520impl<'b> SearchMvtParts<'b> {
7521 #[doc = "Builds a relative URL path to the Search Mvt API"]
7522 pub fn url(self) -> Cow<'static, str> {
7523 match self {
7524 SearchMvtParts::IndexFieldZoomXY(index, field, zoom, x, y) => {
7525 let index_str = index.join(",");
7526 let zoom_str = zoom.to_string();
7527 let x_str = x.to_string();
7528 let y_str = y.to_string();
7529 let encoded_index: Cow<str> =
7530 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
7531 let encoded_field: Cow<str> =
7532 percent_encode(field.as_bytes(), PARTS_ENCODED).into();
7533 let encoded_zoom: Cow<str> =
7534 percent_encode(zoom_str.as_bytes(), PARTS_ENCODED).into();
7535 let encoded_x: Cow<str> = percent_encode(x_str.as_bytes(), PARTS_ENCODED).into();
7536 let encoded_y: Cow<str> = percent_encode(y_str.as_bytes(), PARTS_ENCODED).into();
7537 let mut p = String::with_capacity(
7538 10usize
7539 + encoded_index.len()
7540 + encoded_field.len()
7541 + encoded_zoom.len()
7542 + encoded_x.len()
7543 + encoded_y.len(),
7544 );
7545 p.push('/');
7546 p.push_str(encoded_index.as_ref());
7547 p.push_str("/_mvt/");
7548 p.push_str(encoded_field.as_ref());
7549 p.push('/');
7550 p.push_str(encoded_zoom.as_ref());
7551 p.push('/');
7552 p.push_str(encoded_x.as_ref());
7553 p.push('/');
7554 p.push_str(encoded_y.as_ref());
7555 p.into()
7556 }
7557 }
7558 }
7559}
7560#[doc = "Builder for the [Search Mvt API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-vector-tile-api.html)\n\nSearches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile."]
7561#[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "]
7562#[cfg(feature = "experimental-apis")]
7563#[derive(Clone, Debug)]
7564pub struct SearchMvt<'a, 'b, B> {
7565 transport: &'a Transport,
7566 parts: SearchMvtParts<'b>,
7567 body: Option<B>,
7568 error_trace: Option<bool>,
7569 exact_bounds: Option<bool>,
7570 extent: Option<i32>,
7571 filter_path: Option<&'b [&'b str]>,
7572 grid_precision: Option<i32>,
7573 grid_type: Option<GridType>,
7574 headers: HeaderMap,
7575 human: Option<bool>,
7576 pretty: Option<bool>,
7577 request_timeout: Option<Duration>,
7578 size: Option<i32>,
7579 source: Option<&'b str>,
7580 track_total_hits: Option<TrackTotalHits>,
7581 with_labels: Option<bool>,
7582}
7583#[cfg(feature = "experimental-apis")]
7584impl<'a, 'b, B> SearchMvt<'a, 'b, B>
7585where
7586 B: Body,
7587{
7588 #[doc = "Creates a new instance of [SearchMvt] with the specified API parts"]
7589 pub fn new(transport: &'a Transport, parts: SearchMvtParts<'b>) -> Self {
7590 let headers = HeaderMap::new();
7591 SearchMvt {
7592 transport,
7593 parts,
7594 headers,
7595 body: None,
7596 error_trace: None,
7597 exact_bounds: None,
7598 extent: None,
7599 filter_path: None,
7600 grid_precision: None,
7601 grid_type: None,
7602 human: None,
7603 pretty: None,
7604 request_timeout: None,
7605 size: None,
7606 source: None,
7607 track_total_hits: None,
7608 with_labels: None,
7609 }
7610 }
7611 #[doc = "The body for the API call"]
7612 pub fn body<T>(self, body: T) -> SearchMvt<'a, 'b, JsonBody<T>>
7613 where
7614 T: Serialize,
7615 {
7616 SearchMvt {
7617 transport: self.transport,
7618 parts: self.parts,
7619 body: Some(body.into()),
7620 error_trace: self.error_trace,
7621 exact_bounds: self.exact_bounds,
7622 extent: self.extent,
7623 filter_path: self.filter_path,
7624 grid_precision: self.grid_precision,
7625 grid_type: self.grid_type,
7626 headers: self.headers,
7627 human: self.human,
7628 pretty: self.pretty,
7629 request_timeout: self.request_timeout,
7630 size: self.size,
7631 source: self.source,
7632 track_total_hits: self.track_total_hits,
7633 with_labels: self.with_labels,
7634 }
7635 }
7636 #[doc = "Include the stack trace of returned errors."]
7637 pub fn error_trace(mut self, error_trace: bool) -> Self {
7638 self.error_trace = Some(error_trace);
7639 self
7640 }
7641 #[doc = "If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation."]
7642 pub fn exact_bounds(mut self, exact_bounds: bool) -> Self {
7643 self.exact_bounds = Some(exact_bounds);
7644 self
7645 }
7646 #[doc = "Size, in pixels, of a side of the vector tile."]
7647 pub fn extent(mut self, extent: i32) -> Self {
7648 self.extent = Some(extent);
7649 self
7650 }
7651 #[doc = "A comma-separated list of filters used to reduce the response."]
7652 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
7653 self.filter_path = Some(filter_path);
7654 self
7655 }
7656 #[doc = "Additional zoom levels available through the aggs layer. Accepts 0-8."]
7657 pub fn grid_precision(mut self, grid_precision: i32) -> Self {
7658 self.grid_precision = Some(grid_precision);
7659 self
7660 }
7661 #[doc = "Determines the geometry type for features in the aggs layer."]
7662 pub fn grid_type(mut self, grid_type: GridType) -> Self {
7663 self.grid_type = Some(grid_type);
7664 self
7665 }
7666 #[doc = "Adds a HTTP header"]
7667 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
7668 self.headers.insert(key, value);
7669 self
7670 }
7671 #[doc = "Return human readable values for statistics."]
7672 pub fn human(mut self, human: bool) -> Self {
7673 self.human = Some(human);
7674 self
7675 }
7676 #[doc = "Pretty format the returned JSON response."]
7677 pub fn pretty(mut self, pretty: bool) -> Self {
7678 self.pretty = Some(pretty);
7679 self
7680 }
7681 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
7682 pub fn request_timeout(mut self, timeout: Duration) -> Self {
7683 self.request_timeout = Some(timeout);
7684 self
7685 }
7686 #[doc = "Maximum number of features to return in the hits layer. Accepts 0-10000."]
7687 pub fn size(mut self, size: i32) -> Self {
7688 self.size = Some(size);
7689 self
7690 }
7691 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
7692 pub fn source(mut self, source: &'b str) -> Self {
7693 self.source = Some(source);
7694 self
7695 }
7696 #[doc = "Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number."]
7697 pub fn track_total_hits<T: Into<TrackTotalHits>>(mut self, track_total_hits: T) -> Self {
7698 self.track_total_hits = Some(track_total_hits.into());
7699 self
7700 }
7701 #[doc = "If true, the hits and aggs layers will contain additional point features with suggested label positions for the original features."]
7702 pub fn with_labels(mut self, with_labels: bool) -> Self {
7703 self.with_labels = Some(with_labels);
7704 self
7705 }
7706 #[doc = "Creates an asynchronous call to the Search Mvt API that can be awaited"]
7707 pub async fn send(self) -> Result<Response, Error> {
7708 let path = self.parts.url();
7709 let method = match self.body {
7710 Some(_) => http::Method::Post,
7711 None => http::Method::Get,
7712 };
7713 let headers = self.headers;
7714 let timeout = self.request_timeout;
7715 let query_string = {
7716 #[serde_with::skip_serializing_none]
7717 #[derive(Serialize)]
7718 struct QueryParams<'b> {
7719 error_trace: Option<bool>,
7720 exact_bounds: Option<bool>,
7721 extent: Option<i32>,
7722 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7723 filter_path: Option<&'b [&'b str]>,
7724 grid_precision: Option<i32>,
7725 grid_type: Option<GridType>,
7726 human: Option<bool>,
7727 pretty: Option<bool>,
7728 size: Option<i32>,
7729 source: Option<&'b str>,
7730 track_total_hits: Option<TrackTotalHits>,
7731 with_labels: Option<bool>,
7732 }
7733 let query_params = QueryParams {
7734 error_trace: self.error_trace,
7735 exact_bounds: self.exact_bounds,
7736 extent: self.extent,
7737 filter_path: self.filter_path,
7738 grid_precision: self.grid_precision,
7739 grid_type: self.grid_type,
7740 human: self.human,
7741 pretty: self.pretty,
7742 size: self.size,
7743 source: self.source,
7744 track_total_hits: self.track_total_hits,
7745 with_labels: self.with_labels,
7746 };
7747 Some(query_params)
7748 };
7749 let body = self.body;
7750 let response = self
7751 .transport
7752 .send(method, &path, headers, query_string.as_ref(), body, timeout)
7753 .await?;
7754 Ok(response)
7755 }
7756}
7757#[derive(Debug, Clone, PartialEq, Eq)]
7758#[doc = "API parts for the Search Shards API"]
7759pub enum SearchShardsParts<'b> {
7760 #[doc = "No parts"]
7761 None,
7762 #[doc = "Index"]
7763 Index(&'b [&'b str]),
7764}
7765impl<'b> SearchShardsParts<'b> {
7766 #[doc = "Builds a relative URL path to the Search Shards API"]
7767 pub fn url(self) -> Cow<'static, str> {
7768 match self {
7769 SearchShardsParts::None => "/_search_shards".into(),
7770 SearchShardsParts::Index(index) => {
7771 let index_str = index.join(",");
7772 let encoded_index: Cow<str> =
7773 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
7774 let mut p = String::with_capacity(16usize + encoded_index.len());
7775 p.push('/');
7776 p.push_str(encoded_index.as_ref());
7777 p.push_str("/_search_shards");
7778 p.into()
7779 }
7780 }
7781 }
7782}
7783#[doc = "Builder for the [Search Shards API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-shards.html)\n\nReturns information about the indices and shards that a search request would be executed against."]
7784#[derive(Clone, Debug)]
7785pub struct SearchShards<'a, 'b, B> {
7786 transport: &'a Transport,
7787 parts: SearchShardsParts<'b>,
7788 allow_no_indices: Option<bool>,
7789 body: Option<B>,
7790 error_trace: Option<bool>,
7791 expand_wildcards: Option<&'b [ExpandWildcards]>,
7792 filter_path: Option<&'b [&'b str]>,
7793 headers: HeaderMap,
7794 human: Option<bool>,
7795 ignore_unavailable: Option<bool>,
7796 local: Option<bool>,
7797 master_timeout: Option<&'b str>,
7798 preference: Option<&'b str>,
7799 pretty: Option<bool>,
7800 request_timeout: Option<Duration>,
7801 routing: Option<&'b str>,
7802 source: Option<&'b str>,
7803}
7804impl<'a, 'b, B> SearchShards<'a, 'b, B>
7805where
7806 B: Body,
7807{
7808 #[doc = "Creates a new instance of [SearchShards] with the specified API parts"]
7809 pub fn new(transport: &'a Transport, parts: SearchShardsParts<'b>) -> Self {
7810 let headers = HeaderMap::new();
7811 SearchShards {
7812 transport,
7813 parts,
7814 headers,
7815 allow_no_indices: None,
7816 body: None,
7817 error_trace: None,
7818 expand_wildcards: None,
7819 filter_path: None,
7820 human: None,
7821 ignore_unavailable: None,
7822 local: None,
7823 master_timeout: None,
7824 preference: None,
7825 pretty: None,
7826 request_timeout: None,
7827 routing: None,
7828 source: None,
7829 }
7830 }
7831 #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
7832 pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
7833 self.allow_no_indices = Some(allow_no_indices);
7834 self
7835 }
7836 #[doc = "The body for the API call"]
7837 pub fn body<T>(self, body: T) -> SearchShards<'a, 'b, JsonBody<T>>
7838 where
7839 T: Serialize,
7840 {
7841 SearchShards {
7842 transport: self.transport,
7843 parts: self.parts,
7844 body: Some(body.into()),
7845 allow_no_indices: self.allow_no_indices,
7846 error_trace: self.error_trace,
7847 expand_wildcards: self.expand_wildcards,
7848 filter_path: self.filter_path,
7849 headers: self.headers,
7850 human: self.human,
7851 ignore_unavailable: self.ignore_unavailable,
7852 local: self.local,
7853 master_timeout: self.master_timeout,
7854 preference: self.preference,
7855 pretty: self.pretty,
7856 request_timeout: self.request_timeout,
7857 routing: self.routing,
7858 source: self.source,
7859 }
7860 }
7861 #[doc = "Include the stack trace of returned errors."]
7862 pub fn error_trace(mut self, error_trace: bool) -> Self {
7863 self.error_trace = Some(error_trace);
7864 self
7865 }
7866 #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
7867 pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
7868 self.expand_wildcards = Some(expand_wildcards);
7869 self
7870 }
7871 #[doc = "A comma-separated list of filters used to reduce the response."]
7872 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
7873 self.filter_path = Some(filter_path);
7874 self
7875 }
7876 #[doc = "Adds a HTTP header"]
7877 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
7878 self.headers.insert(key, value);
7879 self
7880 }
7881 #[doc = "Return human readable values for statistics."]
7882 pub fn human(mut self, human: bool) -> Self {
7883 self.human = Some(human);
7884 self
7885 }
7886 #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
7887 pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
7888 self.ignore_unavailable = Some(ignore_unavailable);
7889 self
7890 }
7891 #[doc = "Return local information, do not retrieve the state from master node (default: false)"]
7892 pub fn local(mut self, local: bool) -> Self {
7893 self.local = Some(local);
7894 self
7895 }
7896 #[doc = "Explicit operation timeout for connection to master node"]
7897 pub fn master_timeout(mut self, master_timeout: &'b str) -> Self {
7898 self.master_timeout = Some(master_timeout);
7899 self
7900 }
7901 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
7902 pub fn preference(mut self, preference: &'b str) -> Self {
7903 self.preference = Some(preference);
7904 self
7905 }
7906 #[doc = "Pretty format the returned JSON response."]
7907 pub fn pretty(mut self, pretty: bool) -> Self {
7908 self.pretty = Some(pretty);
7909 self
7910 }
7911 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
7912 pub fn request_timeout(mut self, timeout: Duration) -> Self {
7913 self.request_timeout = Some(timeout);
7914 self
7915 }
7916 #[doc = "Specific routing value"]
7917 pub fn routing(mut self, routing: &'b str) -> Self {
7918 self.routing = Some(routing);
7919 self
7920 }
7921 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
7922 pub fn source(mut self, source: &'b str) -> Self {
7923 self.source = Some(source);
7924 self
7925 }
7926 #[doc = "Creates an asynchronous call to the Search Shards API that can be awaited"]
7927 pub async fn send(self) -> Result<Response, Error> {
7928 let path = self.parts.url();
7929 let method = match self.body {
7930 Some(_) => http::Method::Post,
7931 None => http::Method::Get,
7932 };
7933 let headers = self.headers;
7934 let timeout = self.request_timeout;
7935 let query_string = {
7936 #[serde_with::skip_serializing_none]
7937 #[derive(Serialize)]
7938 struct QueryParams<'b> {
7939 allow_no_indices: Option<bool>,
7940 error_trace: Option<bool>,
7941 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7942 expand_wildcards: Option<&'b [ExpandWildcards]>,
7943 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
7944 filter_path: Option<&'b [&'b str]>,
7945 human: Option<bool>,
7946 ignore_unavailable: Option<bool>,
7947 local: Option<bool>,
7948 master_timeout: Option<&'b str>,
7949 preference: Option<&'b str>,
7950 pretty: Option<bool>,
7951 routing: Option<&'b str>,
7952 source: Option<&'b str>,
7953 }
7954 let query_params = QueryParams {
7955 allow_no_indices: self.allow_no_indices,
7956 error_trace: self.error_trace,
7957 expand_wildcards: self.expand_wildcards,
7958 filter_path: self.filter_path,
7959 human: self.human,
7960 ignore_unavailable: self.ignore_unavailable,
7961 local: self.local,
7962 master_timeout: self.master_timeout,
7963 preference: self.preference,
7964 pretty: self.pretty,
7965 routing: self.routing,
7966 source: self.source,
7967 };
7968 Some(query_params)
7969 };
7970 let body = self.body;
7971 let response = self
7972 .transport
7973 .send(method, &path, headers, query_string.as_ref(), body, timeout)
7974 .await?;
7975 Ok(response)
7976 }
7977}
7978#[derive(Debug, Clone, PartialEq, Eq)]
7979#[doc = "API parts for the Search Template API"]
7980pub enum SearchTemplateParts<'b> {
7981 #[doc = "No parts"]
7982 None,
7983 #[doc = "Index"]
7984 Index(&'b [&'b str]),
7985}
7986impl<'b> SearchTemplateParts<'b> {
7987 #[doc = "Builds a relative URL path to the Search Template API"]
7988 pub fn url(self) -> Cow<'static, str> {
7989 match self {
7990 SearchTemplateParts::None => "/_search/template".into(),
7991 SearchTemplateParts::Index(index) => {
7992 let index_str = index.join(",");
7993 let encoded_index: Cow<str> =
7994 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
7995 let mut p = String::with_capacity(18usize + encoded_index.len());
7996 p.push('/');
7997 p.push_str(encoded_index.as_ref());
7998 p.push_str("/_search/template");
7999 p.into()
8000 }
8001 }
8002 }
8003}
8004#[doc = "Builder for the [Search Template API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-template.html)\n\nAllows to use the Mustache language to pre-render a search definition."]
8005#[derive(Clone, Debug)]
8006pub struct SearchTemplate<'a, 'b, B> {
8007 transport: &'a Transport,
8008 parts: SearchTemplateParts<'b>,
8009 allow_no_indices: Option<bool>,
8010 body: Option<B>,
8011 ccs_minimize_roundtrips: Option<bool>,
8012 error_trace: Option<bool>,
8013 expand_wildcards: Option<&'b [ExpandWildcards]>,
8014 explain: Option<bool>,
8015 filter_path: Option<&'b [&'b str]>,
8016 headers: HeaderMap,
8017 human: Option<bool>,
8018 ignore_throttled: Option<bool>,
8019 ignore_unavailable: Option<bool>,
8020 preference: Option<&'b str>,
8021 pretty: Option<bool>,
8022 profile: Option<bool>,
8023 request_timeout: Option<Duration>,
8024 rest_total_hits_as_int: Option<bool>,
8025 routing: Option<&'b [&'b str]>,
8026 scroll: Option<&'b str>,
8027 search_type: Option<SearchType>,
8028 source: Option<&'b str>,
8029 typed_keys: Option<bool>,
8030}
8031impl<'a, 'b, B> SearchTemplate<'a, 'b, B>
8032where
8033 B: Body,
8034{
8035 #[doc = "Creates a new instance of [SearchTemplate] with the specified API parts"]
8036 pub fn new(transport: &'a Transport, parts: SearchTemplateParts<'b>) -> Self {
8037 let headers = HeaderMap::new();
8038 SearchTemplate {
8039 transport,
8040 parts,
8041 headers,
8042 allow_no_indices: None,
8043 body: None,
8044 ccs_minimize_roundtrips: None,
8045 error_trace: None,
8046 expand_wildcards: None,
8047 explain: None,
8048 filter_path: None,
8049 human: None,
8050 ignore_throttled: None,
8051 ignore_unavailable: None,
8052 preference: None,
8053 pretty: None,
8054 profile: None,
8055 request_timeout: None,
8056 rest_total_hits_as_int: None,
8057 routing: None,
8058 scroll: None,
8059 search_type: None,
8060 source: None,
8061 typed_keys: None,
8062 }
8063 }
8064 #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
8065 pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
8066 self.allow_no_indices = Some(allow_no_indices);
8067 self
8068 }
8069 #[doc = "The body for the API call"]
8070 pub fn body<T>(self, body: T) -> SearchTemplate<'a, 'b, JsonBody<T>>
8071 where
8072 T: Serialize,
8073 {
8074 SearchTemplate {
8075 transport: self.transport,
8076 parts: self.parts,
8077 body: Some(body.into()),
8078 allow_no_indices: self.allow_no_indices,
8079 ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
8080 error_trace: self.error_trace,
8081 expand_wildcards: self.expand_wildcards,
8082 explain: self.explain,
8083 filter_path: self.filter_path,
8084 headers: self.headers,
8085 human: self.human,
8086 ignore_throttled: self.ignore_throttled,
8087 ignore_unavailable: self.ignore_unavailable,
8088 preference: self.preference,
8089 pretty: self.pretty,
8090 profile: self.profile,
8091 request_timeout: self.request_timeout,
8092 rest_total_hits_as_int: self.rest_total_hits_as_int,
8093 routing: self.routing,
8094 scroll: self.scroll,
8095 search_type: self.search_type,
8096 source: self.source,
8097 typed_keys: self.typed_keys,
8098 }
8099 }
8100 #[doc = "Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution"]
8101 pub fn ccs_minimize_roundtrips(mut self, ccs_minimize_roundtrips: bool) -> Self {
8102 self.ccs_minimize_roundtrips = Some(ccs_minimize_roundtrips);
8103 self
8104 }
8105 #[doc = "Include the stack trace of returned errors."]
8106 pub fn error_trace(mut self, error_trace: bool) -> Self {
8107 self.error_trace = Some(error_trace);
8108 self
8109 }
8110 #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
8111 pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
8112 self.expand_wildcards = Some(expand_wildcards);
8113 self
8114 }
8115 #[doc = "Specify whether to return detailed information about score computation as part of a hit"]
8116 pub fn explain(mut self, explain: bool) -> Self {
8117 self.explain = Some(explain);
8118 self
8119 }
8120 #[doc = "A comma-separated list of filters used to reduce the response."]
8121 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
8122 self.filter_path = Some(filter_path);
8123 self
8124 }
8125 #[doc = "Adds a HTTP header"]
8126 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
8127 self.headers.insert(key, value);
8128 self
8129 }
8130 #[doc = "Return human readable values for statistics."]
8131 pub fn human(mut self, human: bool) -> Self {
8132 self.human = Some(human);
8133 self
8134 }
8135 #[doc = "Whether specified concrete, expanded or aliased indices should be ignored when throttled"]
8136 pub fn ignore_throttled(mut self, ignore_throttled: bool) -> Self {
8137 self.ignore_throttled = Some(ignore_throttled);
8138 self
8139 }
8140 #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
8141 pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
8142 self.ignore_unavailable = Some(ignore_unavailable);
8143 self
8144 }
8145 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
8146 pub fn preference(mut self, preference: &'b str) -> Self {
8147 self.preference = Some(preference);
8148 self
8149 }
8150 #[doc = "Pretty format the returned JSON response."]
8151 pub fn pretty(mut self, pretty: bool) -> Self {
8152 self.pretty = Some(pretty);
8153 self
8154 }
8155 #[doc = "Specify whether to profile the query execution"]
8156 pub fn profile(mut self, profile: bool) -> Self {
8157 self.profile = Some(profile);
8158 self
8159 }
8160 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
8161 pub fn request_timeout(mut self, timeout: Duration) -> Self {
8162 self.request_timeout = Some(timeout);
8163 self
8164 }
8165 #[doc = "Indicates whether hits.total should be rendered as an integer or an object in the rest search response"]
8166 pub fn rest_total_hits_as_int(mut self, rest_total_hits_as_int: bool) -> Self {
8167 self.rest_total_hits_as_int = Some(rest_total_hits_as_int);
8168 self
8169 }
8170 #[doc = "A comma-separated list of specific routing values"]
8171 pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
8172 self.routing = Some(routing);
8173 self
8174 }
8175 #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
8176 pub fn scroll(mut self, scroll: &'b str) -> Self {
8177 self.scroll = Some(scroll);
8178 self
8179 }
8180 #[doc = "Search operation type"]
8181 pub fn search_type(mut self, search_type: SearchType) -> Self {
8182 self.search_type = Some(search_type);
8183 self
8184 }
8185 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
8186 pub fn source(mut self, source: &'b str) -> Self {
8187 self.source = Some(source);
8188 self
8189 }
8190 #[doc = "Specify whether aggregation and suggester names should be prefixed by their respective types in the response"]
8191 pub fn typed_keys(mut self, typed_keys: bool) -> Self {
8192 self.typed_keys = Some(typed_keys);
8193 self
8194 }
8195 #[doc = "Creates an asynchronous call to the Search Template API that can be awaited"]
8196 pub async fn send(self) -> Result<Response, Error> {
8197 let path = self.parts.url();
8198 let method = match self.body {
8199 Some(_) => http::Method::Post,
8200 None => http::Method::Get,
8201 };
8202 let headers = self.headers;
8203 let timeout = self.request_timeout;
8204 let query_string = {
8205 #[serde_with::skip_serializing_none]
8206 #[derive(Serialize)]
8207 struct QueryParams<'b> {
8208 allow_no_indices: Option<bool>,
8209 ccs_minimize_roundtrips: Option<bool>,
8210 error_trace: Option<bool>,
8211 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8212 expand_wildcards: Option<&'b [ExpandWildcards]>,
8213 explain: Option<bool>,
8214 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8215 filter_path: Option<&'b [&'b str]>,
8216 human: Option<bool>,
8217 ignore_throttled: Option<bool>,
8218 ignore_unavailable: Option<bool>,
8219 preference: Option<&'b str>,
8220 pretty: Option<bool>,
8221 profile: Option<bool>,
8222 rest_total_hits_as_int: Option<bool>,
8223 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8224 routing: Option<&'b [&'b str]>,
8225 scroll: Option<&'b str>,
8226 search_type: Option<SearchType>,
8227 source: Option<&'b str>,
8228 typed_keys: Option<bool>,
8229 }
8230 let query_params = QueryParams {
8231 allow_no_indices: self.allow_no_indices,
8232 ccs_minimize_roundtrips: self.ccs_minimize_roundtrips,
8233 error_trace: self.error_trace,
8234 expand_wildcards: self.expand_wildcards,
8235 explain: self.explain,
8236 filter_path: self.filter_path,
8237 human: self.human,
8238 ignore_throttled: self.ignore_throttled,
8239 ignore_unavailable: self.ignore_unavailable,
8240 preference: self.preference,
8241 pretty: self.pretty,
8242 profile: self.profile,
8243 rest_total_hits_as_int: self.rest_total_hits_as_int,
8244 routing: self.routing,
8245 scroll: self.scroll,
8246 search_type: self.search_type,
8247 source: self.source,
8248 typed_keys: self.typed_keys,
8249 };
8250 Some(query_params)
8251 };
8252 let body = self.body;
8253 let response = self
8254 .transport
8255 .send(method, &path, headers, query_string.as_ref(), body, timeout)
8256 .await?;
8257 Ok(response)
8258 }
8259}
8260#[derive(Debug, Clone, PartialEq, Eq)]
8261#[doc = "API parts for the Terms Enum API"]
8262pub enum TermsEnumParts<'b> {
8263 #[doc = "Index"]
8264 Index(&'b [&'b str]),
8265}
8266impl<'b> TermsEnumParts<'b> {
8267 #[doc = "Builds a relative URL path to the Terms Enum API"]
8268 pub fn url(self) -> Cow<'static, str> {
8269 match self {
8270 TermsEnumParts::Index(index) => {
8271 let index_str = index.join(",");
8272 let encoded_index: Cow<str> =
8273 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
8274 let mut p = String::with_capacity(13usize + encoded_index.len());
8275 p.push('/');
8276 p.push_str(encoded_index.as_ref());
8277 p.push_str("/_terms_enum");
8278 p.into()
8279 }
8280 }
8281 }
8282}
8283#[doc = "Builder for the [Terms Enum API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-terms-enum.html)\n\nThe terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios."]
8284#[derive(Clone, Debug)]
8285pub struct TermsEnum<'a, 'b, B> {
8286 transport: &'a Transport,
8287 parts: TermsEnumParts<'b>,
8288 body: Option<B>,
8289 error_trace: Option<bool>,
8290 filter_path: Option<&'b [&'b str]>,
8291 headers: HeaderMap,
8292 human: Option<bool>,
8293 pretty: Option<bool>,
8294 request_timeout: Option<Duration>,
8295 source: Option<&'b str>,
8296}
8297impl<'a, 'b, B> TermsEnum<'a, 'b, B>
8298where
8299 B: Body,
8300{
8301 #[doc = "Creates a new instance of [TermsEnum] with the specified API parts"]
8302 pub fn new(transport: &'a Transport, parts: TermsEnumParts<'b>) -> Self {
8303 let headers = HeaderMap::new();
8304 TermsEnum {
8305 transport,
8306 parts,
8307 headers,
8308 body: None,
8309 error_trace: None,
8310 filter_path: None,
8311 human: None,
8312 pretty: None,
8313 request_timeout: None,
8314 source: None,
8315 }
8316 }
8317 #[doc = "The body for the API call"]
8318 pub fn body<T>(self, body: T) -> TermsEnum<'a, 'b, JsonBody<T>>
8319 where
8320 T: Serialize,
8321 {
8322 TermsEnum {
8323 transport: self.transport,
8324 parts: self.parts,
8325 body: Some(body.into()),
8326 error_trace: self.error_trace,
8327 filter_path: self.filter_path,
8328 headers: self.headers,
8329 human: self.human,
8330 pretty: self.pretty,
8331 request_timeout: self.request_timeout,
8332 source: self.source,
8333 }
8334 }
8335 #[doc = "Include the stack trace of returned errors."]
8336 pub fn error_trace(mut self, error_trace: bool) -> Self {
8337 self.error_trace = Some(error_trace);
8338 self
8339 }
8340 #[doc = "A comma-separated list of filters used to reduce the response."]
8341 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
8342 self.filter_path = Some(filter_path);
8343 self
8344 }
8345 #[doc = "Adds a HTTP header"]
8346 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
8347 self.headers.insert(key, value);
8348 self
8349 }
8350 #[doc = "Return human readable values for statistics."]
8351 pub fn human(mut self, human: bool) -> Self {
8352 self.human = Some(human);
8353 self
8354 }
8355 #[doc = "Pretty format the returned JSON response."]
8356 pub fn pretty(mut self, pretty: bool) -> Self {
8357 self.pretty = Some(pretty);
8358 self
8359 }
8360 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
8361 pub fn request_timeout(mut self, timeout: Duration) -> Self {
8362 self.request_timeout = Some(timeout);
8363 self
8364 }
8365 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
8366 pub fn source(mut self, source: &'b str) -> Self {
8367 self.source = Some(source);
8368 self
8369 }
8370 #[doc = "Creates an asynchronous call to the Terms Enum API that can be awaited"]
8371 pub async fn send(self) -> Result<Response, Error> {
8372 let path = self.parts.url();
8373 let method = match self.body {
8374 Some(_) => http::Method::Post,
8375 None => http::Method::Get,
8376 };
8377 let headers = self.headers;
8378 let timeout = self.request_timeout;
8379 let query_string = {
8380 #[serde_with::skip_serializing_none]
8381 #[derive(Serialize)]
8382 struct QueryParams<'b> {
8383 error_trace: Option<bool>,
8384 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8385 filter_path: Option<&'b [&'b str]>,
8386 human: Option<bool>,
8387 pretty: Option<bool>,
8388 source: Option<&'b str>,
8389 }
8390 let query_params = QueryParams {
8391 error_trace: self.error_trace,
8392 filter_path: self.filter_path,
8393 human: self.human,
8394 pretty: self.pretty,
8395 source: self.source,
8396 };
8397 Some(query_params)
8398 };
8399 let body = self.body;
8400 let response = self
8401 .transport
8402 .send(method, &path, headers, query_string.as_ref(), body, timeout)
8403 .await?;
8404 Ok(response)
8405 }
8406}
8407#[derive(Debug, Clone, PartialEq, Eq)]
8408#[doc = "API parts for the Termvectors API"]
8409pub enum TermvectorsParts<'b> {
8410 #[doc = "Index and Id"]
8411 IndexId(&'b str, &'b str),
8412 #[doc = "Index"]
8413 Index(&'b str),
8414}
8415impl<'b> TermvectorsParts<'b> {
8416 #[doc = "Builds a relative URL path to the Termvectors API"]
8417 pub fn url(self) -> Cow<'static, str> {
8418 match self {
8419 TermvectorsParts::IndexId(index, id) => {
8420 let encoded_index: Cow<str> =
8421 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
8422 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
8423 let mut p = String::with_capacity(15usize + encoded_index.len() + encoded_id.len());
8424 p.push('/');
8425 p.push_str(encoded_index.as_ref());
8426 p.push_str("/_termvectors/");
8427 p.push_str(encoded_id.as_ref());
8428 p.into()
8429 }
8430 TermvectorsParts::Index(index) => {
8431 let encoded_index: Cow<str> =
8432 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
8433 let mut p = String::with_capacity(14usize + encoded_index.len());
8434 p.push('/');
8435 p.push_str(encoded_index.as_ref());
8436 p.push_str("/_termvectors");
8437 p.into()
8438 }
8439 }
8440 }
8441}
8442#[doc = "Builder for the [Termvectors API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-termvectors.html)\n\nReturns information and statistics about terms in the fields of a particular document."]
8443#[derive(Clone, Debug)]
8444pub struct Termvectors<'a, 'b, B> {
8445 transport: &'a Transport,
8446 parts: TermvectorsParts<'b>,
8447 body: Option<B>,
8448 error_trace: Option<bool>,
8449 field_statistics: Option<bool>,
8450 fields: Option<&'b [&'b str]>,
8451 filter_path: Option<&'b [&'b str]>,
8452 headers: HeaderMap,
8453 human: Option<bool>,
8454 offsets: Option<bool>,
8455 payloads: Option<bool>,
8456 positions: Option<bool>,
8457 preference: Option<&'b str>,
8458 pretty: Option<bool>,
8459 realtime: Option<bool>,
8460 request_timeout: Option<Duration>,
8461 routing: Option<&'b str>,
8462 source: Option<&'b str>,
8463 term_statistics: Option<bool>,
8464 version: Option<i64>,
8465 version_type: Option<VersionType>,
8466}
8467impl<'a, 'b, B> Termvectors<'a, 'b, B>
8468where
8469 B: Body,
8470{
8471 #[doc = "Creates a new instance of [Termvectors] with the specified API parts"]
8472 pub fn new(transport: &'a Transport, parts: TermvectorsParts<'b>) -> Self {
8473 let headers = HeaderMap::new();
8474 Termvectors {
8475 transport,
8476 parts,
8477 headers,
8478 body: None,
8479 error_trace: None,
8480 field_statistics: None,
8481 fields: None,
8482 filter_path: None,
8483 human: None,
8484 offsets: None,
8485 payloads: None,
8486 positions: None,
8487 preference: None,
8488 pretty: None,
8489 realtime: None,
8490 request_timeout: None,
8491 routing: None,
8492 source: None,
8493 term_statistics: None,
8494 version: None,
8495 version_type: None,
8496 }
8497 }
8498 #[doc = "The body for the API call"]
8499 pub fn body<T>(self, body: T) -> Termvectors<'a, 'b, JsonBody<T>>
8500 where
8501 T: Serialize,
8502 {
8503 Termvectors {
8504 transport: self.transport,
8505 parts: self.parts,
8506 body: Some(body.into()),
8507 error_trace: self.error_trace,
8508 field_statistics: self.field_statistics,
8509 fields: self.fields,
8510 filter_path: self.filter_path,
8511 headers: self.headers,
8512 human: self.human,
8513 offsets: self.offsets,
8514 payloads: self.payloads,
8515 positions: self.positions,
8516 preference: self.preference,
8517 pretty: self.pretty,
8518 realtime: self.realtime,
8519 request_timeout: self.request_timeout,
8520 routing: self.routing,
8521 source: self.source,
8522 term_statistics: self.term_statistics,
8523 version: self.version,
8524 version_type: self.version_type,
8525 }
8526 }
8527 #[doc = "Include the stack trace of returned errors."]
8528 pub fn error_trace(mut self, error_trace: bool) -> Self {
8529 self.error_trace = Some(error_trace);
8530 self
8531 }
8532 #[doc = "Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned."]
8533 pub fn field_statistics(mut self, field_statistics: bool) -> Self {
8534 self.field_statistics = Some(field_statistics);
8535 self
8536 }
8537 #[doc = "A comma-separated list of fields to return."]
8538 pub fn fields(mut self, fields: &'b [&'b str]) -> Self {
8539 self.fields = Some(fields);
8540 self
8541 }
8542 #[doc = "A comma-separated list of filters used to reduce the response."]
8543 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
8544 self.filter_path = Some(filter_path);
8545 self
8546 }
8547 #[doc = "Adds a HTTP header"]
8548 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
8549 self.headers.insert(key, value);
8550 self
8551 }
8552 #[doc = "Return human readable values for statistics."]
8553 pub fn human(mut self, human: bool) -> Self {
8554 self.human = Some(human);
8555 self
8556 }
8557 #[doc = "Specifies if term offsets should be returned."]
8558 pub fn offsets(mut self, offsets: bool) -> Self {
8559 self.offsets = Some(offsets);
8560 self
8561 }
8562 #[doc = "Specifies if term payloads should be returned."]
8563 pub fn payloads(mut self, payloads: bool) -> Self {
8564 self.payloads = Some(payloads);
8565 self
8566 }
8567 #[doc = "Specifies if term positions should be returned."]
8568 pub fn positions(mut self, positions: bool) -> Self {
8569 self.positions = Some(positions);
8570 self
8571 }
8572 #[doc = "Specify the node or shard the operation should be performed on (default: random)."]
8573 pub fn preference(mut self, preference: &'b str) -> Self {
8574 self.preference = Some(preference);
8575 self
8576 }
8577 #[doc = "Pretty format the returned JSON response."]
8578 pub fn pretty(mut self, pretty: bool) -> Self {
8579 self.pretty = Some(pretty);
8580 self
8581 }
8582 #[doc = "Specifies if request is real-time as opposed to near-real-time (default: true)."]
8583 pub fn realtime(mut self, realtime: bool) -> Self {
8584 self.realtime = Some(realtime);
8585 self
8586 }
8587 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
8588 pub fn request_timeout(mut self, timeout: Duration) -> Self {
8589 self.request_timeout = Some(timeout);
8590 self
8591 }
8592 #[doc = "Specific routing value."]
8593 pub fn routing(mut self, routing: &'b str) -> Self {
8594 self.routing = Some(routing);
8595 self
8596 }
8597 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
8598 pub fn source(mut self, source: &'b str) -> Self {
8599 self.source = Some(source);
8600 self
8601 }
8602 #[doc = "Specifies if total term frequency and document frequency should be returned."]
8603 pub fn term_statistics(mut self, term_statistics: bool) -> Self {
8604 self.term_statistics = Some(term_statistics);
8605 self
8606 }
8607 #[doc = "Explicit version number for concurrency control"]
8608 pub fn version(mut self, version: i64) -> Self {
8609 self.version = Some(version);
8610 self
8611 }
8612 #[doc = "Specific version type"]
8613 pub fn version_type(mut self, version_type: VersionType) -> Self {
8614 self.version_type = Some(version_type);
8615 self
8616 }
8617 #[doc = "Creates an asynchronous call to the Termvectors API that can be awaited"]
8618 pub async fn send(self) -> Result<Response, Error> {
8619 let path = self.parts.url();
8620 let method = match self.body {
8621 Some(_) => http::Method::Post,
8622 None => http::Method::Get,
8623 };
8624 let headers = self.headers;
8625 let timeout = self.request_timeout;
8626 let query_string = {
8627 #[serde_with::skip_serializing_none]
8628 #[derive(Serialize)]
8629 struct QueryParams<'b> {
8630 error_trace: Option<bool>,
8631 field_statistics: Option<bool>,
8632 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8633 fields: Option<&'b [&'b str]>,
8634 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8635 filter_path: Option<&'b [&'b str]>,
8636 human: Option<bool>,
8637 offsets: Option<bool>,
8638 payloads: Option<bool>,
8639 positions: Option<bool>,
8640 preference: Option<&'b str>,
8641 pretty: Option<bool>,
8642 realtime: Option<bool>,
8643 routing: Option<&'b str>,
8644 source: Option<&'b str>,
8645 term_statistics: Option<bool>,
8646 version: Option<i64>,
8647 version_type: Option<VersionType>,
8648 }
8649 let query_params = QueryParams {
8650 error_trace: self.error_trace,
8651 field_statistics: self.field_statistics,
8652 fields: self.fields,
8653 filter_path: self.filter_path,
8654 human: self.human,
8655 offsets: self.offsets,
8656 payloads: self.payloads,
8657 positions: self.positions,
8658 preference: self.preference,
8659 pretty: self.pretty,
8660 realtime: self.realtime,
8661 routing: self.routing,
8662 source: self.source,
8663 term_statistics: self.term_statistics,
8664 version: self.version,
8665 version_type: self.version_type,
8666 };
8667 Some(query_params)
8668 };
8669 let body = self.body;
8670 let response = self
8671 .transport
8672 .send(method, &path, headers, query_string.as_ref(), body, timeout)
8673 .await?;
8674 Ok(response)
8675 }
8676}
8677#[derive(Debug, Clone, PartialEq, Eq)]
8678#[doc = "API parts for the Update API"]
8679pub enum UpdateParts<'b> {
8680 #[doc = "Index and Id"]
8681 IndexId(&'b str, &'b str),
8682}
8683impl<'b> UpdateParts<'b> {
8684 #[doc = "Builds a relative URL path to the Update API"]
8685 pub fn url(self) -> Cow<'static, str> {
8686 match self {
8687 UpdateParts::IndexId(index, id) => {
8688 let encoded_index: Cow<str> =
8689 percent_encode(index.as_bytes(), PARTS_ENCODED).into();
8690 let encoded_id: Cow<str> = percent_encode(id.as_bytes(), PARTS_ENCODED).into();
8691 let mut p = String::with_capacity(10usize + encoded_index.len() + encoded_id.len());
8692 p.push('/');
8693 p.push_str(encoded_index.as_ref());
8694 p.push_str("/_update/");
8695 p.push_str(encoded_id.as_ref());
8696 p.into()
8697 }
8698 }
8699 }
8700}
8701#[doc = "Builder for the [Update API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-update.html)\n\nUpdates a document with a script or partial document."]
8702#[derive(Clone, Debug)]
8703pub struct Update<'a, 'b, B> {
8704 transport: &'a Transport,
8705 parts: UpdateParts<'b>,
8706 _source: Option<&'b [&'b str]>,
8707 _source_excludes: Option<&'b [&'b str]>,
8708 _source_includes: Option<&'b [&'b str]>,
8709 body: Option<B>,
8710 error_trace: Option<bool>,
8711 filter_path: Option<&'b [&'b str]>,
8712 headers: HeaderMap,
8713 human: Option<bool>,
8714 if_primary_term: Option<i64>,
8715 if_seq_no: Option<i64>,
8716 include_source_on_error: Option<bool>,
8717 lang: Option<&'b str>,
8718 pretty: Option<bool>,
8719 refresh: Option<Refresh>,
8720 request_timeout: Option<Duration>,
8721 require_alias: Option<bool>,
8722 retry_on_conflict: Option<i64>,
8723 routing: Option<&'b str>,
8724 source: Option<&'b str>,
8725 timeout: Option<&'b str>,
8726 wait_for_active_shards: Option<&'b str>,
8727}
8728impl<'a, 'b, B> Update<'a, 'b, B>
8729where
8730 B: Body,
8731{
8732 #[doc = "Creates a new instance of [Update] with the specified API parts"]
8733 pub fn new(transport: &'a Transport, parts: UpdateParts<'b>) -> Self {
8734 let headers = HeaderMap::new();
8735 Update {
8736 transport,
8737 parts,
8738 headers,
8739 _source: None,
8740 _source_excludes: None,
8741 _source_includes: None,
8742 body: None,
8743 error_trace: None,
8744 filter_path: None,
8745 human: None,
8746 if_primary_term: None,
8747 if_seq_no: None,
8748 include_source_on_error: None,
8749 lang: None,
8750 pretty: None,
8751 refresh: None,
8752 request_timeout: None,
8753 require_alias: None,
8754 retry_on_conflict: None,
8755 routing: None,
8756 source: None,
8757 timeout: None,
8758 wait_for_active_shards: None,
8759 }
8760 }
8761 #[doc = "True or false to return the _source field or not, or a list of fields to return"]
8762 pub fn _source(mut self, _source: &'b [&'b str]) -> Self {
8763 self._source = Some(_source);
8764 self
8765 }
8766 #[doc = "A list of fields to exclude from the returned _source field"]
8767 pub fn _source_excludes(mut self, _source_excludes: &'b [&'b str]) -> Self {
8768 self._source_excludes = Some(_source_excludes);
8769 self
8770 }
8771 #[doc = "A list of fields to extract and return from the _source field"]
8772 pub fn _source_includes(mut self, _source_includes: &'b [&'b str]) -> Self {
8773 self._source_includes = Some(_source_includes);
8774 self
8775 }
8776 #[doc = "The body for the API call"]
8777 pub fn body<T>(self, body: T) -> Update<'a, 'b, JsonBody<T>>
8778 where
8779 T: Serialize,
8780 {
8781 Update {
8782 transport: self.transport,
8783 parts: self.parts,
8784 body: Some(body.into()),
8785 _source: self._source,
8786 _source_excludes: self._source_excludes,
8787 _source_includes: self._source_includes,
8788 error_trace: self.error_trace,
8789 filter_path: self.filter_path,
8790 headers: self.headers,
8791 human: self.human,
8792 if_primary_term: self.if_primary_term,
8793 if_seq_no: self.if_seq_no,
8794 include_source_on_error: self.include_source_on_error,
8795 lang: self.lang,
8796 pretty: self.pretty,
8797 refresh: self.refresh,
8798 request_timeout: self.request_timeout,
8799 require_alias: self.require_alias,
8800 retry_on_conflict: self.retry_on_conflict,
8801 routing: self.routing,
8802 source: self.source,
8803 timeout: self.timeout,
8804 wait_for_active_shards: self.wait_for_active_shards,
8805 }
8806 }
8807 #[doc = "Include the stack trace of returned errors."]
8808 pub fn error_trace(mut self, error_trace: bool) -> Self {
8809 self.error_trace = Some(error_trace);
8810 self
8811 }
8812 #[doc = "A comma-separated list of filters used to reduce the response."]
8813 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
8814 self.filter_path = Some(filter_path);
8815 self
8816 }
8817 #[doc = "Adds a HTTP header"]
8818 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
8819 self.headers.insert(key, value);
8820 self
8821 }
8822 #[doc = "Return human readable values for statistics."]
8823 pub fn human(mut self, human: bool) -> Self {
8824 self.human = Some(human);
8825 self
8826 }
8827 #[doc = "only perform the update operation if the last operation that has changed the document has the specified primary term"]
8828 pub fn if_primary_term(mut self, if_primary_term: i64) -> Self {
8829 self.if_primary_term = Some(if_primary_term);
8830 self
8831 }
8832 #[doc = "only perform the update operation if the last operation that has changed the document has the specified sequence number"]
8833 pub fn if_seq_no(mut self, if_seq_no: i64) -> Self {
8834 self.if_seq_no = Some(if_seq_no);
8835 self
8836 }
8837 #[doc = "True or false if to include the document source in the error message in case of parsing errors. Defaults to true."]
8838 pub fn include_source_on_error(mut self, include_source_on_error: bool) -> Self {
8839 self.include_source_on_error = Some(include_source_on_error);
8840 self
8841 }
8842 #[doc = "The script language (default: painless)"]
8843 pub fn lang(mut self, lang: &'b str) -> Self {
8844 self.lang = Some(lang);
8845 self
8846 }
8847 #[doc = "Pretty format the returned JSON response."]
8848 pub fn pretty(mut self, pretty: bool) -> Self {
8849 self.pretty = Some(pretty);
8850 self
8851 }
8852 #[doc = "If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes."]
8853 pub fn refresh(mut self, refresh: Refresh) -> Self {
8854 self.refresh = Some(refresh);
8855 self
8856 }
8857 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
8858 pub fn request_timeout(mut self, timeout: Duration) -> Self {
8859 self.request_timeout = Some(timeout);
8860 self
8861 }
8862 #[doc = "When true, requires destination is an alias. Default is false"]
8863 pub fn require_alias(mut self, require_alias: bool) -> Self {
8864 self.require_alias = Some(require_alias);
8865 self
8866 }
8867 #[doc = "Specify how many times should the operation be retried when a conflict occurs (default: 0)"]
8868 pub fn retry_on_conflict(mut self, retry_on_conflict: i64) -> Self {
8869 self.retry_on_conflict = Some(retry_on_conflict);
8870 self
8871 }
8872 #[doc = "Specific routing value"]
8873 pub fn routing(mut self, routing: &'b str) -> Self {
8874 self.routing = Some(routing);
8875 self
8876 }
8877 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
8878 pub fn source(mut self, source: &'b str) -> Self {
8879 self.source = Some(source);
8880 self
8881 }
8882 #[doc = "Explicit operation timeout"]
8883 pub fn timeout(mut self, timeout: &'b str) -> Self {
8884 self.timeout = Some(timeout);
8885 self
8886 }
8887 #[doc = "Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"]
8888 pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
8889 self.wait_for_active_shards = Some(wait_for_active_shards);
8890 self
8891 }
8892 #[doc = "Creates an asynchronous call to the Update API that can be awaited"]
8893 pub async fn send(self) -> Result<Response, Error> {
8894 let path = self.parts.url();
8895 let method = http::Method::Post;
8896 let headers = self.headers;
8897 let timeout = self.request_timeout;
8898 let query_string = {
8899 #[serde_with::skip_serializing_none]
8900 #[derive(Serialize)]
8901 struct QueryParams<'b> {
8902 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8903 _source: Option<&'b [&'b str]>,
8904 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8905 _source_excludes: Option<&'b [&'b str]>,
8906 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8907 _source_includes: Option<&'b [&'b str]>,
8908 error_trace: Option<bool>,
8909 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
8910 filter_path: Option<&'b [&'b str]>,
8911 human: Option<bool>,
8912 if_primary_term: Option<i64>,
8913 if_seq_no: Option<i64>,
8914 include_source_on_error: Option<bool>,
8915 lang: Option<&'b str>,
8916 pretty: Option<bool>,
8917 refresh: Option<Refresh>,
8918 require_alias: Option<bool>,
8919 retry_on_conflict: Option<i64>,
8920 routing: Option<&'b str>,
8921 source: Option<&'b str>,
8922 timeout: Option<&'b str>,
8923 wait_for_active_shards: Option<&'b str>,
8924 }
8925 let query_params = QueryParams {
8926 _source: self._source,
8927 _source_excludes: self._source_excludes,
8928 _source_includes: self._source_includes,
8929 error_trace: self.error_trace,
8930 filter_path: self.filter_path,
8931 human: self.human,
8932 if_primary_term: self.if_primary_term,
8933 if_seq_no: self.if_seq_no,
8934 include_source_on_error: self.include_source_on_error,
8935 lang: self.lang,
8936 pretty: self.pretty,
8937 refresh: self.refresh,
8938 require_alias: self.require_alias,
8939 retry_on_conflict: self.retry_on_conflict,
8940 routing: self.routing,
8941 source: self.source,
8942 timeout: self.timeout,
8943 wait_for_active_shards: self.wait_for_active_shards,
8944 };
8945 Some(query_params)
8946 };
8947 let body = self.body;
8948 let response = self
8949 .transport
8950 .send(method, &path, headers, query_string.as_ref(), body, timeout)
8951 .await?;
8952 Ok(response)
8953 }
8954}
8955#[derive(Debug, Clone, PartialEq, Eq)]
8956#[doc = "API parts for the Update By Query API"]
8957pub enum UpdateByQueryParts<'b> {
8958 #[doc = "Index"]
8959 Index(&'b [&'b str]),
8960}
8961impl<'b> UpdateByQueryParts<'b> {
8962 #[doc = "Builds a relative URL path to the Update By Query API"]
8963 pub fn url(self) -> Cow<'static, str> {
8964 match self {
8965 UpdateByQueryParts::Index(index) => {
8966 let index_str = index.join(",");
8967 let encoded_index: Cow<str> =
8968 percent_encode(index_str.as_bytes(), PARTS_ENCODED).into();
8969 let mut p = String::with_capacity(18usize + encoded_index.len());
8970 p.push('/');
8971 p.push_str(encoded_index.as_ref());
8972 p.push_str("/_update_by_query");
8973 p.into()
8974 }
8975 }
8976 }
8977}
8978#[doc = "Builder for the [Update By Query API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-update-by-query.html)\n\nPerforms an update on every document in the index without changing the source,\nfor example to pick up a mapping change."]
8979#[derive(Clone, Debug)]
8980pub struct UpdateByQuery<'a, 'b, B> {
8981 transport: &'a Transport,
8982 parts: UpdateByQueryParts<'b>,
8983 allow_no_indices: Option<bool>,
8984 analyze_wildcard: Option<bool>,
8985 analyzer: Option<&'b str>,
8986 body: Option<B>,
8987 conflicts: Option<Conflicts>,
8988 default_operator: Option<DefaultOperator>,
8989 df: Option<&'b str>,
8990 error_trace: Option<bool>,
8991 expand_wildcards: Option<&'b [ExpandWildcards]>,
8992 filter_path: Option<&'b [&'b str]>,
8993 from: Option<i64>,
8994 headers: HeaderMap,
8995 human: Option<bool>,
8996 ignore_unavailable: Option<bool>,
8997 lenient: Option<bool>,
8998 max_docs: Option<i64>,
8999 pipeline: Option<&'b str>,
9000 preference: Option<&'b str>,
9001 pretty: Option<bool>,
9002 q: Option<&'b str>,
9003 refresh: Option<bool>,
9004 request_cache: Option<bool>,
9005 request_timeout: Option<Duration>,
9006 requests_per_second: Option<i64>,
9007 routing: Option<&'b [&'b str]>,
9008 scroll: Option<&'b str>,
9009 scroll_size: Option<i64>,
9010 search_timeout: Option<&'b str>,
9011 search_type: Option<SearchType>,
9012 slices: Option<Slices>,
9013 sort: Option<&'b [&'b str]>,
9014 source: Option<&'b str>,
9015 stats: Option<&'b [&'b str]>,
9016 terminate_after: Option<i64>,
9017 timeout: Option<&'b str>,
9018 version: Option<bool>,
9019 version_type: Option<bool>,
9020 wait_for_active_shards: Option<&'b str>,
9021 wait_for_completion: Option<bool>,
9022}
9023impl<'a, 'b, B> UpdateByQuery<'a, 'b, B>
9024where
9025 B: Body,
9026{
9027 #[doc = "Creates a new instance of [UpdateByQuery] with the specified API parts"]
9028 pub fn new(transport: &'a Transport, parts: UpdateByQueryParts<'b>) -> Self {
9029 let headers = HeaderMap::new();
9030 UpdateByQuery {
9031 transport,
9032 parts,
9033 headers,
9034 allow_no_indices: None,
9035 analyze_wildcard: None,
9036 analyzer: None,
9037 body: None,
9038 conflicts: None,
9039 default_operator: None,
9040 df: None,
9041 error_trace: None,
9042 expand_wildcards: None,
9043 filter_path: None,
9044 from: None,
9045 human: None,
9046 ignore_unavailable: None,
9047 lenient: None,
9048 max_docs: None,
9049 pipeline: None,
9050 preference: None,
9051 pretty: None,
9052 q: None,
9053 refresh: None,
9054 request_cache: None,
9055 request_timeout: None,
9056 requests_per_second: None,
9057 routing: None,
9058 scroll: None,
9059 scroll_size: None,
9060 search_timeout: None,
9061 search_type: None,
9062 slices: None,
9063 sort: None,
9064 source: None,
9065 stats: None,
9066 terminate_after: None,
9067 timeout: None,
9068 version: None,
9069 version_type: None,
9070 wait_for_active_shards: None,
9071 wait_for_completion: None,
9072 }
9073 }
9074 #[doc = "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"]
9075 pub fn allow_no_indices(mut self, allow_no_indices: bool) -> Self {
9076 self.allow_no_indices = Some(allow_no_indices);
9077 self
9078 }
9079 #[doc = "Specify whether wildcard and prefix queries should be analyzed (default: false)"]
9080 pub fn analyze_wildcard(mut self, analyze_wildcard: bool) -> Self {
9081 self.analyze_wildcard = Some(analyze_wildcard);
9082 self
9083 }
9084 #[doc = "The analyzer to use for the query string"]
9085 pub fn analyzer(mut self, analyzer: &'b str) -> Self {
9086 self.analyzer = Some(analyzer);
9087 self
9088 }
9089 #[doc = "The body for the API call"]
9090 pub fn body<T>(self, body: T) -> UpdateByQuery<'a, 'b, JsonBody<T>>
9091 where
9092 T: Serialize,
9093 {
9094 UpdateByQuery {
9095 transport: self.transport,
9096 parts: self.parts,
9097 body: Some(body.into()),
9098 allow_no_indices: self.allow_no_indices,
9099 analyze_wildcard: self.analyze_wildcard,
9100 analyzer: self.analyzer,
9101 conflicts: self.conflicts,
9102 default_operator: self.default_operator,
9103 df: self.df,
9104 error_trace: self.error_trace,
9105 expand_wildcards: self.expand_wildcards,
9106 filter_path: self.filter_path,
9107 from: self.from,
9108 headers: self.headers,
9109 human: self.human,
9110 ignore_unavailable: self.ignore_unavailable,
9111 lenient: self.lenient,
9112 max_docs: self.max_docs,
9113 pipeline: self.pipeline,
9114 preference: self.preference,
9115 pretty: self.pretty,
9116 q: self.q,
9117 refresh: self.refresh,
9118 request_cache: self.request_cache,
9119 request_timeout: self.request_timeout,
9120 requests_per_second: self.requests_per_second,
9121 routing: self.routing,
9122 scroll: self.scroll,
9123 scroll_size: self.scroll_size,
9124 search_timeout: self.search_timeout,
9125 search_type: self.search_type,
9126 slices: self.slices,
9127 sort: self.sort,
9128 source: self.source,
9129 stats: self.stats,
9130 terminate_after: self.terminate_after,
9131 timeout: self.timeout,
9132 version: self.version,
9133 version_type: self.version_type,
9134 wait_for_active_shards: self.wait_for_active_shards,
9135 wait_for_completion: self.wait_for_completion,
9136 }
9137 }
9138 #[doc = "What to do when the update by query hits version conflicts?"]
9139 pub fn conflicts(mut self, conflicts: Conflicts) -> Self {
9140 self.conflicts = Some(conflicts);
9141 self
9142 }
9143 #[doc = "The default operator for query string query (AND or OR)"]
9144 pub fn default_operator(mut self, default_operator: DefaultOperator) -> Self {
9145 self.default_operator = Some(default_operator);
9146 self
9147 }
9148 #[doc = "The field to use as default where no field prefix is given in the query string"]
9149 pub fn df(mut self, df: &'b str) -> Self {
9150 self.df = Some(df);
9151 self
9152 }
9153 #[doc = "Include the stack trace of returned errors."]
9154 pub fn error_trace(mut self, error_trace: bool) -> Self {
9155 self.error_trace = Some(error_trace);
9156 self
9157 }
9158 #[doc = "Whether to expand wildcard expression to concrete indices that are open, closed or both."]
9159 pub fn expand_wildcards(mut self, expand_wildcards: &'b [ExpandWildcards]) -> Self {
9160 self.expand_wildcards = Some(expand_wildcards);
9161 self
9162 }
9163 #[doc = "A comma-separated list of filters used to reduce the response."]
9164 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
9165 self.filter_path = Some(filter_path);
9166 self
9167 }
9168 #[doc = "Starting offset (default: 0)"]
9169 pub fn from(mut self, from: i64) -> Self {
9170 self.from = Some(from);
9171 self
9172 }
9173 #[doc = "Adds a HTTP header"]
9174 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
9175 self.headers.insert(key, value);
9176 self
9177 }
9178 #[doc = "Return human readable values for statistics."]
9179 pub fn human(mut self, human: bool) -> Self {
9180 self.human = Some(human);
9181 self
9182 }
9183 #[doc = "Whether specified concrete indices should be ignored when unavailable (missing or closed)"]
9184 pub fn ignore_unavailable(mut self, ignore_unavailable: bool) -> Self {
9185 self.ignore_unavailable = Some(ignore_unavailable);
9186 self
9187 }
9188 #[doc = "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored"]
9189 pub fn lenient(mut self, lenient: bool) -> Self {
9190 self.lenient = Some(lenient);
9191 self
9192 }
9193 #[doc = "Maximum number of documents to process (default: all documents)"]
9194 pub fn max_docs(mut self, max_docs: i64) -> Self {
9195 self.max_docs = Some(max_docs);
9196 self
9197 }
9198 #[doc = "Ingest pipeline to set on index requests made by this action. (default: none)"]
9199 pub fn pipeline(mut self, pipeline: &'b str) -> Self {
9200 self.pipeline = Some(pipeline);
9201 self
9202 }
9203 #[doc = "Specify the node or shard the operation should be performed on (default: random)"]
9204 pub fn preference(mut self, preference: &'b str) -> Self {
9205 self.preference = Some(preference);
9206 self
9207 }
9208 #[doc = "Pretty format the returned JSON response."]
9209 pub fn pretty(mut self, pretty: bool) -> Self {
9210 self.pretty = Some(pretty);
9211 self
9212 }
9213 #[doc = "Query in the Lucene query string syntax"]
9214 pub fn q(mut self, q: &'b str) -> Self {
9215 self.q = Some(q);
9216 self
9217 }
9218 #[doc = "Should the affected indexes be refreshed?"]
9219 pub fn refresh(mut self, refresh: bool) -> Self {
9220 self.refresh = Some(refresh);
9221 self
9222 }
9223 #[doc = "Specify if request cache should be used for this request or not, defaults to index level setting"]
9224 pub fn request_cache(mut self, request_cache: bool) -> Self {
9225 self.request_cache = Some(request_cache);
9226 self
9227 }
9228 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
9229 pub fn request_timeout(mut self, timeout: Duration) -> Self {
9230 self.request_timeout = Some(timeout);
9231 self
9232 }
9233 #[doc = "The throttle to set on this request in sub-requests per second. -1 means no throttle."]
9234 pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
9235 self.requests_per_second = Some(requests_per_second);
9236 self
9237 }
9238 #[doc = "A comma-separated list of specific routing values"]
9239 pub fn routing(mut self, routing: &'b [&'b str]) -> Self {
9240 self.routing = Some(routing);
9241 self
9242 }
9243 #[doc = "Specify how long a consistent view of the index should be maintained for scrolled search"]
9244 pub fn scroll(mut self, scroll: &'b str) -> Self {
9245 self.scroll = Some(scroll);
9246 self
9247 }
9248 #[doc = "Size on the scroll request powering the update by query"]
9249 pub fn scroll_size(mut self, scroll_size: i64) -> Self {
9250 self.scroll_size = Some(scroll_size);
9251 self
9252 }
9253 #[doc = "Explicit timeout for each search request. Defaults to no timeout."]
9254 pub fn search_timeout(mut self, search_timeout: &'b str) -> Self {
9255 self.search_timeout = Some(search_timeout);
9256 self
9257 }
9258 #[doc = "Search operation type"]
9259 pub fn search_type(mut self, search_type: SearchType) -> Self {
9260 self.search_type = Some(search_type);
9261 self
9262 }
9263 #[doc = "The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`."]
9264 pub fn slices(mut self, slices: Slices) -> Self {
9265 self.slices = Some(slices);
9266 self
9267 }
9268 #[doc = "A comma-separated list of <field>:<direction> pairs"]
9269 pub fn sort(mut self, sort: &'b [&'b str]) -> Self {
9270 self.sort = Some(sort);
9271 self
9272 }
9273 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
9274 pub fn source(mut self, source: &'b str) -> Self {
9275 self.source = Some(source);
9276 self
9277 }
9278 #[doc = "Specific 'tag' of the request for logging and statistical purposes"]
9279 pub fn stats(mut self, stats: &'b [&'b str]) -> Self {
9280 self.stats = Some(stats);
9281 self
9282 }
9283 #[doc = "The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early."]
9284 pub fn terminate_after(mut self, terminate_after: i64) -> Self {
9285 self.terminate_after = Some(terminate_after);
9286 self
9287 }
9288 #[doc = "Time each individual bulk request should wait for shards that are unavailable."]
9289 pub fn timeout(mut self, timeout: &'b str) -> Self {
9290 self.timeout = Some(timeout);
9291 self
9292 }
9293 #[doc = "Specify whether to return document version as part of a hit"]
9294 pub fn version(mut self, version: bool) -> Self {
9295 self.version = Some(version);
9296 self
9297 }
9298 #[doc = "Should the document increment the version number (internal) on hit or not (reindex)"]
9299 pub fn version_type(mut self, version_type: bool) -> Self {
9300 self.version_type = Some(version_type);
9301 self
9302 }
9303 #[doc = "Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)"]
9304 pub fn wait_for_active_shards(mut self, wait_for_active_shards: &'b str) -> Self {
9305 self.wait_for_active_shards = Some(wait_for_active_shards);
9306 self
9307 }
9308 #[doc = "Should the request should block until the update by query operation is complete."]
9309 pub fn wait_for_completion(mut self, wait_for_completion: bool) -> Self {
9310 self.wait_for_completion = Some(wait_for_completion);
9311 self
9312 }
9313 #[doc = "Creates an asynchronous call to the Update By Query API that can be awaited"]
9314 pub async fn send(self) -> Result<Response, Error> {
9315 let path = self.parts.url();
9316 let method = http::Method::Post;
9317 let headers = self.headers;
9318 let timeout = self.request_timeout;
9319 let query_string = {
9320 #[serde_with::skip_serializing_none]
9321 #[derive(Serialize)]
9322 struct QueryParams<'b> {
9323 allow_no_indices: Option<bool>,
9324 analyze_wildcard: Option<bool>,
9325 analyzer: Option<&'b str>,
9326 conflicts: Option<Conflicts>,
9327 default_operator: Option<DefaultOperator>,
9328 df: Option<&'b str>,
9329 error_trace: Option<bool>,
9330 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
9331 expand_wildcards: Option<&'b [ExpandWildcards]>,
9332 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
9333 filter_path: Option<&'b [&'b str]>,
9334 from: Option<i64>,
9335 human: Option<bool>,
9336 ignore_unavailable: Option<bool>,
9337 lenient: Option<bool>,
9338 max_docs: Option<i64>,
9339 pipeline: Option<&'b str>,
9340 preference: Option<&'b str>,
9341 pretty: Option<bool>,
9342 q: Option<&'b str>,
9343 refresh: Option<bool>,
9344 request_cache: Option<bool>,
9345 requests_per_second: Option<i64>,
9346 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
9347 routing: Option<&'b [&'b str]>,
9348 scroll: Option<&'b str>,
9349 scroll_size: Option<i64>,
9350 search_timeout: Option<&'b str>,
9351 search_type: Option<SearchType>,
9352 slices: Option<Slices>,
9353 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
9354 sort: Option<&'b [&'b str]>,
9355 source: Option<&'b str>,
9356 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
9357 stats: Option<&'b [&'b str]>,
9358 terminate_after: Option<i64>,
9359 timeout: Option<&'b str>,
9360 version: Option<bool>,
9361 version_type: Option<bool>,
9362 wait_for_active_shards: Option<&'b str>,
9363 wait_for_completion: Option<bool>,
9364 }
9365 let query_params = QueryParams {
9366 allow_no_indices: self.allow_no_indices,
9367 analyze_wildcard: self.analyze_wildcard,
9368 analyzer: self.analyzer,
9369 conflicts: self.conflicts,
9370 default_operator: self.default_operator,
9371 df: self.df,
9372 error_trace: self.error_trace,
9373 expand_wildcards: self.expand_wildcards,
9374 filter_path: self.filter_path,
9375 from: self.from,
9376 human: self.human,
9377 ignore_unavailable: self.ignore_unavailable,
9378 lenient: self.lenient,
9379 max_docs: self.max_docs,
9380 pipeline: self.pipeline,
9381 preference: self.preference,
9382 pretty: self.pretty,
9383 q: self.q,
9384 refresh: self.refresh,
9385 request_cache: self.request_cache,
9386 requests_per_second: self.requests_per_second,
9387 routing: self.routing,
9388 scroll: self.scroll,
9389 scroll_size: self.scroll_size,
9390 search_timeout: self.search_timeout,
9391 search_type: self.search_type,
9392 slices: self.slices,
9393 sort: self.sort,
9394 source: self.source,
9395 stats: self.stats,
9396 terminate_after: self.terminate_after,
9397 timeout: self.timeout,
9398 version: self.version,
9399 version_type: self.version_type,
9400 wait_for_active_shards: self.wait_for_active_shards,
9401 wait_for_completion: self.wait_for_completion,
9402 };
9403 Some(query_params)
9404 };
9405 let body = self.body;
9406 let response = self
9407 .transport
9408 .send(method, &path, headers, query_string.as_ref(), body, timeout)
9409 .await?;
9410 Ok(response)
9411 }
9412}
9413#[derive(Debug, Clone, PartialEq, Eq)]
9414#[doc = "API parts for the Update By Query Rethrottle API"]
9415pub enum UpdateByQueryRethrottleParts<'b> {
9416 #[doc = "TaskId"]
9417 TaskId(&'b str),
9418}
9419impl<'b> UpdateByQueryRethrottleParts<'b> {
9420 #[doc = "Builds a relative URL path to the Update By Query Rethrottle API"]
9421 pub fn url(self) -> Cow<'static, str> {
9422 match self {
9423 UpdateByQueryRethrottleParts::TaskId(task_id) => {
9424 let encoded_task_id: Cow<str> =
9425 percent_encode(task_id.as_bytes(), PARTS_ENCODED).into();
9426 let mut p = String::with_capacity(30usize + encoded_task_id.len());
9427 p.push_str("/_update_by_query/");
9428 p.push_str(encoded_task_id.as_ref());
9429 p.push_str("/_rethrottle");
9430 p.into()
9431 }
9432 }
9433 }
9434}
9435#[doc = "Builder for the [Update By Query Rethrottle API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-update-by-query.html)\n\nChanges the number of requests per second for a particular Update By Query operation."]
9436#[derive(Clone, Debug)]
9437pub struct UpdateByQueryRethrottle<'a, 'b, B> {
9438 transport: &'a Transport,
9439 parts: UpdateByQueryRethrottleParts<'b>,
9440 body: Option<B>,
9441 error_trace: Option<bool>,
9442 filter_path: Option<&'b [&'b str]>,
9443 headers: HeaderMap,
9444 human: Option<bool>,
9445 pretty: Option<bool>,
9446 request_timeout: Option<Duration>,
9447 requests_per_second: Option<i64>,
9448 source: Option<&'b str>,
9449}
9450impl<'a, 'b, B> UpdateByQueryRethrottle<'a, 'b, B>
9451where
9452 B: Body,
9453{
9454 #[doc = "Creates a new instance of [UpdateByQueryRethrottle] with the specified API parts"]
9455 pub fn new(transport: &'a Transport, parts: UpdateByQueryRethrottleParts<'b>) -> Self {
9456 let headers = HeaderMap::new();
9457 UpdateByQueryRethrottle {
9458 transport,
9459 parts,
9460 headers,
9461 body: None,
9462 error_trace: None,
9463 filter_path: None,
9464 human: None,
9465 pretty: None,
9466 request_timeout: None,
9467 requests_per_second: None,
9468 source: None,
9469 }
9470 }
9471 #[doc = "The body for the API call"]
9472 pub fn body<T>(self, body: T) -> UpdateByQueryRethrottle<'a, 'b, JsonBody<T>>
9473 where
9474 T: Serialize,
9475 {
9476 UpdateByQueryRethrottle {
9477 transport: self.transport,
9478 parts: self.parts,
9479 body: Some(body.into()),
9480 error_trace: self.error_trace,
9481 filter_path: self.filter_path,
9482 headers: self.headers,
9483 human: self.human,
9484 pretty: self.pretty,
9485 request_timeout: self.request_timeout,
9486 requests_per_second: self.requests_per_second,
9487 source: self.source,
9488 }
9489 }
9490 #[doc = "Include the stack trace of returned errors."]
9491 pub fn error_trace(mut self, error_trace: bool) -> Self {
9492 self.error_trace = Some(error_trace);
9493 self
9494 }
9495 #[doc = "A comma-separated list of filters used to reduce the response."]
9496 pub fn filter_path(mut self, filter_path: &'b [&'b str]) -> Self {
9497 self.filter_path = Some(filter_path);
9498 self
9499 }
9500 #[doc = "Adds a HTTP header"]
9501 pub fn header(mut self, key: HeaderName, value: HeaderValue) -> Self {
9502 self.headers.insert(key, value);
9503 self
9504 }
9505 #[doc = "Return human readable values for statistics."]
9506 pub fn human(mut self, human: bool) -> Self {
9507 self.human = Some(human);
9508 self
9509 }
9510 #[doc = "Pretty format the returned JSON response."]
9511 pub fn pretty(mut self, pretty: bool) -> Self {
9512 self.pretty = Some(pretty);
9513 self
9514 }
9515 #[doc = "Sets a request timeout for this API call.\n\nThe timeout is applied from when the request starts connecting until the response body has finished."]
9516 pub fn request_timeout(mut self, timeout: Duration) -> Self {
9517 self.request_timeout = Some(timeout);
9518 self
9519 }
9520 #[doc = "The throttle to set on this request in floating sub-requests per second. -1 means set no throttle."]
9521 pub fn requests_per_second(mut self, requests_per_second: i64) -> Self {
9522 self.requests_per_second = Some(requests_per_second);
9523 self
9524 }
9525 #[doc = "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests."]
9526 pub fn source(mut self, source: &'b str) -> Self {
9527 self.source = Some(source);
9528 self
9529 }
9530 #[doc = "Creates an asynchronous call to the Update By Query Rethrottle API that can be awaited"]
9531 pub async fn send(self) -> Result<Response, Error> {
9532 let path = self.parts.url();
9533 let method = http::Method::Post;
9534 let headers = self.headers;
9535 let timeout = self.request_timeout;
9536 let query_string = {
9537 #[serde_with::skip_serializing_none]
9538 #[derive(Serialize)]
9539 struct QueryParams<'b> {
9540 error_trace: Option<bool>,
9541 #[serde(serialize_with = "crate::client::serialize_coll_qs")]
9542 filter_path: Option<&'b [&'b str]>,
9543 human: Option<bool>,
9544 pretty: Option<bool>,
9545 requests_per_second: Option<i64>,
9546 source: Option<&'b str>,
9547 }
9548 let query_params = QueryParams {
9549 error_trace: self.error_trace,
9550 filter_path: self.filter_path,
9551 human: self.human,
9552 pretty: self.pretty,
9553 requests_per_second: self.requests_per_second,
9554 source: self.source,
9555 };
9556 Some(query_params)
9557 };
9558 let body = self.body;
9559 let response = self
9560 .transport
9561 .send(method, &path, headers, query_string.as_ref(), body, timeout)
9562 .await?;
9563 Ok(response)
9564 }
9565}
9566#[allow(clippy::needless_lifetimes)]
9567impl Elasticsearch {
9568 #[doc = "[Bulk API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-bulk.html)\n\nAllows to perform multiple index/update/delete operations in a single request."]
9569 pub fn bulk<'a, 'b>(&'a self, parts: BulkParts<'b>) -> Bulk<'a, 'b, ()> {
9570 Bulk::new(self.transport(), parts)
9571 }
9572 #[doc = "[Capabilities API](https://github.com/elastic/elasticsearch/blob/main/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/README.asciidoc#require-or-skip-api-capabilities)\n\nChecks if the specified combination of method, API, parameters, and arbitrary capabilities are supported"]
9573 #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "]
9574 #[cfg(feature = "experimental-apis")]
9575 pub fn capabilities<'a, 'b>(&'a self) -> Capabilities<'a, 'b> {
9576 Capabilities::new(self.transport())
9577 }
9578 #[doc = "[Clear Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/clear-scroll-api.html)\n\nExplicitly clears the search context for a scroll."]
9579 pub fn clear_scroll<'a, 'b>(&'a self, parts: ClearScrollParts<'b>) -> ClearScroll<'a, 'b, ()> {
9580 ClearScroll::new(self.transport(), parts)
9581 }
9582 #[doc = "[Close Point In Time API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/point-in-time-api.html)\n\nClose a point in time"]
9583 pub fn close_point_in_time<'a, 'b>(&'a self) -> ClosePointInTime<'a, 'b, ()> {
9584 ClosePointInTime::new(self.transport())
9585 }
9586 #[doc = "[Count API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-count.html)\n\nReturns number of documents matching a query."]
9587 pub fn count<'a, 'b>(&'a self, parts: CountParts<'b>) -> Count<'a, 'b, ()> {
9588 Count::new(self.transport(), parts)
9589 }
9590 #[doc = "[Create API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-index_.html)\n\nCreates a new document in the index.\n\nReturns a 409 response when a document with a same ID already exists in the index."]
9591 pub fn create<'a, 'b>(&'a self, parts: CreateParts<'b>) -> Create<'a, 'b, ()> {
9592 Create::new(self.transport(), parts)
9593 }
9594 #[doc = "[Delete API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-delete.html)\n\nRemoves a document from the index."]
9595 pub fn delete<'a, 'b>(&'a self, parts: DeleteParts<'b>) -> Delete<'a, 'b> {
9596 Delete::new(self.transport(), parts)
9597 }
9598 #[doc = "[Delete By Query API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-delete-by-query.html)\n\nDeletes documents matching the provided query."]
9599 pub fn delete_by_query<'a, 'b>(
9600 &'a self,
9601 parts: DeleteByQueryParts<'b>,
9602 ) -> DeleteByQuery<'a, 'b, ()> {
9603 DeleteByQuery::new(self.transport(), parts)
9604 }
9605 #[doc = "[Delete By Query Rethrottle API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-delete-by-query.html)\n\nChanges the number of requests per second for a particular Delete By Query operation."]
9606 pub fn delete_by_query_rethrottle<'a, 'b>(
9607 &'a self,
9608 parts: DeleteByQueryRethrottleParts<'b>,
9609 ) -> DeleteByQueryRethrottle<'a, 'b, ()> {
9610 DeleteByQueryRethrottle::new(self.transport(), parts)
9611 }
9612 #[doc = "[Delete Script API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/modules-scripting.html)\n\nDeletes a script."]
9613 pub fn delete_script<'a, 'b>(&'a self, parts: DeleteScriptParts<'b>) -> DeleteScript<'a, 'b> {
9614 DeleteScript::new(self.transport(), parts)
9615 }
9616 #[doc = "[Exists API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-get.html)\n\nReturns information about whether a document exists in an index."]
9617 pub fn exists<'a, 'b>(&'a self, parts: ExistsParts<'b>) -> Exists<'a, 'b> {
9618 Exists::new(self.transport(), parts)
9619 }
9620 #[doc = "[Exists Source API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-get.html)\n\nReturns information about whether a document source exists in an index."]
9621 pub fn exists_source<'a, 'b>(&'a self, parts: ExistsSourceParts<'b>) -> ExistsSource<'a, 'b> {
9622 ExistsSource::new(self.transport(), parts)
9623 }
9624 #[doc = "[Explain API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-explain.html)\n\nReturns information about why a specific matches (or doesn't match) a query."]
9625 pub fn explain<'a, 'b>(&'a self, parts: ExplainParts<'b>) -> Explain<'a, 'b, ()> {
9626 Explain::new(self.transport(), parts)
9627 }
9628 #[doc = "[Field Caps API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-field-caps.html)\n\nReturns the information about the capabilities of fields among multiple indices."]
9629 pub fn field_caps<'a, 'b>(&'a self, parts: FieldCapsParts<'b>) -> FieldCaps<'a, 'b, ()> {
9630 FieldCaps::new(self.transport(), parts)
9631 }
9632 #[doc = "[Get API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-get.html)\n\nReturns a document."]
9633 pub fn get<'a, 'b>(&'a self, parts: GetParts<'b>) -> Get<'a, 'b> {
9634 Get::new(self.transport(), parts)
9635 }
9636 #[doc = "[Get Script API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/modules-scripting.html)\n\nReturns a script."]
9637 pub fn get_script<'a, 'b>(&'a self, parts: GetScriptParts<'b>) -> GetScript<'a, 'b> {
9638 GetScript::new(self.transport(), parts)
9639 }
9640 #[doc = "[Get Script Context API](https://www.elastic.co/guide/en/elasticsearch/painless/9.0/painless-contexts.html)\n\nReturns all script contexts."]
9641 pub fn get_script_context<'a, 'b>(&'a self) -> GetScriptContext<'a, 'b> {
9642 GetScriptContext::new(self.transport())
9643 }
9644 #[doc = "[Get Script Languages API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/modules-scripting.html)\n\nReturns available script types, languages and contexts"]
9645 pub fn get_script_languages<'a, 'b>(&'a self) -> GetScriptLanguages<'a, 'b> {
9646 GetScriptLanguages::new(self.transport())
9647 }
9648 #[doc = "[Get Source API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-get.html)\n\nReturns the source of a document."]
9649 pub fn get_source<'a, 'b>(&'a self, parts: GetSourceParts<'b>) -> GetSource<'a, 'b> {
9650 GetSource::new(self.transport(), parts)
9651 }
9652 #[doc = "[Health Report API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/health-api.html)\n\nReturns the health of the cluster."]
9653 pub fn health_report<'a, 'b>(&'a self, parts: HealthReportParts<'b>) -> HealthReport<'a, 'b> {
9654 HealthReport::new(self.transport(), parts)
9655 }
9656 #[doc = "[Index API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-index_.html)\n\nCreates or updates a document in an index."]
9657 pub fn index<'a, 'b>(&'a self, parts: IndexParts<'b>) -> Index<'a, 'b, ()> {
9658 Index::new(self.transport(), parts)
9659 }
9660 #[doc = "[Info API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/index.html)\n\nReturns basic information about the cluster."]
9661 pub fn info<'a, 'b>(&'a self) -> Info<'a, 'b> {
9662 Info::new(self.transport())
9663 }
9664 #[doc = "[Mget API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-multi-get.html)\n\nAllows to get multiple documents in one request."]
9665 pub fn mget<'a, 'b>(&'a self, parts: MgetParts<'b>) -> Mget<'a, 'b, ()> {
9666 Mget::new(self.transport(), parts)
9667 }
9668 #[doc = "[Msearch API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-multi-search.html)\n\nAllows to execute several search operations in one request.\n\n# Examples\n\nTo make a multi-search request, specify the headers and bodies\nfor the search requests in the body. The body accepts a\n`Vec<T>` where `T` implements the [Body] trait.\n\n```rust,no_run\n# use elasticsearch::{Elasticsearch, Error, MsearchParts};\n# use elasticsearch::http::request::JsonBody;\n# use serde_json::{json, Value};\n# async fn doc() -> Result<(), Box<dyn std::error::Error>> {\nlet client = Elasticsearch::default();\n\nfn print_hits(hits: &[Value]) {\n for hit in hits {\n println!(\n \"id: '{}', source: '{}', score: '{}'\",\n hit[\"_id\"].as_str().unwrap(),\n hit[\"_source\"],\n hit[\"_score\"].as_f64().unwrap()\n );\n }\n}\n\nlet msearch_response = client\n .msearch(MsearchParts::None)\n .body::<JsonBody<Value>>(vec![\n json!({\"index\":\"cat_food\"}).into(),\n json!({\"query\":{\"term\":{\"name\":{\"term\":\"Whiskers\"}}}}).into(),\n json!({\"index\":\"cat_food\"}).into(),\n json!({\"query\":{\"term\":{\"name\":{\"term\":\"Chicken\"}}}}).into(),\n json!({\"index\":\"cat_food\"}).into(),\n json!({\"query\":{\"term\":{\"name\":{\"term\":\"Turkey\"}}}}).into(),\n ])\n .send()\n .await?;\n\nlet json: Value = msearch_response.json().await?;\n\n// iterate over the responses\nfor response in json[\"responses\"].as_array().unwrap()\n{\n print_hits(response[\"hits\"][\"hits\"].as_array().unwrap());\n}\n \n# Ok(())\n# }\n```\n"]
9669 pub fn msearch<'a, 'b>(&'a self, parts: MsearchParts<'b>) -> Msearch<'a, 'b, ()> {
9670 Msearch::new(self.transport(), parts)
9671 }
9672 #[doc = "[Msearch Template API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-multi-search.html)\n\nAllows to execute several search template operations in one request."]
9673 pub fn msearch_template<'a, 'b>(
9674 &'a self,
9675 parts: MsearchTemplateParts<'b>,
9676 ) -> MsearchTemplate<'a, 'b, ()> {
9677 MsearchTemplate::new(self.transport(), parts)
9678 }
9679 #[doc = "[Mtermvectors API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-multi-termvectors.html)\n\nReturns multiple termvectors in one request."]
9680 pub fn mtermvectors<'a, 'b>(
9681 &'a self,
9682 parts: MtermvectorsParts<'b>,
9683 ) -> Mtermvectors<'a, 'b, ()> {
9684 Mtermvectors::new(self.transport(), parts)
9685 }
9686 #[doc = "[Open Point In Time API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/point-in-time-api.html)\n\nOpen a point in time that can be used in subsequent searches"]
9687 pub fn open_point_in_time<'a, 'b>(
9688 &'a self,
9689 parts: OpenPointInTimeParts<'b>,
9690 ) -> OpenPointInTime<'a, 'b, ()> {
9691 OpenPointInTime::new(self.transport(), parts)
9692 }
9693 #[doc = "[Ping API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/index.html)\n\nReturns whether the cluster is running."]
9694 pub fn ping<'a, 'b>(&'a self) -> Ping<'a, 'b> {
9695 Ping::new(self.transport())
9696 }
9697 #[doc = "[Put Script API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/modules-scripting.html)\n\nCreates or updates a script."]
9698 pub fn put_script<'a, 'b>(&'a self, parts: PutScriptParts<'b>) -> PutScript<'a, 'b, ()> {
9699 PutScript::new(self.transport(), parts)
9700 }
9701 #[doc = "[Rank Eval API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-rank-eval.html)\n\nAllows to evaluate the quality of ranked search results over a set of typical search queries"]
9702 pub fn rank_eval<'a, 'b>(&'a self, parts: RankEvalParts<'b>) -> RankEval<'a, 'b, ()> {
9703 RankEval::new(self.transport(), parts)
9704 }
9705 #[doc = "[Reindex API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-reindex.html)\n\nAllows to copy documents from one index to another, optionally filtering the source\ndocuments by a query, changing the destination index settings, or fetching the\ndocuments from a remote cluster."]
9706 pub fn reindex<'a, 'b>(&'a self) -> Reindex<'a, 'b, ()> {
9707 Reindex::new(self.transport())
9708 }
9709 #[doc = "[Reindex Rethrottle API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-reindex.html)\n\nChanges the number of requests per second for a particular Reindex operation."]
9710 pub fn reindex_rethrottle<'a, 'b>(
9711 &'a self,
9712 parts: ReindexRethrottleParts<'b>,
9713 ) -> ReindexRethrottle<'a, 'b, ()> {
9714 ReindexRethrottle::new(self.transport(), parts)
9715 }
9716 #[doc = "[Render Search Template API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/render-search-template-api.html)\n\nAllows to use the Mustache language to pre-render a search definition."]
9717 pub fn render_search_template<'a, 'b>(
9718 &'a self,
9719 parts: RenderSearchTemplateParts<'b>,
9720 ) -> RenderSearchTemplate<'a, 'b, ()> {
9721 RenderSearchTemplate::new(self.transport(), parts)
9722 }
9723 #[doc = "[Scripts Painless Execute API](https://www.elastic.co/guide/en/elasticsearch/painless/9.0/painless-execute-api.html)\n\nAllows an arbitrary script to be executed and a result to be returned"]
9724 #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "]
9725 #[cfg(feature = "experimental-apis")]
9726 pub fn scripts_painless_execute<'a, 'b>(&'a self) -> ScriptsPainlessExecute<'a, 'b, ()> {
9727 ScriptsPainlessExecute::new(self.transport())
9728 }
9729 #[doc = "[Scroll API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-request-body.html#request-body-search-scroll)\n\nAllows to retrieve a large numbers of results from a single search request.\n\n# Examples\n\nTo initiate a scroll, make search API call with a specified `scroll` timeout,\nthen fetch the next set of hits using the `_scroll_id` returned in\nthe response. Once no more hits are returned, clear the scroll.\n\n```rust,no_run\n# use elasticsearch::{Elasticsearch, Error, SearchParts, ScrollParts, ClearScrollParts};\n# use serde_json::{json, Value};\n# async fn doc() -> Result<(), Box<dyn std::error::Error>> {\nlet client = Elasticsearch::default();\n\nfn print_hits(hits: &[Value]) {\n for hit in hits {\n println!(\n \"id: '{}', source: '{}', score: '{}'\",\n hit[\"_id\"].as_str().unwrap(),\n hit[\"_source\"],\n hit[\"_score\"].as_f64().unwrap()\n );\n }\n}\n\nlet scroll = \"1m\";\nlet mut response = client\n .search(SearchParts::Index(&[\"tweets\"]))\n .scroll(scroll)\n .body(json!({\n \"query\": {\n \"match\": {\n \"body\": {\n \"query\": \"Elasticsearch rust\",\n \"operator\": \"AND\"\n }\n }\n }\n }))\n .send()\n .await?;\n\nlet mut response_body = response.json::<Value>().await?;\nlet mut scroll_id = response_body[\"_scroll_id\"].as_str().unwrap();\nlet mut hits = response_body[\"hits\"][\"hits\"].as_array().unwrap();\n\nprint_hits(hits);\n\nwhile hits.len() > 0 {\n response = client\n .scroll(ScrollParts::None)\n .body(json!({\n \"scroll\": scroll,\n \"scroll_id\": scroll_id\n }))\n .send()\n .await?;\n\n response_body = response.json::<Value>().await?;\n scroll_id = response_body[\"_scroll_id\"].as_str().unwrap();\n hits = response_body[\"hits\"][\"hits\"].as_array().unwrap();\n print_hits(hits);\n}\n\nresponse = client\n .clear_scroll(ClearScrollParts::None)\n .body(json!({\n \"scroll_id\": scroll_id\n }))\n .send()\n .await?;\n \n# Ok(())\n# }\n```"]
9730 pub fn scroll<'a, 'b>(&'a self, parts: ScrollParts<'b>) -> Scroll<'a, 'b, ()> {
9731 Scroll::new(self.transport(), parts)
9732 }
9733 #[doc = "[Search API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-search.html)\n\nReturns results matching a query."]
9734 pub fn search<'a, 'b>(&'a self, parts: SearchParts<'b>) -> Search<'a, 'b, ()> {
9735 Search::new(self.transport(), parts)
9736 }
9737 #[doc = "[Search Mvt API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-vector-tile-api.html)\n\nSearches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile."]
9738 #[doc = " \n# Optional, experimental\nThis requires the `experimental-apis` feature. Can have breaking changes in future\nversions or might even be removed entirely.\n "]
9739 #[cfg(feature = "experimental-apis")]
9740 pub fn search_mvt<'a, 'b>(&'a self, parts: SearchMvtParts<'b>) -> SearchMvt<'a, 'b, ()> {
9741 SearchMvt::new(self.transport(), parts)
9742 }
9743 #[doc = "[Search Shards API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-shards.html)\n\nReturns information about the indices and shards that a search request would be executed against."]
9744 pub fn search_shards<'a, 'b>(
9745 &'a self,
9746 parts: SearchShardsParts<'b>,
9747 ) -> SearchShards<'a, 'b, ()> {
9748 SearchShards::new(self.transport(), parts)
9749 }
9750 #[doc = "[Search Template API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-template.html)\n\nAllows to use the Mustache language to pre-render a search definition."]
9751 pub fn search_template<'a, 'b>(
9752 &'a self,
9753 parts: SearchTemplateParts<'b>,
9754 ) -> SearchTemplate<'a, 'b, ()> {
9755 SearchTemplate::new(self.transport(), parts)
9756 }
9757 #[doc = "[Terms Enum API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/search-terms-enum.html)\n\nThe terms enum API can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios."]
9758 pub fn terms_enum<'a, 'b>(&'a self, parts: TermsEnumParts<'b>) -> TermsEnum<'a, 'b, ()> {
9759 TermsEnum::new(self.transport(), parts)
9760 }
9761 #[doc = "[Termvectors API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-termvectors.html)\n\nReturns information and statistics about terms in the fields of a particular document."]
9762 pub fn termvectors<'a, 'b>(&'a self, parts: TermvectorsParts<'b>) -> Termvectors<'a, 'b, ()> {
9763 Termvectors::new(self.transport(), parts)
9764 }
9765 #[doc = "[Update API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-update.html)\n\nUpdates a document with a script or partial document."]
9766 pub fn update<'a, 'b>(&'a self, parts: UpdateParts<'b>) -> Update<'a, 'b, ()> {
9767 Update::new(self.transport(), parts)
9768 }
9769 #[doc = "[Update By Query API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-update-by-query.html)\n\nPerforms an update on every document in the index without changing the source,\nfor example to pick up a mapping change."]
9770 pub fn update_by_query<'a, 'b>(
9771 &'a self,
9772 parts: UpdateByQueryParts<'b>,
9773 ) -> UpdateByQuery<'a, 'b, ()> {
9774 UpdateByQuery::new(self.transport(), parts)
9775 }
9776 #[doc = "[Update By Query Rethrottle API](https://www.elastic.co/guide/en/elasticsearch/reference/9.0/docs-update-by-query.html)\n\nChanges the number of requests per second for a particular Update By Query operation."]
9777 pub fn update_by_query_rethrottle<'a, 'b>(
9778 &'a self,
9779 parts: UpdateByQueryRethrottleParts<'b>,
9780 ) -> UpdateByQueryRethrottle<'a, 'b, ()> {
9781 UpdateByQueryRethrottle::new(self.transport(), parts)
9782 }
9783}
9784
9785mod bulk;
9786pub use bulk::*;