-
Notifications
You must be signed in to change notification settings - Fork 968
Expand file tree
/
Copy pathClientEndpointsTrait.php
More file actions
2148 lines (2034 loc) · 155 KB
/
Copy pathClientEndpointsTrait.php
File metadata and controls
2148 lines (2034 loc) · 155 KB
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
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Elasticsearch PHP Client
*
* @link https://github.com/elastic/elasticsearch-php
* @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
* @license https://opensource.org/licenses/MIT MIT License
*
* Licensed to Elasticsearch B.V under one or more agreements.
* Elasticsearch B.V licenses this file to you under the MIT License.
* See the LICENSE file in the project root for more information.
*/
declare(strict_types=1);
namespace Elastic\Elasticsearch\Traits;
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\MissingParameterException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Elastic\Transport\Exception\NoNodeAvailableException;
use Http\Promise\Promise;
/**
* @generated This file is generated, please do not edit
*/
trait ClientEndpointsTrait
{
/**
* Bulk index or delete documents
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-bulk
* @group serverless
*
* @param array{
* index?: string, // Default index for items which don't provide one
* wait_for_active_shards?: string, // The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). The default is `1`, which waits for each primary shard to be active. (DEFAULT: 1)
* refresh?: string, // If `true`, Elasticsearch refreshes the affected shards to make this operation visible to search. If `wait_for`, wait for a refresh to make this operation visible to search. If `false`, do nothing with refreshes. Valid values: `true`, `false`, `wait_for`. (DEFAULT: false)
* routing?: string|array<string>, // A custom value that is used to route operations to a specific shard.
* timeout?: int|string, // The period each action waits for the following operations: automatic index creation, dynamic mapping updates, and waiting for active shards. The default is `1m` (one minute), which guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur. (DEFAULT: 1m)
* _source?: string|array<string>, // Indicates whether to return the `_source` field (`true` or `false`) or contains a list of fields to return.
* _source_excludes?: string|array<string>, // A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter. If the `_source` parameter is `false`, this parameter is ignored.
* _source_includes?: string|array<string>, // A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the `_source_excludes` query parameter. If the `_source` parameter is `false`, this parameter is ignored.
* pipeline?: string, // The pipeline identifier to use to preprocess incoming documents. If the index has a default ingest pipeline specified, setting the value to `_none` turns off the default ingest pipeline for this request. If a final pipeline is configured, it will always run regardless of the value of this parameter.
* require_alias?: bool, // If `true`, the request's actions must target an index alias.
* require_data_stream?: bool, // If `true`, the request's actions must target a data stream (existing or to be created).
* list_executed_pipelines?: bool, // If `true`, the response will include the ingest pipelines that were run for each index or create.
* include_source_on_error?: bool, // True or false if to include the document source in the error message in case of parsing errors. (DEFAULT: 1)
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* body: string|array<mixed>, // (REQUIRED) The operation definition and data (action-data pairs), separated by newlines. If body is a string must be a valid JSON.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function bulk(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['body'], $params);
if (isset($params['index'])) {
$url = '/' . $this->encode($params['index']) . '/_bulk';
$method = 'POST';
} else {
$url = '/_bulk';
$method = 'POST';
}
$url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','_source','_source_excludes','_source_includes','pipeline','require_alias','require_data_stream','list_executed_pipelines','include_source_on_error','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/x-ndjson',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['index'], $request, 'bulk');
return $this->sendRequest($request);
}
/**
* Clear a scrolling search
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-clear-scroll
* @group serverless
*
* @param array{
* scroll_id?: string|array<string>, // A comma-separated list of scroll IDs to clear
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* body?: string|array<mixed>, // A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter. If body is a string must be a valid JSON.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function clearScroll(?array $params = null)
{
$params = $params ?? [];
if (isset($params['scroll_id'])) {
$url = '/_search/scroll/' . $this->encode($this->convertValue($params['scroll_id']));
$method = 'DELETE';
} else {
$url = '/_search/scroll';
$method = 'DELETE';
}
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['scroll_id'], $request, 'clear_scroll');
return $this->sendRequest($request);
}
/**
* Close a point in time
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-open-point-in-time
* @group serverless
*
* @param array{
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* body: string|array<mixed>, // (REQUIRED) a point-in-time id to close. If body is a string must be a valid JSON.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function closePointInTime(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['body'], $params);
$url = '/_pit';
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, [], $request, 'close_point_in_time');
return $this->sendRequest($request);
}
/**
* Count search results
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-count
* @group serverless
*
* @param array{
* index?: string|array<string>, // A comma-separated list of indices to restrict the results
* ignore_unavailable?: bool, // If `false`, the request returns an error if it targets a concrete (non-wildcarded) index, alias, or data stream that is missing, closed, or otherwise unavailable. If `true`, unavailable concrete targets are silently ignored.
* ignore_throttled?: bool, // If `true`, concrete, expanded, or aliased indices are ignored when frozen. (DEFAULT: 1)
* allow_no_indices?: bool, // A setting that does two separate checks on the index expression. If `false`, the request returns an error (1) if any wildcard expression (including `_all` and `*`) resolves to zero matching indices or (2) if the complete set of resolved indices, aliases or data streams is empty after all expressions are evaluated. If `true`, index expressions that resolve to no indices are allowed and the request returns an empty result. (DEFAULT: 1)
* expand_wildcards?: string|array<string>, // The type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. It supports comma-separated values, such as `open,hidden`. (DEFAULT: open)
* min_score?: float, // The minimum `_score` value that documents must have to be included in the result.
* preference?: string, // The node or shard the operation should be performed on. By default, it is random.
* routing?: string|array<string>, // A custom value used to route operations to a specific shard.
* q?: string, // The query in Lucene query string syntax. This parameter cannot be used with a request body.
* analyzer?: string, // The analyzer to use for the query string. This parameter can be used only when the `q` query string parameter is specified.
* analyze_wildcard?: bool, // If `true`, wildcard and prefix queries are analyzed. This parameter can be used only when the `q` query string parameter is specified.
* default_operator?: string, // The default operator for query string query: `and` or `or`. This parameter can be used only when the `q` query string parameter is specified. (DEFAULT: or)
* df?: string, // The field to use as a default when no field prefix is given in the query string. This parameter can be used only when the `q` query string parameter is specified.
* lenient?: bool, // If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. This parameter can be used only when the `q` query string parameter is specified.
* terminate_after?: int, // The maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting. IMPORTANT: Use with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* body?: string|array<mixed>, // A query to restrict the results specified with the Query DSL (optional). If body is a string must be a valid JSON.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function count(?array $params = null)
{
$params = $params ?? [];
if (isset($params['index'])) {
$url = '/' . $this->encode($this->convertValue($params['index'])) . '/_count';
$method = empty($params['body']) ? 'GET' : 'POST';
} else {
$url = '/_count';
$method = empty($params['body']) ? 'GET' : 'POST';
}
$url = $this->addQueryString($url, $params, ['ignore_unavailable','ignore_throttled','allow_no_indices','expand_wildcards','min_score','preference','routing','q','analyzer','analyze_wildcard','default_operator','df','lenient','terminate_after','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['index'], $request, 'count');
return $this->sendRequest($request);
}
/**
* Create a new document in the index
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-create
* @group serverless
*
* @param array{
* id: string, // (REQUIRED) Document ID
* index: string, // (REQUIRED) The name of the index
* wait_for_active_shards?: string, // The number of shard copies that must be active before proceeding with the operation. You can set it to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). The default value of `1` means it waits for each primary shard to be active. (DEFAULT: 1)
* refresh?: string, // If `true`, Elasticsearch refreshes the affected shards to make this operation visible to search. If `wait_for`, it waits for a refresh to make this operation visible to search. If `false`, it does nothing with refreshes. (DEFAULT: false)
* routing?: string|array<string>, // A custom value that is used to route operations to a specific shard.
* timeout?: int|string, // The period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. Elasticsearch waits for at least the specified timeout period before failing. The actual wait time could be longer, particularly when multiple waits occur. This parameter is useful for situations where the primary shard assigned to perform the operation might not be available when the operation runs. Some reasons for this might be that the primary shard is currently recovering from a gateway or undergoing relocation. By default, the operation will wait on the primary shard to become available for at least 1 minute before failing and responding with an error. The actual wait time could be longer, particularly when multiple waits occur. (DEFAULT: 1m)
* version?: int, // The explicit version number for concurrency control. It must be a non-negative long number.
* version_type?: string, // The version type.
* pipeline?: string, // The ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, setting the value to `_none` turns off the default ingest pipeline for this request. If a final pipeline is configured, it will always run regardless of the value of this parameter.
* include_source_on_error?: bool, // True or false if to include the document source in the error message in case of parsing errors. (DEFAULT: 1)
* require_alias?: bool, // If `true`, the destination must be an index alias.
* require_data_stream?: bool, // If `true`, the request's actions must target a data stream (existing or to be created).
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* body: string|array<mixed>, // (REQUIRED) The document. If body is a string must be a valid JSON.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function create(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['id','index','body'], $params);
$url = '/' . $this->encode($params['index']) . '/_create/' . $this->encode($params['id']);
$method = 'PUT';
$url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','version','version_type','pipeline','include_source_on_error','require_alias','require_data_stream','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'create');
return $this->sendRequest($request);
}
/**
* Delete a document
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete
* @group serverless
*
* @param array{
* id: string, // (REQUIRED) The document ID
* index: string, // (REQUIRED) The name of the index
* wait_for_active_shards?: string, // The minimum number of shard copies that must be active before proceeding with the operation. You can set it to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). The default value of `1` means it waits for each primary shard to be active. (DEFAULT: 1)
* refresh?: string, // If `true`, Elasticsearch refreshes the affected shards to make this operation visible to search. If `wait_for`, it waits for a refresh to make this operation visible to search. If `false`, it does nothing with refreshes. (DEFAULT: false)
* routing?: string|array<string>, // A custom value used to route operations to a specific shard.
* timeout?: int|string, // The period to wait for active shards. This parameter is useful for situations where the primary shard assigned to perform the delete operation might not be available when the delete operation runs. Some reasons for this might be that the primary shard is currently recovering from a store or undergoing relocation. By default, the delete operation will wait on the primary shard to become available for up to 1 minute before failing and responding with an error. (DEFAULT: 1m)
* if_seq_no?: int, // Only perform the operation if the document has this sequence number.
* if_primary_term?: int, // Only perform the operation if the document has this primary term.
* version?: int, // An explicit version number for concurrency control. It must match the current version of the document for the request to succeed.
* version_type?: string, // The version type.
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function delete(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['id','index'], $params);
$url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['wait_for_active_shards','refresh','routing','timeout','if_seq_no','if_primary_term','version','version_type','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'delete');
return $this->sendRequest($request);
}
/**
* Delete documents
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete-by-query
* @group serverless
*
* @param array{
* index: string|array<string>, // (REQUIRED) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
* analyzer?: string, // Analyzer to use for the query string. This parameter can be used only when the `q` query string parameter is specified.
* analyze_wildcard?: bool, // If `true`, wildcard and prefix queries are analyzed. This parameter can be used only when the `q` query string parameter is specified.
* default_operator?: string, // The default operator for query string query: `and` or `or`. This parameter can be used only when the `q` query string parameter is specified. (DEFAULT: or)
* df?: string, // The field to use as default where no field prefix is given in the query string. This parameter can be used only when the `q` query string parameter is specified.
* from?: int, // Skips the specified number of documents.
* ignore_unavailable?: bool, // If `false`, the request returns an error if it targets a concrete (non-wildcarded) index, alias, or data stream that is missing, closed, or otherwise unavailable. If `true`, unavailable concrete targets are silently ignored.
* allow_no_indices?: bool, // A setting that does two separate checks on the index expression. If `false`, the request returns an error (1) if any wildcard expression (including `_all` and `*`) resolves to zero matching indices or (2) if the complete set of resolved indices, aliases or data streams is empty after all expressions are evaluated. If `true`, index expressions that resolve to no indices are allowed and the request returns an empty result. (DEFAULT: 1)
* conflicts?: string, // What to do if delete by query hits version conflicts: `abort` or `proceed`. (DEFAULT: abort)
* expand_wildcards?: string|array<string>, // The type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. It supports comma-separated values, such as `open,hidden`. (DEFAULT: open)
* lenient?: bool, // If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. This parameter can be used only when the `q` query string parameter is specified.
* preference?: string, // The node or shard the operation should be performed on. It is random by default.
* q?: string, // A query in the Lucene query string syntax.
* routing?: string|array<string>, // A custom value used to route operations to a specific shard.
* scroll?: int|string, // The period to retain the search context for scrolling.
* search_type?: string, // The type of the search operation. Available options include `query_then_fetch` and `dfs_query_then_fetch`.
* search_timeout?: int|string, // The explicit timeout for each search request. It defaults to no timeout.
* max_docs?: int, // The maximum number of documents to process. Defaults to all documents. When set to a value less then or equal to `scroll_size`, a scroll will not be used to retrieve the results for the operation.
* sort?: string|array<string>, // A comma-separated list of `<field>:<direction>` pairs.
* terminate_after?: int, // The maximum number of documents to collect for each shard. If a query reaches this limit, Elasticsearch terminates the query early. Elasticsearch collects documents before sorting. Use with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.
* stats?: string|array<string>, // The specific `tag` of the request for logging and statistical purposes.
* version?: bool, // If `true`, returns the document version as part of a hit.
* request_cache?: bool, // If `true`, the request cache is used for this request. Defaults to the index-level setting.
* refresh?: bool, // If `true`, Elasticsearch refreshes all shards involved in the delete by query after the request completes. This is different than the delete API's `refresh` parameter, which causes just the shard that received the delete request to be refreshed. Unlike the delete API, it does not support `wait_for`.
* timeout?: int|string, // The period each deletion request waits for active shards. (DEFAULT: 1m)
* wait_for_active_shards?: string, // The number of shard copies that must be active before proceeding with the operation. Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). The `timeout` value controls how long each write request waits for unavailable shards to become available. (DEFAULT: 1)
* scroll_size?: int, // The size of the scroll request that powers the operation. (DEFAULT: 1000)
* wait_for_completion?: bool, // If `true`, the request blocks until the operation is complete. If `false`, Elasticsearch performs some preflight checks, launches the request, and returns a task you can use to cancel or get the status of the task. Elasticsearch creates a record of this task as a document at `.tasks/task/${taskId}`. When you are done with a task, you should delete the task document so Elasticsearch can reclaim the space. (DEFAULT: 1)
* requests_per_second?: int, // The throttle for this request in sub-requests per second. (DEFAULT: -1)
* slices?: int|string, // The number of slices this task should be divided into. (DEFAULT: 1)
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* body: string|array<mixed>, // (REQUIRED) The search definition using the Query DSL. If body is a string must be a valid JSON.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteByQuery(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['index','body'], $params);
$url = '/' . $this->encode($this->convertValue($params['index'])) . '/_delete_by_query';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['analyzer','analyze_wildcard','default_operator','df','from','ignore_unavailable','allow_no_indices','conflicts','expand_wildcards','lenient','preference','q','routing','scroll','search_type','search_timeout','max_docs','sort','terminate_after','stats','version','request_cache','refresh','timeout','wait_for_active_shards','scroll_size','wait_for_completion','requests_per_second','slices','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['index'], $request, 'delete_by_query');
return $this->sendRequest($request);
}
/**
* Throttle a delete by query operation
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete-by-query-rethrottle
*
* @param array{
* task_id: string, // (REQUIRED) The task id to rethrottle
* requests_per_second?: int, // The throttle for this request in sub-requests per second. To disable throttling, set it to `-1`.
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteByQueryRethrottle(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['task_id','requests_per_second'], $params);
$url = '/_delete_by_query/' . $this->encode($params['task_id']) . '/_rethrottle';
$method = 'POST';
$url = $this->addQueryString($url, $params, ['requests_per_second','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['task_id'], $request, 'delete_by_query_rethrottle');
return $this->sendRequest($request);
}
/**
* Delete a script or search template
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete-script
* @group serverless
*
* @param array{
* id: string, // (REQUIRED) Script ID
* timeout?: int|string, // The period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. It can also be set to `-1` to indicate that the request should never timeout. (DEFAULT: 30s)
* master_timeout?: int|string, // The period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. It can also be set to `-1` to indicate that the request should never timeout. (DEFAULT: 30s)
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function deleteScript(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['id'], $params);
$url = '/_scripts/' . $this->encode($params['id']);
$method = 'DELETE';
$url = $this->addQueryString($url, $params, ['timeout','master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id'], $request, 'delete_script');
return $this->sendRequest($request);
}
/**
* Check a document
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get
* @group serverless
*
* @param array{
* id: string, // (REQUIRED) The document ID
* index: string, // (REQUIRED) The name of the index
* stored_fields?: string|array<string>, // A comma-separated list of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the `_source` parameter defaults to `false`.
* preference?: string, // The node or shard the operation should be performed on. By default, the operation is randomized between the shard replicas. If it is set to `_local`, the operation will prefer to be run on a local allocated shard when possible. If it is set to a custom value, the value is used to guarantee that the same shards will be used for the same custom value. This can help with "jumping values" when hitting different shards in different refresh states. A sample value can be something like the web session ID or the user name.
* realtime?: bool, // If `true`, the request is real-time as opposed to near-real-time. (DEFAULT: 1)
* refresh?: bool, // If `true`, the request refreshes the relevant shards before retrieving the document. Setting it to `true` should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing).
* routing?: string|array<string>, // A custom value used to route operations to a specific shard.
* _source?: string|array<string>, // Indicates whether to return the `_source` field (`true` or `false`) or lists the fields to return.
* _source_excludes?: string|array<string>, // A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter. If the `_source` parameter is `false`, this parameter is ignored.
* _source_includes?: string|array<string>, // A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the `_source_excludes` query parameter. If the `_source` parameter is `false`, this parameter is ignored.
* version?: int, // Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
* version_type?: string, // The version type.
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function exists(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['id','index'], $params);
$url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']);
$method = 'HEAD';
$url = $this->addQueryString($url, $params, ['stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'exists');
return $this->sendRequest($request);
}
/**
* Check for a document source
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get
* @group serverless
*
* @param array{
* id: string, // (REQUIRED) The document ID
* index: string, // (REQUIRED) The name of the index
* preference?: string, // The node or shard the operation should be performed on. By default, the operation is randomized between the shard replicas.
* realtime?: bool, // If `true`, the request is real-time as opposed to near-real-time. (DEFAULT: 1)
* refresh?: bool, // If `true`, the request refreshes the relevant shards before retrieving the document. Setting it to `true` should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing).
* routing?: string|array<string>, // A custom value used to route operations to a specific shard.
* _source?: string|array<string>, // Indicates whether to return the `_source` field (`true` or `false`) or lists the fields to return.
* _source_excludes?: string|array<string>, // A comma-separated list of source fields to exclude in the response.
* _source_includes?: string|array<string>, // A comma-separated list of source fields to include in the response.
* version?: int, // The version number for concurrency control. It must match the current version of the document for the request to succeed.
* version_type?: string, // The version type.
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function existsSource(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['id','index'], $params);
$url = '/' . $this->encode($params['index']) . '/_source/' . $this->encode($params['id']);
$method = 'HEAD';
$url = $this->addQueryString($url, $params, ['preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'exists_source');
return $this->sendRequest($request);
}
/**
* Explain a document match result
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-explain
* @group serverless
*
* @param array{
* id: string, // (REQUIRED) The document ID
* index: string, // (REQUIRED) The name of the index
* analyze_wildcard?: bool, // If `true`, wildcard and prefix queries are analyzed. This parameter can be used only when the `q` query string parameter is specified.
* analyzer?: string, // The analyzer to use for the query string. This parameter can be used only when the `q` query string parameter is specified.
* default_operator?: string, // The default operator for query string query: `and` or `or`. This parameter can be used only when the `q` query string parameter is specified. (DEFAULT: or)
* df?: string, // The field to use as default where no field prefix is given in the query string. This parameter can be used only when the `q` query string parameter is specified.
* stored_fields?: string|array<string>, // A comma-separated list of stored fields to return in the response.
* lenient?: bool, // If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. This parameter can be used only when the `q` query string parameter is specified.
* preference?: string, // The node or shard the operation should be performed on. It is random by default.
* q?: string, // The query in the Lucene query string syntax.
* routing?: string|array<string>, // A custom value used to route operations to a specific shard.
* _source?: string|array<string>, // `True` or `false` to return the `_source` field or not or a list of fields to return.
* _source_excludes?: string|array<string>, // A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter. If the `_source` parameter is `false`, this parameter is ignored.
* _source_includes?: string|array<string>, // A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the `_source_excludes` query parameter. If the `_source` parameter is `false`, this parameter is ignored.
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* body?: string|array<mixed>, // The query definition using the Query DSL. If body is a string must be a valid JSON.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function explain(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['id','index'], $params);
$url = '/' . $this->encode($params['index']) . '/_explain/' . $this->encode($params['id']);
$method = empty($params['body']) ? 'GET' : 'POST';
$url = $this->addQueryString($url, $params, ['analyze_wildcard','analyzer','default_operator','df','stored_fields','lenient','preference','q','routing','_source','_source_excludes','_source_includes','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'explain');
return $this->sendRequest($request);
}
/**
* Get the field capabilities
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-field-caps
* @group serverless
*
* @param array{
* index?: string|array<string>, // A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
* fields?: string|array<string>, // A comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.
* ignore_unavailable?: bool, // If `false`, the request returns an error if it targets a concrete (non-wildcarded) index, alias, or data stream that is missing, closed, or otherwise unavailable. If `true`, unavailable concrete targets are silently ignored.
* allow_no_indices?: bool, // A setting that does two separate checks on the index expression. If `false`, the request returns an error (1) if any wildcard expression (including `_all` and `*`) resolves to zero matching indices or (2) if the complete set of resolved indices, aliases or data streams is empty after all expressions are evaluated. If `true`, index expressions that resolve to no indices are allowed and the request returns an empty result. (DEFAULT: 1)
* expand_wildcards?: string|array<string>, // The type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`. (DEFAULT: open)
* include_unmapped?: bool, // If true, unmapped fields are included in the response.
* filters?: string|array<string>, // A comma-separated list of filters to apply to the response.
* types?: string|array<string>, // A comma-separated list of field types to include. Any fields that do not match one of these types will be excluded from the results. It defaults to empty, meaning that all field types are returned.
* include_empty_fields?: bool, // If false, empty fields are not included in the response. (DEFAULT: 1)
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* body?: string|array<mixed>, // An index filter specified with the Query DSL. If body is a string must be a valid JSON.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function fieldCaps(?array $params = null)
{
$params = $params ?? [];
if (isset($params['index'])) {
$url = '/' . $this->encode($this->convertValue($params['index'])) . '/_field_caps';
$method = empty($params['body']) ? 'GET' : 'POST';
} else {
$url = '/_field_caps';
$method = empty($params['body']) ? 'GET' : 'POST';
}
$url = $this->addQueryString($url, $params, ['fields','ignore_unavailable','allow_no_indices','expand_wildcards','include_unmapped','filters','types','include_empty_fields','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['index'], $request, 'field_caps');
return $this->sendRequest($request);
}
/**
* Get a document by its ID
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get
* @group serverless
*
* @param array{
* id: string, // (REQUIRED) The document ID
* index: string, // (REQUIRED) The name of the index
* force_synthetic_source?: bool, // Indicates whether the request forces synthetic `_source`. Use this parameter to test if the mapping supports synthetic `_source` and to get a sense of the worst case performance. Fetches with this parameter enabled will be slower than enabling synthetic source natively in the index.
* stored_fields?: string|array<string>, // A comma-separated list of stored fields to return as part of a hit. If no fields are specified, no stored fields are included in the response. If this field is specified, the `_source` parameter defaults to `false`. Only leaf fields can be retrieved with the `stored_fields` option. Object fields can't be returned; if specified, the request fails.
* preference?: string, // The node or shard the operation should be performed on. By default, the operation is randomized between the shard replicas. If it is set to `_local`, the operation will prefer to be run on a local allocated shard when possible. If it is set to a custom value, the value is used to guarantee that the same shards will be used for the same custom value. This can help with "jumping values" when hitting different shards in different refresh states. A sample value can be something like the web session ID or the user name.
* realtime?: bool, // If `true`, the request is real-time as opposed to near-real-time. (DEFAULT: 1)
* refresh?: bool, // If `true`, the request refreshes the relevant shards before retrieving the document. Setting it to `true` should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing).
* routing?: string|array<string>, // A custom value used to route operations to a specific shard.
* _source?: string|array<string>, // Indicates whether to return the `_source` field (`true` or `false`) or lists the fields to return.
* _source_excludes?: string|array<string>, // A comma-separated list of source fields to exclude from the response. You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter. If the `_source` parameter is `false`, this parameter is ignored.
* _source_includes?: string|array<string>, // A comma-separated list of source fields to include in the response. If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the `_source_excludes` query parameter. If the `_source` parameter is `false`, this parameter is ignored.
* _source_exclude_vectors?: bool, // Whether vectors should be excluded from _source
* version?: int, // The version number for concurrency control. It must match the current version of the document for the request to succeed.
* version_type?: string, // The version type.
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function get(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['id','index'], $params);
$url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['force_synthetic_source','stored_fields','preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','_source_exclude_vectors','version','version_type','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'get');
return $this->sendRequest($request);
}
/**
* Get a script or search template
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get-script
* @group serverless
*
* @param array{
* id: string, // (REQUIRED) Script ID
* master_timeout?: int|string, // The period to wait for the master node. If the master node is not available before the timeout expires, the request fails and returns an error. It can also be set to `-1` to indicate that the request should never timeout. (DEFAULT: 30s)
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getScript(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['id'], $params);
$url = '/_scripts/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['master_timeout','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id'], $request, 'get_script');
return $this->sendRequest($request);
}
/**
* Get script contexts
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get-script-context
*
* @param array{
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getScriptContext(?array $params = null)
{
$params = $params ?? [];
$url = '/_script_context';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, [], $request, 'get_script_context');
return $this->sendRequest($request);
}
/**
* Get script languages
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get-script-languages
*
* @param array{
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getScriptLanguages(?array $params = null)
{
$params = $params ?? [];
$url = '/_script_language';
$method = 'GET';
$url = $this->addQueryString($url, $params, ['pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, [], $request, 'get_script_languages');
return $this->sendRequest($request);
}
/**
* Get a document's source
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-get
* @group serverless
*
* @param array{
* id: string, // (REQUIRED) The document ID
* index: string, // (REQUIRED) The name of the index
* preference?: string, // The node or shard the operation should be performed on. By default, the operation is randomized between the shard replicas.
* realtime?: bool, // If `true`, the request is real-time as opposed to near-real-time. (DEFAULT: 1)
* refresh?: bool, // If `true`, the request refreshes the relevant shards before retrieving the document. Setting it to `true` should be done after careful thought and verification that this does not cause a heavy load on the system (and slow down indexing).
* routing?: string|array<string>, // A custom value used to route operations to a specific shard.
* _source?: string|array<string>, // Indicates whether to return the `_source` field (`true` or `false`) or lists the fields to return.
* _source_excludes?: string|array<string>, // A comma-separated list of source fields to exclude in the response.
* _source_includes?: string|array<string>, // A comma-separated list of source fields to include in the response.
* version?: int, // The version number for concurrency control. It must match the current version of the document for the request to succeed.
* version_type?: string, // The version type.
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function getSource(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['id','index'], $params);
$url = '/' . $this->encode($params['index']) . '/_source/' . $this->encode($params['id']);
$method = 'GET';
$url = $this->addQueryString($url, $params, ['preference','realtime','refresh','routing','_source','_source_excludes','_source_includes','version','version_type','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'get_source');
return $this->sendRequest($request);
}
/**
* Get the cluster health
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-health-report
*
* @param array{
* feature?: string|array<string>, // Comma-separated list of cluster features, as returned by the top-level health report API.
* timeout?: int|string, // Explicit operation timeout.
* verbose?: bool, // Opt-in for more information about the health of the system. (DEFAULT: 1)
* size?: int, // Limit the number of affected resources the health report API returns. (DEFAULT: 1000)
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* } $params
*
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function healthReport(?array $params = null)
{
$params = $params ?? [];
if (isset($params['feature'])) {
$url = '/_health_report/' . $this->encode($this->convertValue($params['feature']));
$method = 'GET';
} else {
$url = '/_health_report';
$method = 'GET';
}
$url = $this->addQueryString($url, $params, ['timeout','verbose','size','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['feature'], $request, 'health_report');
return $this->sendRequest($request);
}
/**
* Create or update a document in an index
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-create
* @group serverless
*
* @param array{
* id?: string, // Document ID
* index: string, // (REQUIRED) The name of the index
* wait_for_active_shards?: string, // The number of shard copies that must be active before proceeding with the operation. You can set it to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`). The default value of `1` means it waits for each primary shard to be active. (DEFAULT: 1)
* op_type?: string, // Set to `create` to only index the document if it does not already exist (put if absent). If a document with the specified `_id` already exists, the indexing operation will fail. The behavior is the same as using the `<index>/_create` endpoint. If a document ID is specified, this paramater defaults to `index`. Otherwise, it defaults to `create`. If the request targets a data stream, an `op_type` of `create` is required.
* refresh?: string, // If `true`, Elasticsearch refreshes the affected shards to make this operation visible to search. If `wait_for`, it waits for a refresh to make this operation visible to search. If `false`, it does nothing with refreshes. (DEFAULT: false)
* routing?: string|array<string>, // A custom value that is used to route operations to a specific shard.
* timeout?: int|string, // The period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards. This parameter is useful for situations where the primary shard assigned to perform the operation might not be available when the operation runs. Some reasons for this might be that the primary shard is currently recovering from a gateway or undergoing relocation. By default, the operation will wait on the primary shard to become available for at least 1 minute before failing and responding with an error. The actual wait time could be longer, particularly when multiple waits occur. (DEFAULT: 1m)
* version?: int, // An explicit version number for concurrency control. It must be a non-negative long number.
* version_type?: string, // The version type.
* if_seq_no?: int, // Only perform the operation if the document has this sequence number.
* if_primary_term?: int, // Only perform the operation if the document has this primary term.
* pipeline?: string, // The ID of the pipeline to use to preprocess incoming documents. If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request. If a final pipeline is configured it will always run, regardless of the value of this parameter.
* require_alias?: bool, // If `true`, the destination must be an index alias.
* require_data_stream?: bool, // If `true`, the request's actions must target a data stream (existing or to be created).
* include_source_on_error?: bool, // True or false if to include the document source in the error message in case of parsing errors. (DEFAULT: 1)
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)
* human?: bool, // Return human readable values for statistics. (DEFAULT: true)
* error_trace?: bool, // Include the stack trace of returned errors. (DEFAULT: false)
* source?: string, // The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* filter_path?: string|array<string>, // A comma-separated list of filters used to reduce the response.
* body: string|array<mixed>, // (REQUIRED) The document. If body is a string must be a valid JSON.
* } $params
*
* @throws MissingParameterException if a required parameter is missing
* @throws NoNodeAvailableException if all the hosts are offline
* @throws ClientResponseException if the status code of response is 4xx
* @throws ServerResponseException if the status code of response is 5xx
*
* @return Elasticsearch|Promise
*/
public function index(?array $params = null)
{
$params = $params ?? [];
$this->checkRequiredParameters(['index','body'], $params);
if (isset($params['id'])) {
$url = '/' . $this->encode($params['index']) . '/_doc/' . $this->encode($params['id']);
$method = 'PUT';
} else {
$url = '/' . $this->encode($params['index']) . '/_doc';
$method = 'POST';
}
$url = $this->addQueryString($url, $params, ['wait_for_active_shards','op_type','refresh','routing','timeout','version','version_type','if_seq_no','if_primary_term','pipeline','require_alias','require_data_stream','include_source_on_error','pretty','human','error_trace','source','filter_path']);
$headers = [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
];
$request = $this->createRequest($method, $url, $headers, $params['body'] ?? null);
$request = $this->addOtelAttributes($params, ['id', 'index'], $request, 'index');
return $this->sendRequest($request);
}
/**
* Get cluster info
*
* @link https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-info
* @group serverless
*
* @param array{
* pretty?: bool, // Pretty format the returned JSON response. (DEFAULT: false)