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