opensearch-client 0.3.1

Strongly typed OpenSearch Client
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
/*
 * opensearch-client
 *
 * Rust Client for OpenSearch
 *
 * The version of the OpenAPI document: 3.1.0
 * Contact: alberto.paro@gmail.com
 * Generated by Paro OpenAPI Generator
 */
use bon::bon;

use reqwest;
use std::sync::Arc;
use serde::{Deserialize, Serialize, de::Error as OtherError};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration};
use crate::apis::ContentType;
use crate::*;


#[async_trait]
pub trait KnnApi: Send + Sync {


    /// GET /_plugins/_knn/{node_id}/stats/{stat}///
    /// Provides information about the current status of the k-NN plugin.
    async fn stats(&self, params: StatsParams) -> Result<crate::knn::Stats, Error>;

    /// GET /_plugins/_knn/models/{model_id}///
    /// Used to retrieve information about models present in the cluster.
    async fn get_model(&self, params: GetModelParams) -> Result<crate::knn::GetModelResponse, Error>;

    /// POST /_plugins/_knn/models/{model_id}/_train///
    /// Create and train a model that can be used for initializing k-NN native library indexes during indexing.
    async fn train_model(&self, params: TrainModelParams) -> Result<crate::knn::TrainModelResponse, Error>;

    /// DELETE /_plugins/_knn/models/{model_id}///
    /// Used to delete a particular model in the cluster.
    async fn delete_model(&self, params: DeleteModelParams) -> Result<crate::knn::DeletedModel, Error>;

    /// GET /_plugins/_knn/warmup/{index}///
    /// Preloads native library files into memory, reducing initial search latency for specified indexes.
    async fn warmup(&self, params: WarmupParams) -> Result<crate::common::ShardsOperationResponseBase, Error>;

    /// POST /_plugins/_knn/models/_search///
    /// Use an OpenSearch query to search for models in the index.
    async fn search_models(&self, params: SearchModelsParams) -> Result<crate::core::search::ResponseBody, Error>;
}

pub struct KnnApiClient {
    configuration: Arc<crate::Configuration>
}

impl KnnApiClient {
    pub fn new(configuration: Arc<crate::Configuration>) -> Self {
        Self { configuration }
    }
}


/// Struct for passing parameters to the method [`stats`]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct StatsParams {
      /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
  /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
    pub timeout: Option<String>,
      /// No description available
    pub error_trace: Option<bool>,
      /// No description available
    pub filter_path: Option<common::FilterPath>,
      /// No description available
    pub human: Option<bool>,
      /// No description available
    pub node_id: String,
      /// No description available
    pub pretty: Option<bool>,
      /// No description available
    pub source: Option<String>,
      /// No description available
    pub stat: String,
}
/// Struct for passing parameters to the method [`get_model`]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct GetModelParams {
      /// No description available
    pub error_trace: Option<bool>,
      /// No description available
    pub filter_path: Option<common::FilterPath>,
      /// No description available
    pub human: Option<bool>,
      /// No description available
    pub model_id: String,
      /// No description available
    pub pretty: Option<bool>,
      /// No description available
    pub source: Option<String>,
}
/// Struct for passing parameters to the method [`train_model`]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct TrainModelParams {
    
    pub train_model: knn::TrainModel,
      /// No description available
    pub error_trace: Option<bool>,
      /// No description available
    pub filter_path: Option<common::FilterPath>,
      /// No description available
    pub human: Option<bool>,
      /// No description available
    pub model_id: String,
      /// No description available
    pub pretty: Option<bool>,
      /// No description available
    pub source: Option<String>,
      /// Preferred node to execute training.
    pub preference: Option<String>,
}
/// Struct for passing parameters to the method [`delete_model`]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct DeleteModelParams {
      /// No description available
    pub error_trace: Option<bool>,
      /// No description available
    pub filter_path: Option<common::FilterPath>,
      /// No description available
    pub human: Option<bool>,
      /// No description available
    pub model_id: String,
      /// No description available
    pub pretty: Option<bool>,
      /// No description available
    pub source: Option<String>,
}
/// Struct for passing parameters to the method [`warmup`]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct WarmupParams {
      /// No description available
    pub error_trace: Option<bool>,
      /// No description available
    pub filter_path: Option<common::FilterPath>,
      /// No description available
    pub human: Option<bool>,
      /// No description available
    pub index: String,
      /// No description available
    pub pretty: Option<bool>,
      /// No description available
    pub source: Option<String>,
}
/// Struct for passing parameters to the method [`search_models`]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "bon", derive(::bon::Builder))]
pub struct SearchModelsParams {
    
    pub search_models: knn::SearchModels,
      /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
  /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
    pub scroll: Option<String>,
      /// A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and
  /// `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value.
    pub timeout: Option<String>,
      /// How many suggestions to return in response.
    pub suggest_size: Option<i32>,
      /// Indicate if an error should be returned if there is a partial search failure or timeout.
    pub allow_partial_search_results: Option<bool>,
      /// Indicate if the number of documents that match the query should be tracked.
    pub track_total_hits: Option<bool>,
      /// Indicates whether `hits.total` should be rendered as an integer or an object in the rest search response.
    pub rest_total_hits_as_int: Option<bool>,
      /// Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.
    pub ccs_minimize_roundtrips: Option<bool>,
      /// No description available
    pub source_excludes: Option<Vec<String>>,
      /// No description available
    pub source_includes: Option<Vec<String>>,
      /// No description available
    pub docvalue_fields: Option<Vec<String>>,
      /// No description available
    pub error_trace: Option<bool>,
      /// No description available
    pub filter_path: Option<common::FilterPath>,
      /// No description available
    pub human: Option<bool>,
      /// No description available
    pub pretty: Option<bool>,
      /// No description available
    pub routing: Option<common::Routing>,
      /// No description available
    pub sort: Option<Vec<String>>,
      /// No description available
    pub source: Option<String>,
      /// No description available
    pub stats: Option<Vec<String>>,
      /// No description available
    pub stored_fields: Option<Vec<String>>,
      /// Number of hits to return.
    pub size: Option<i32>,
      /// Query in the Lucene query string syntax.
    pub q: Option<String>,
      /// Search operation type.
    pub search_type: Option<String>,
      /// Specifies the type of index that wildcard expressions can match. Supports comma-separated values.
    pub expand_wildcards: Option<common::ExpandWildcards>,
      /// Specify if request cache should be used for this request or not, defaults to index level setting.
    pub request_cache: Option<bool>,
      /// Specify suggest mode.
    pub suggest_mode: Option<String>,
      /// Specify the node or shard the operation should be performed on.
    pub preference: Option<String>,
      /// Specify whether aggregation and suggester names should be prefixed by their respective types in the response.
    pub typed_keys: Option<bool>,
      /// Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.
    pub lenient: Option<bool>,
      /// Specify whether to return detailed information about score computation as part of a hit.
    pub explain: Option<bool>,
      /// Specify whether to return sequence number and primary term of the last modification of each hit.
    pub seq_no_primary_term: Option<bool>,
      /// Specify whether wildcard and prefix queries should be analyzed.
    pub analyze_wildcard: Option<bool>,
      /// Specify which field to use for suggestions.
    pub suggest_field: Option<String>,
      /// Starting offset.
    pub from: Option<i32>,
      /// The analyzer to use for the query string.
    pub analyzer: Option<String>,
      /// The default operator for query string query (AND or OR).
    pub default_operator: Option<String>,
      /// The field to use as default where no field prefix is given in the query string.
    pub df: Option<String>,
      /// The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
    pub terminate_after: Option<i32>,
      /// 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.
    pub max_concurrent_shard_requests: Option<i32>,
      /// 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.
    pub batched_reduce_size: Option<i32>,
      /// The source text for which the suggestions should be returned.
    pub suggest_text: Option<String>,
      /// Threshold that enforces a pre-filter round-trip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter round-trip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method, that is if date filters are mandatory to match but the shard bounds and the query are disjoint.
    pub pre_filter_shard_size: Option<i32>,
      /// Whether specified concrete indexes should be ignored when unavailable (missing or closed).
    pub ignore_unavailable: Option<bool>,
      /// Whether specified concrete, expanded or aliased indexes should be ignored when throttled.
    pub ignore_throttled: Option<bool>,
      /// Whether to calculate and return scores even if they are not used for sorting.
    pub track_scores: Option<bool>,
      /// Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified).
    pub allow_no_indices: Option<bool>,
      /// Whether to return document version as part of a hit.
    pub version: Option<bool>,
}

#[async_trait]
impl KnnApi for KnnApiClient {
///
      /// Provides information about the current status of the k-NN plugin.
    async fn stats(&self, params: StatsParams) -> Result<crate::knn::Stats, Error> {
        let StatsParams {
            timeout,
            error_trace,
            filter_path,
            human,
            node_id,
            pretty,
            source,
            stat,
        } = params;
    
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!("{}_plugins/_knn/{node_id}/stats/{stat}", local_var_configuration.base_path, node_id=node_id, stat=stat);
        let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());


    if let Some(ref local_var_str) = timeout {
        local_var_req_builder = local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = error_trace {
        local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = filter_path {
        local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = pretty {
        local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = source {
        local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = human {
        local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
    }







        let local_var_req = local_var_req_builder.build()?;
        let local_var_resp = local_var_client.execute(local_var_req).await?;

        let local_var_status = local_var_resp.status();
        let local_var_content = local_var_resp.text().await?;

        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
            
            serde_json::from_str(&local_var_content).map_err(Error::from)
            
            
        } else {
            let local_var_error = ResponseContent {
                status: local_var_status,
                content: local_var_content,
            };
            Err(Error::ApiError(local_var_error))
        }
    }///
      /// Used to retrieve information about models present in the cluster.
    async fn get_model(&self, params: GetModelParams) -> Result<crate::knn::GetModelResponse, Error> {
        let GetModelParams {
            error_trace,
            filter_path,
            human,
            model_id,
            pretty,
            source,
        } = params;
    
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!("{}_plugins/_knn/models/{model_id}", local_var_configuration.base_path, model_id=model_id);
        let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());


    if let Some(ref local_var_str) = pretty {
        local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = human {
        local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = error_trace {
        local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = source {
        local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = filter_path {
        local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
    }







        let local_var_req = local_var_req_builder.build()?;
        let local_var_resp = local_var_client.execute(local_var_req).await?;

        let local_var_status = local_var_resp.status();
        let local_var_content = local_var_resp.text().await?;

        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
            
            serde_json::from_str(&local_var_content).map_err(Error::from)
            
            
        } else {
            let local_var_error = ResponseContent {
                status: local_var_status,
                content: local_var_content,
            };
            Err(Error::ApiError(local_var_error))
        }
    }///
      /// Create and train a model that can be used for initializing k-NN native library indexes during indexing.
    async fn train_model(&self, params: TrainModelParams) -> Result<crate::knn::TrainModelResponse, Error> {
        let TrainModelParams {
            train_model,
            error_trace,
            filter_path,
            human,
            model_id,
            pretty,
            source,
            preference,
        } = params;
    
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!("{}_plugins/_knn/models/{model_id}/_train", local_var_configuration.base_path, model_id=model_id);
        let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());


    if let Some(ref local_var_str) = preference {
        local_var_req_builder = local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = error_trace {
        local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = human {
        local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = filter_path {
        local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = pretty {
        local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = source {
        local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
    }






    local_var_req_builder = local_var_req_builder.json(&train_model);

        let local_var_req = local_var_req_builder.build()?;
        let local_var_resp = local_var_client.execute(local_var_req).await?;

        let local_var_status = local_var_resp.status();
        let local_var_content = local_var_resp.text().await?;

        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
            
            serde_json::from_str(&local_var_content).map_err(Error::from)
            
            
        } else {
            let local_var_error = ResponseContent {
                status: local_var_status,
                content: local_var_content,
            };
            Err(Error::ApiError(local_var_error))
        }
    }///
      /// Used to delete a particular model in the cluster.
    async fn delete_model(&self, params: DeleteModelParams) -> Result<crate::knn::DeletedModel, Error> {
        let DeleteModelParams {
            error_trace,
            filter_path,
            human,
            model_id,
            pretty,
            source,
        } = params;
    
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!("{}_plugins/_knn/models/{model_id}", local_var_configuration.base_path, model_id=model_id);
        let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());


    if let Some(ref local_var_str) = pretty {
        local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = error_trace {
        local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = human {
        local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = source {
        local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = filter_path {
        local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
    }







        let local_var_req = local_var_req_builder.build()?;
        let local_var_resp = local_var_client.execute(local_var_req).await?;

        let local_var_status = local_var_resp.status();
        let local_var_content = local_var_resp.text().await?;

        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
            
            serde_json::from_str(&local_var_content).map_err(Error::from)
            
            
        } else {
            let local_var_error = ResponseContent {
                status: local_var_status,
                content: local_var_content,
            };
            Err(Error::ApiError(local_var_error))
        }
    }///
      /// Preloads native library files into memory, reducing initial search latency for specified indexes.
    async fn warmup(&self, params: WarmupParams) -> Result<crate::common::ShardsOperationResponseBase, Error> {
        let WarmupParams {
            error_trace,
            filter_path,
            human,
            index,
            pretty,
            source,
        } = params;
    
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!("{}_plugins/_knn/warmup/{index}", local_var_configuration.base_path, index=index);
        let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());


    if let Some(ref local_var_str) = pretty {
        local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = filter_path {
        local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = error_trace {
        local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = human {
        local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = source {
        local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
    }







        let local_var_req = local_var_req_builder.build()?;
        let local_var_resp = local_var_client.execute(local_var_req).await?;

        let local_var_status = local_var_resp.status();
        let local_var_content = local_var_resp.text().await?;

        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
            
            serde_json::from_str(&local_var_content).map_err(Error::from)
            
            
        } else {
            let local_var_error = ResponseContent {
                status: local_var_status,
                content: local_var_content,
            };
            Err(Error::ApiError(local_var_error))
        }
    }///
      /// Use an OpenSearch query to search for models in the index.
    async fn search_models(&self, params: SearchModelsParams) -> Result<crate::core::search::ResponseBody, Error> {
        let SearchModelsParams {
            search_models,
            scroll,
            timeout,
            suggest_size,
            allow_partial_search_results,
            track_total_hits,
            rest_total_hits_as_int,
            ccs_minimize_roundtrips,
            source_excludes,
            source_includes,
            docvalue_fields,
            error_trace,
            filter_path,
            human,
            pretty,
            routing,
            sort,
            source,
            stats,
            stored_fields,
            size,
            q,
            search_type,
            expand_wildcards,
            request_cache,
            suggest_mode,
            preference,
            typed_keys,
            lenient,
            explain,
            seq_no_primary_term,
            analyze_wildcard,
            suggest_field,
            from,
            analyzer,
            default_operator,
            df,
            terminate_after,
            max_concurrent_shard_requests,
            batched_reduce_size,
            suggest_text,
            pre_filter_shard_size,
            ignore_unavailable,
            ignore_throttled,
            track_scores,
            allow_no_indices,
            version,
        } = params;
    
        let local_var_configuration = &self.configuration;

        let local_var_client = &local_var_configuration.client;

        let local_var_uri_str = format!("{}_plugins/_knn/models/_search", local_var_configuration.base_path);
        let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());


    if let Some(ref local_var_str) = pre_filter_shard_size {
        local_var_req_builder = local_var_req_builder.query(&[("pre_filter_shard_size", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = timeout {
        local_var_req_builder = local_var_req_builder.query(&[("timeout", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = stats {
        local_var_req_builder = match "multi" {
            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("stats".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
            _ => local_var_req_builder.query(&[("stats", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
        };
    }
    if let Some(ref local_var_str) = human {
        local_var_req_builder = local_var_req_builder.query(&[("human", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = ignore_throttled {
        local_var_req_builder = local_var_req_builder.query(&[("ignore_throttled", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = analyzer {
        local_var_req_builder = local_var_req_builder.query(&[("analyzer", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = allow_no_indices {
        local_var_req_builder = local_var_req_builder.query(&[("allow_no_indices", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = preference {
        local_var_req_builder = local_var_req_builder.query(&[("preference", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = seq_no_primary_term {
        local_var_req_builder = local_var_req_builder.query(&[("seq_no_primary_term", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = error_trace {
        local_var_req_builder = local_var_req_builder.query(&[("error_trace", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = track_scores {
        local_var_req_builder = local_var_req_builder.query(&[("track_scores", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = allow_partial_search_results {
        local_var_req_builder = local_var_req_builder.query(&[("allow_partial_search_results", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = filter_path {
        local_var_req_builder = local_var_req_builder.query(&[("filter_path", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = batched_reduce_size {
        local_var_req_builder = local_var_req_builder.query(&[("batched_reduce_size", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = ccs_minimize_roundtrips {
        local_var_req_builder = local_var_req_builder.query(&[("ccs_minimize_roundtrips", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = routing {
        local_var_req_builder = local_var_req_builder.query(&[("routing", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = docvalue_fields {
        local_var_req_builder = match "multi" {
            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("docvalue_fields".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
            _ => local_var_req_builder.query(&[("docvalue_fields", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
        };
    }
    if let Some(ref local_var_str) = suggest_size {
        local_var_req_builder = local_var_req_builder.query(&[("suggest_size", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = search_type {
        local_var_req_builder = local_var_req_builder.query(&[("search_type", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = suggest_text {
        local_var_req_builder = local_var_req_builder.query(&[("suggest_text", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = suggest_field {
        local_var_req_builder = local_var_req_builder.query(&[("suggest_field", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = source_includes {
        local_var_req_builder = match "multi" {
            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("source_includes".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
            _ => local_var_req_builder.query(&[("source_includes", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
        };
    }
    if let Some(ref local_var_str) = terminate_after {
        local_var_req_builder = local_var_req_builder.query(&[("terminate_after", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = typed_keys {
        local_var_req_builder = local_var_req_builder.query(&[("typed_keys", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = max_concurrent_shard_requests {
        local_var_req_builder = local_var_req_builder.query(&[("max_concurrent_shard_requests", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = analyze_wildcard {
        local_var_req_builder = local_var_req_builder.query(&[("analyze_wildcard", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = stored_fields {
        local_var_req_builder = match "multi" {
            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("stored_fields".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
            _ => local_var_req_builder.query(&[("stored_fields", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
        };
    }
    if let Some(ref local_var_str) = ignore_unavailable {
        local_var_req_builder = local_var_req_builder.query(&[("ignore_unavailable", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = pretty {
        local_var_req_builder = local_var_req_builder.query(&[("pretty", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = source_excludes {
        local_var_req_builder = match "multi" {
            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("source_excludes".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
            _ => local_var_req_builder.query(&[("source_excludes", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
        };
    }
    if let Some(ref local_var_str) = request_cache {
        local_var_req_builder = local_var_req_builder.query(&[("request_cache", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = scroll {
        local_var_req_builder = local_var_req_builder.query(&[("scroll", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = explain {
        local_var_req_builder = local_var_req_builder.query(&[("explain", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = default_operator {
        local_var_req_builder = local_var_req_builder.query(&[("default_operator", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = sort {
        local_var_req_builder = match "multi" {
            "multi" => local_var_req_builder.query(&local_var_str.into_iter().map(|p| ("sort".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
            _ => local_var_req_builder.query(&[("sort", &local_var_str.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
        };
    }
    if let Some(ref local_var_str) = rest_total_hits_as_int {
        local_var_req_builder = local_var_req_builder.query(&[("rest_total_hits_as_int", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = expand_wildcards {
        local_var_req_builder = local_var_req_builder.query(&[("expand_wildcards", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = size {
        local_var_req_builder = local_var_req_builder.query(&[("size", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = suggest_mode {
        local_var_req_builder = local_var_req_builder.query(&[("suggest_mode", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = version {
        local_var_req_builder = local_var_req_builder.query(&[("version", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = source {
        local_var_req_builder = local_var_req_builder.query(&[("source", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = q {
        local_var_req_builder = local_var_req_builder.query(&[("q", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = from {
        local_var_req_builder = local_var_req_builder.query(&[("from", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = track_total_hits {
        local_var_req_builder = local_var_req_builder.query(&[("track_total_hits", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = df {
        local_var_req_builder = local_var_req_builder.query(&[("df", &local_var_str.to_string())]);
    }
    if let Some(ref local_var_str) = lenient {
        local_var_req_builder = local_var_req_builder.query(&[("lenient", &local_var_str.to_string())]);
    }






    local_var_req_builder = local_var_req_builder.json(&search_models);

        let local_var_req = local_var_req_builder.build()?;
        let local_var_resp = local_var_client.execute(local_var_req).await?;

        let local_var_status = local_var_resp.status();
        let local_var_content = local_var_resp.text().await?;

        if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
            
            serde_json::from_str(&local_var_content).map_err(Error::from)
            
            
        } else {
            let local_var_error = ResponseContent {
                status: local_var_status,
                content: local_var_content,
            };
            Err(Error::ApiError(local_var_error))
        }
    }
}