1<?php
2/**
3 * Elasticsearch PHP client
4 *
5 * @link      https://github.com/elastic/elasticsearch-php/
6 * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
7 * @license   http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
8 * @license   https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
9 *
10 * Licensed to Elasticsearch B.V under one or more agreements.
11 * Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
12 * the GNU Lesser General Public License, Version 2.1, at your option.
13 * See the LICENSE file in the project root for more information.
14 */
15declare(strict_types = 1);
16
17namespace Elasticsearch;
18
19use Elasticsearch\Common\Exceptions\BadMethodCallException;
20use Elasticsearch\Common\Exceptions\InvalidArgumentException;
21use Elasticsearch\Common\Exceptions\NoNodesAvailableException;
22use Elasticsearch\Common\Exceptions\BadRequest400Exception;
23use Elasticsearch\Common\Exceptions\Missing404Exception;
24use Elasticsearch\Common\Exceptions\TransportException;
25use Elasticsearch\Endpoints\AbstractEndpoint;
26use Elasticsearch\Namespaces\AbstractNamespace;
27use Elasticsearch\Namespaces\NamespaceBuilderInterface;
28use Elasticsearch\Namespaces\BooleanRequestWrapper;
29use Elasticsearch\Namespaces\AsyncSearchNamespace;
30use Elasticsearch\Namespaces\AutoscalingNamespace;
31use Elasticsearch\Namespaces\CatNamespace;
32use Elasticsearch\Namespaces\CcrNamespace;
33use Elasticsearch\Namespaces\ClusterNamespace;
34use Elasticsearch\Namespaces\DanglingIndicesNamespace;
35use Elasticsearch\Namespaces\DataFrameTransformDeprecatedNamespace;
36use Elasticsearch\Namespaces\EnrichNamespace;
37use Elasticsearch\Namespaces\EqlNamespace;
38use Elasticsearch\Namespaces\FeaturesNamespace;
39use Elasticsearch\Namespaces\FleetNamespace;
40use Elasticsearch\Namespaces\GraphNamespace;
41use Elasticsearch\Namespaces\IlmNamespace;
42use Elasticsearch\Namespaces\IndicesNamespace;
43use Elasticsearch\Namespaces\IngestNamespace;
44use Elasticsearch\Namespaces\LicenseNamespace;
45use Elasticsearch\Namespaces\LogstashNamespace;
46use Elasticsearch\Namespaces\MigrationNamespace;
47use Elasticsearch\Namespaces\MlNamespace;
48use Elasticsearch\Namespaces\MonitoringNamespace;
49use Elasticsearch\Namespaces\NodesNamespace;
50use Elasticsearch\Namespaces\RollupNamespace;
51use Elasticsearch\Namespaces\SearchableSnapshotsNamespace;
52use Elasticsearch\Namespaces\SecurityNamespace;
53use Elasticsearch\Namespaces\ShutdownNamespace;
54use Elasticsearch\Namespaces\SlmNamespace;
55use Elasticsearch\Namespaces\SnapshotNamespace;
56use Elasticsearch\Namespaces\SqlNamespace;
57use Elasticsearch\Namespaces\SslNamespace;
58use Elasticsearch\Namespaces\TasksNamespace;
59use Elasticsearch\Namespaces\TextStructureNamespace;
60use Elasticsearch\Namespaces\TransformNamespace;
61use Elasticsearch\Namespaces\WatcherNamespace;
62use Elasticsearch\Namespaces\XpackNamespace;
63
64/**
65 * Class Client
66 *
67 * NOTE: this file is autogenerated using util/GenerateEndpoints.php
68 * and Elasticsearch 7.16.0-SNAPSHOT (dfc9a8e7563ed5f24b5210ed21ed92ae182cd0ee)
69 */
70class Client
71{
72    const VERSION = '7.16.0-SNAPSHOT';
73
74    /**
75     * @var Transport
76     */
77    public $transport;
78
79    /**
80     * @var array
81     */
82    protected $params;
83
84    /**
85     * @var callable
86     */
87    protected $endpoints;
88
89    /**
90     * @var NamespaceBuilderInterface[]
91     */
92    protected $registeredNamespaces = [];
93
94    /**
95     * @var AsyncSearchNamespace
96     */
97    protected $asyncSearch;
98
99    /**
100     * @var AutoscalingNamespace
101     */
102    protected $autoscaling;
103
104    /**
105     * @var CatNamespace
106     */
107    protected $cat;
108
109    /**
110     * @var CcrNamespace
111     */
112    protected $ccr;
113
114    /**
115     * @var ClusterNamespace
116     */
117    protected $cluster;
118
119    /**
120     * @var DanglingIndicesNamespace
121     */
122    protected $danglingIndices;
123
124    /**
125     * @var DataFrameTransformDeprecatedNamespace
126     */
127    protected $dataFrameTransformDeprecated;
128
129    /**
130     * @var EnrichNamespace
131     */
132    protected $enrich;
133
134    /**
135     * @var EqlNamespace
136     */
137    protected $eql;
138
139    /**
140     * @var FeaturesNamespace
141     */
142    protected $features;
143
144    /**
145     * @var FleetNamespace
146     */
147    protected $fleet;
148
149    /**
150     * @var GraphNamespace
151     */
152    protected $graph;
153
154    /**
155     * @var IlmNamespace
156     */
157    protected $ilm;
158
159    /**
160     * @var IndicesNamespace
161     */
162    protected $indices;
163
164    /**
165     * @var IngestNamespace
166     */
167    protected $ingest;
168
169    /**
170     * @var LicenseNamespace
171     */
172    protected $license;
173
174    /**
175     * @var LogstashNamespace
176     */
177    protected $logstash;
178
179    /**
180     * @var MigrationNamespace
181     */
182    protected $migration;
183
184    /**
185     * @var MlNamespace
186     */
187    protected $ml;
188
189    /**
190     * @var MonitoringNamespace
191     */
192    protected $monitoring;
193
194    /**
195     * @var NodesNamespace
196     */
197    protected $nodes;
198
199    /**
200     * @var RollupNamespace
201     */
202    protected $rollup;
203
204    /**
205     * @var SearchableSnapshotsNamespace
206     */
207    protected $searchableSnapshots;
208
209    /**
210     * @var SecurityNamespace
211     */
212    protected $security;
213
214    /**
215     * @var ShutdownNamespace
216     */
217    protected $shutdown;
218
219    /**
220     * @var SlmNamespace
221     */
222    protected $slm;
223
224    /**
225     * @var SnapshotNamespace
226     */
227    protected $snapshot;
228
229    /**
230     * @var SqlNamespace
231     */
232    protected $sql;
233
234    /**
235     * @var SslNamespace
236     */
237    protected $ssl;
238
239    /**
240     * @var TasksNamespace
241     */
242    protected $tasks;
243
244    /**
245     * @var TextStructureNamespace
246     */
247    protected $textStructure;
248
249    /**
250     * @var TransformNamespace
251     */
252    protected $transform;
253
254    /**
255     * @var WatcherNamespace
256     */
257    protected $watcher;
258
259    /**
260     * @var XpackNamespace
261     */
262    protected $xpack;
263
264
265    /**
266     * Client constructor
267     *
268     * @param Transport           $transport
269     * @param callable            $endpoint
270     * @param AbstractNamespace[] $registeredNamespaces
271     */
272    public function __construct(Transport $transport, callable $endpoint, array $registeredNamespaces)
273    {
274        $this->transport = $transport;
275        $this->endpoints = $endpoint;
276        $this->asyncSearch = new AsyncSearchNamespace($transport, $endpoint);
277        $this->autoscaling = new AutoscalingNamespace($transport, $endpoint);
278        $this->cat = new CatNamespace($transport, $endpoint);
279        $this->ccr = new CcrNamespace($transport, $endpoint);
280        $this->cluster = new ClusterNamespace($transport, $endpoint);
281        $this->danglingIndices = new DanglingIndicesNamespace($transport, $endpoint);
282        $this->dataFrameTransformDeprecated = new DataFrameTransformDeprecatedNamespace($transport, $endpoint);
283        $this->enrich = new EnrichNamespace($transport, $endpoint);
284        $this->eql = new EqlNamespace($transport, $endpoint);
285        $this->features = new FeaturesNamespace($transport, $endpoint);
286        $this->fleet = new FleetNamespace($transport, $endpoint);
287        $this->graph = new GraphNamespace($transport, $endpoint);
288        $this->ilm = new IlmNamespace($transport, $endpoint);
289        $this->indices = new IndicesNamespace($transport, $endpoint);
290        $this->ingest = new IngestNamespace($transport, $endpoint);
291        $this->license = new LicenseNamespace($transport, $endpoint);
292        $this->logstash = new LogstashNamespace($transport, $endpoint);
293        $this->migration = new MigrationNamespace($transport, $endpoint);
294        $this->ml = new MlNamespace($transport, $endpoint);
295        $this->monitoring = new MonitoringNamespace($transport, $endpoint);
296        $this->nodes = new NodesNamespace($transport, $endpoint);
297        $this->rollup = new RollupNamespace($transport, $endpoint);
298        $this->searchableSnapshots = new SearchableSnapshotsNamespace($transport, $endpoint);
299        $this->security = new SecurityNamespace($transport, $endpoint);
300        $this->shutdown = new ShutdownNamespace($transport, $endpoint);
301        $this->slm = new SlmNamespace($transport, $endpoint);
302        $this->snapshot = new SnapshotNamespace($transport, $endpoint);
303        $this->sql = new SqlNamespace($transport, $endpoint);
304        $this->ssl = new SslNamespace($transport, $endpoint);
305        $this->tasks = new TasksNamespace($transport, $endpoint);
306        $this->textStructure = new TextStructureNamespace($transport, $endpoint);
307        $this->transform = new TransformNamespace($transport, $endpoint);
308        $this->watcher = new WatcherNamespace($transport, $endpoint);
309        $this->xpack = new XpackNamespace($transport, $endpoint);
310
311        $this->registeredNamespaces = $registeredNamespaces;
312    }
313
314    /**
315     * Allows to perform multiple index/update/delete operations in a single request.
316     *
317     * $params['index']                  = (string) Default index for items which don't provide one
318     * $params['type']                   = DEPRECATED (string) Default document type for items which don't provide one
319     * $params['wait_for_active_shards'] = (string) Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
320     * $params['refresh']                = (enum) If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (Options = true,false,wait_for)
321     * $params['routing']                = (string) Specific routing value
322     * $params['timeout']                = (time) Explicit operation timeout
323     * $params['_source']                = (list) True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request
324     * $params['_source_excludes']       = (list) Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
325     * $params['_source_includes']       = (list) Default list of fields to extract and return from the _source field, can be overridden on each sub-request
326     * $params['pipeline']               = (string) The pipeline id to preprocess incoming documents with
327     * $params['require_alias']          = (boolean) Sets require_alias for all incoming documents. Defaults to unset (false)
328     * $params['body']                   = (array) The operation definition and data (action-data pairs), separated by newlines (Required)
329     *
330     * @param array $params Associative array of parameters
331     * @return array
332     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html
333     */
334    public function bulk(array $params = [])
335    {
336        $index = $this->extractArgument($params, 'index');
337        $type = $this->extractArgument($params, 'type');
338        $body = $this->extractArgument($params, 'body');
339
340        $endpointBuilder = $this->endpoints;
341        $endpoint = $endpointBuilder('Bulk');
342        $endpoint->setParams($params);
343        $endpoint->setIndex($index);
344        $endpoint->setType($type);
345        $endpoint->setBody($body);
346
347        return $this->performRequest($endpoint);
348    }
349    /**
350     * Explicitly clears the search context for a scroll.
351     *
352     * $params['scroll_id'] = DEPRECATED (list) A comma-separated list of scroll IDs to clear
353     * $params['body']      = (array) A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter
354     *
355     * @param array $params Associative array of parameters
356     * @return array
357     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html
358     */
359    public function clearScroll(array $params = [])
360    {
361        $scroll_id = $this->extractArgument($params, 'scroll_id');
362        $body = $this->extractArgument($params, 'body');
363
364        $endpointBuilder = $this->endpoints;
365        $endpoint = $endpointBuilder('ClearScroll');
366        $endpoint->setParams($params);
367        $endpoint->setScrollId($scroll_id);
368        $endpoint->setBody($body);
369
370        return $this->performRequest($endpoint);
371    }
372    /**
373     * Close a point in time
374     *
375     * $params['body'] = (array) a point-in-time id to close
376     *
377     * @param array $params Associative array of parameters
378     * @return array
379     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html
380     */
381    public function closePointInTime(array $params = [])
382    {
383        $body = $this->extractArgument($params, 'body');
384
385        $endpointBuilder = $this->endpoints;
386        $endpoint = $endpointBuilder('ClosePointInTime');
387        $endpoint->setParams($params);
388        $endpoint->setBody($body);
389
390        return $this->performRequest($endpoint);
391    }
392    /**
393     * Returns number of documents matching a query.
394     *
395     * $params['index']              = (list) A comma-separated list of indices to restrict the results
396     * $params['type']               = DEPRECATED (list) A comma-separated list of types to restrict the results
397     * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
398     * $params['ignore_throttled']   = (boolean) Whether specified concrete, expanded or aliased indices should be ignored when throttled
399     * $params['allow_no_indices']   = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
400     * $params['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
401     * $params['min_score']          = (number) Include only documents with a specific `_score` value in the result
402     * $params['preference']         = (string) Specify the node or shard the operation should be performed on (default: random)
403     * $params['routing']            = (list) A comma-separated list of specific routing values
404     * $params['q']                  = (string) Query in the Lucene query string syntax
405     * $params['analyzer']           = (string) The analyzer to use for the query string
406     * $params['analyze_wildcard']   = (boolean) Specify whether wildcard and prefix queries should be analyzed (default: false)
407     * $params['default_operator']   = (enum) The default operator for query string query (AND or OR) (Options = AND,OR) (Default = OR)
408     * $params['df']                 = (string) The field to use as default where no field prefix is given in the query string
409     * $params['lenient']            = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
410     * $params['terminate_after']    = (number) The maximum count for each shard, upon reaching which the query execution will terminate early
411     * $params['body']               = (array) A query to restrict the results specified with the Query DSL (optional)
412     *
413     * @param array $params Associative array of parameters
414     * @return array
415     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html
416     */
417    public function count(array $params = [])
418    {
419        $index = $this->extractArgument($params, 'index');
420        $type = $this->extractArgument($params, 'type');
421        $body = $this->extractArgument($params, 'body');
422
423        $endpointBuilder = $this->endpoints;
424        $endpoint = $endpointBuilder('Count');
425        $endpoint->setParams($params);
426        $endpoint->setIndex($index);
427        $endpoint->setType($type);
428        $endpoint->setBody($body);
429
430        return $this->performRequest($endpoint);
431    }
432    /**
433     * Creates a new document in the index.Returns a 409 response when a document with a same ID already exists in the index.
434     *
435     * $params['id']                     = (string) Document ID (Required)
436     * $params['index']                  = (string) The name of the index (Required)
437     * $params['type']                   = DEPRECATED (string) The type of the document
438     * $params['wait_for_active_shards'] = (string) Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
439     * $params['refresh']                = (enum) If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (Options = true,false,wait_for)
440     * $params['routing']                = (string) Specific routing value
441     * $params['timeout']                = (time) Explicit operation timeout
442     * $params['version']                = (number) Explicit version number for concurrency control
443     * $params['version_type']           = (enum) Specific version type (Options = internal,external,external_gte)
444     * $params['pipeline']               = (string) The pipeline id to preprocess incoming documents with
445     * $params['body']                   = (array) The document (Required)
446     *
447     * @param array $params Associative array of parameters
448     * @return array
449     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html
450     */
451    public function create(array $params = [])
452    {
453        $id = $this->extractArgument($params, 'id');
454        $index = $this->extractArgument($params, 'index');
455        $type = $this->extractArgument($params, 'type');
456        $body = $this->extractArgument($params, 'body');
457
458        $endpointBuilder = $this->endpoints;
459        $endpoint = $endpointBuilder('Create');
460        $endpoint->setParams($params);
461        $endpoint->setId($id);
462        $endpoint->setIndex($index);
463        $endpoint->setType($type);
464        $endpoint->setBody($body);
465
466        return $this->performRequest($endpoint);
467    }
468    /**
469     * Removes a document from the index.
470     *
471     * $params['id']                     = (string) The document ID (Required)
472     * $params['index']                  = (string) The name of the index (Required)
473     * $params['type']                   = DEPRECATED (string) The type of the document
474     * $params['wait_for_active_shards'] = (string) Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
475     * $params['refresh']                = (enum) If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (Options = true,false,wait_for)
476     * $params['routing']                = (string) Specific routing value
477     * $params['timeout']                = (time) Explicit operation timeout
478     * $params['if_seq_no']              = (number) only perform the delete operation if the last operation that has changed the document has the specified sequence number
479     * $params['if_primary_term']        = (number) only perform the delete operation if the last operation that has changed the document has the specified primary term
480     * $params['version']                = (number) Explicit version number for concurrency control
481     * $params['version_type']           = (enum) Specific version type (Options = internal,external,external_gte,force)
482     *
483     * @param array $params Associative array of parameters
484     * @return array
485     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html
486     */
487    public function delete(array $params = [])
488    {
489        $id = $this->extractArgument($params, 'id');
490        $index = $this->extractArgument($params, 'index');
491        $type = $this->extractArgument($params, 'type');
492
493        $endpointBuilder = $this->endpoints;
494        $endpoint = $endpointBuilder('Delete');
495        $endpoint->setParams($params);
496        $endpoint->setId($id);
497        $endpoint->setIndex($index);
498        $endpoint->setType($type);
499
500        return $this->performRequest($endpoint);
501    }
502    /**
503     * Deletes documents matching the provided query.
504     *
505     * $params['index']                  = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (Required)
506     * $params['type']                   = DEPRECATED (list) A comma-separated list of document types to search; leave empty to perform the operation on all types
507     * $params['analyzer']               = (string) The analyzer to use for the query string
508     * $params['analyze_wildcard']       = (boolean) Specify whether wildcard and prefix queries should be analyzed (default: false)
509     * $params['default_operator']       = (enum) The default operator for query string query (AND or OR) (Options = AND,OR) (Default = OR)
510     * $params['df']                     = (string) The field to use as default where no field prefix is given in the query string
511     * $params['from']                   = (number) Starting offset (default: 0)
512     * $params['ignore_unavailable']     = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
513     * $params['allow_no_indices']       = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
514     * $params['conflicts']              = (enum) What to do when the delete by query hits version conflicts? (Options = abort,proceed) (Default = abort)
515     * $params['expand_wildcards']       = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
516     * $params['lenient']                = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
517     * $params['preference']             = (string) Specify the node or shard the operation should be performed on (default: random)
518     * $params['q']                      = (string) Query in the Lucene query string syntax
519     * $params['routing']                = (list) A comma-separated list of specific routing values
520     * $params['scroll']                 = (time) Specify how long a consistent view of the index should be maintained for scrolled search
521     * $params['search_type']            = (enum) Search operation type (Options = query_then_fetch,dfs_query_then_fetch)
522     * $params['search_timeout']         = (time) Explicit timeout for each search request. Defaults to no timeout.
523     * $params['size']                   = (number) Deprecated, please use `max_docs` instead
524     * $params['max_docs']               = (number) Maximum number of documents to process (default: all documents)
525     * $params['sort']                   = (list) A comma-separated list of <field>:<direction> pairs
526     * $params['_source']                = (list) True or false to return the _source field or not, or a list of fields to return
527     * $params['_source_excludes']       = (list) A list of fields to exclude from the returned _source field
528     * $params['_source_includes']       = (list) A list of fields to extract and return from the _source field
529     * $params['terminate_after']        = (number) The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
530     * $params['stats']                  = (list) Specific 'tag' of the request for logging and statistical purposes
531     * $params['version']                = (boolean) Specify whether to return document version as part of a hit
532     * $params['request_cache']          = (boolean) Specify if request cache should be used for this request or not, defaults to index level setting
533     * $params['refresh']                = (boolean) Should the effected indexes be refreshed?
534     * $params['timeout']                = (time) Time each individual bulk request should wait for shards that are unavailable. (Default = 1m)
535     * $params['wait_for_active_shards'] = (string) Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
536     * $params['scroll_size']            = (number) Size on the scroll request powering the delete by query (Default = 100)
537     * $params['wait_for_completion']    = (boolean) Should the request should block until the delete by query is complete. (Default = true)
538     * $params['requests_per_second']    = (number) The throttle for this request in sub-requests per second. -1 means no throttle. (Default = 0)
539     * $params['slices']                 = (number|string) The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. (Default = 1)
540     * $params['body']                   = (array) The search definition using the Query DSL (Required)
541     *
542     * @param array $params Associative array of parameters
543     * @return array
544     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html
545     */
546    public function deleteByQuery(array $params = [])
547    {
548        $index = $this->extractArgument($params, 'index');
549        $type = $this->extractArgument($params, 'type');
550        $body = $this->extractArgument($params, 'body');
551
552        $endpointBuilder = $this->endpoints;
553        $endpoint = $endpointBuilder('DeleteByQuery');
554        $endpoint->setParams($params);
555        $endpoint->setIndex($index);
556        $endpoint->setType($type);
557        $endpoint->setBody($body);
558
559        return $this->performRequest($endpoint);
560    }
561    /**
562     * Changes the number of requests per second for a particular Delete By Query operation.
563     *
564     * $params['task_id']             = (string) The task id to rethrottle
565     * $params['requests_per_second'] = (number) The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (Required)
566     *
567     * @param array $params Associative array of parameters
568     * @return array
569     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
570     */
571    public function deleteByQueryRethrottle(array $params = [])
572    {
573        $task_id = $this->extractArgument($params, 'task_id');
574
575        $endpointBuilder = $this->endpoints;
576        $endpoint = $endpointBuilder('DeleteByQueryRethrottle');
577        $endpoint->setParams($params);
578        $endpoint->setTaskId($task_id);
579
580        return $this->performRequest($endpoint);
581    }
582    /**
583     * Deletes a script.
584     *
585     * $params['id']             = (string) Script ID
586     * $params['timeout']        = (time) Explicit operation timeout
587     * $params['master_timeout'] = (time) Specify timeout for connection to master
588     *
589     * @param array $params Associative array of parameters
590     * @return array
591     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
592     */
593    public function deleteScript(array $params = [])
594    {
595        $id = $this->extractArgument($params, 'id');
596
597        $endpointBuilder = $this->endpoints;
598        $endpoint = $endpointBuilder('DeleteScript');
599        $endpoint->setParams($params);
600        $endpoint->setId($id);
601
602        return $this->performRequest($endpoint);
603    }
604    /**
605     * Returns information about whether a document exists in an index.
606     *
607     * $params['id']               = (string) The document ID (Required)
608     * $params['index']            = (string) The name of the index (Required)
609     * $params['type']             = DEPRECATED (string) The type of the document (use `_all` to fetch the first document matching the ID across all types)
610     * $params['stored_fields']    = (list) A comma-separated list of stored fields to return in the response
611     * $params['preference']       = (string) Specify the node or shard the operation should be performed on (default: random)
612     * $params['realtime']         = (boolean) Specify whether to perform the operation in realtime or search mode
613     * $params['refresh']          = (boolean) Refresh the shard containing the document before performing the operation
614     * $params['routing']          = (string) Specific routing value
615     * $params['_source']          = (list) True or false to return the _source field or not, or a list of fields to return
616     * $params['_source_excludes'] = (list) A list of fields to exclude from the returned _source field
617     * $params['_source_includes'] = (list) A list of fields to extract and return from the _source field
618     * $params['version']          = (number) Explicit version number for concurrency control
619     * $params['version_type']     = (enum) Specific version type (Options = internal,external,external_gte,force)
620     *
621     * @param array $params Associative array of parameters
622     * @return bool
623     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
624     */
625    public function exists(array $params = []): bool
626    {
627        $id = $this->extractArgument($params, 'id');
628        $index = $this->extractArgument($params, 'index');
629        $type = $this->extractArgument($params, 'type');
630
631        // manually make this verbose so we can check status code
632        $params['client']['verbose'] = true;
633
634        $endpointBuilder = $this->endpoints;
635        $endpoint = $endpointBuilder('Exists');
636        $endpoint->setParams($params);
637        $endpoint->setId($id);
638        $endpoint->setIndex($index);
639        $endpoint->setType($type);
640
641        return BooleanRequestWrapper::performRequest($endpoint, $this->transport);
642    }
643    /**
644     * Returns information about whether a document source exists in an index.
645     *
646     * $params['id']               = (string) The document ID (Required)
647     * $params['index']            = (string) The name of the index (Required)
648     * $params['type']             = DEPRECATED (string) The type of the document; deprecated and optional starting with 7.0
649     * $params['preference']       = (string) Specify the node or shard the operation should be performed on (default: random)
650     * $params['realtime']         = (boolean) Specify whether to perform the operation in realtime or search mode
651     * $params['refresh']          = (boolean) Refresh the shard containing the document before performing the operation
652     * $params['routing']          = (string) Specific routing value
653     * $params['_source']          = (list) True or false to return the _source field or not, or a list of fields to return
654     * $params['_source_excludes'] = (list) A list of fields to exclude from the returned _source field
655     * $params['_source_includes'] = (list) A list of fields to extract and return from the _source field
656     * $params['version']          = (number) Explicit version number for concurrency control
657     * $params['version_type']     = (enum) Specific version type (Options = internal,external,external_gte,force)
658     *
659     * @param array $params Associative array of parameters
660     * @return bool
661     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
662     */
663    public function existsSource(array $params = []): bool
664    {
665        $id = $this->extractArgument($params, 'id');
666        $index = $this->extractArgument($params, 'index');
667        $type = $this->extractArgument($params, 'type');
668
669        // manually make this verbose so we can check status code
670        $params['client']['verbose'] = true;
671
672        $endpointBuilder = $this->endpoints;
673        $endpoint = $endpointBuilder('ExistsSource');
674        $endpoint->setParams($params);
675        $endpoint->setId($id);
676        $endpoint->setIndex($index);
677        $endpoint->setType($type);
678
679        return BooleanRequestWrapper::performRequest($endpoint, $this->transport);
680    }
681    /**
682     * Returns information about why a specific matches (or doesn't match) a query.
683     *
684     * $params['id']               = (string) The document ID (Required)
685     * $params['index']            = (string) The name of the index (Required)
686     * $params['type']             = DEPRECATED (string) The type of the document
687     * $params['analyze_wildcard'] = (boolean) Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false)
688     * $params['analyzer']         = (string) The analyzer for the query string query
689     * $params['default_operator'] = (enum) The default operator for query string query (AND or OR) (Options = AND,OR) (Default = OR)
690     * $params['df']               = (string) The default field for query string query (default: _all)
691     * $params['stored_fields']    = (list) A comma-separated list of stored fields to return in the response
692     * $params['lenient']          = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
693     * $params['preference']       = (string) Specify the node or shard the operation should be performed on (default: random)
694     * $params['q']                = (string) Query in the Lucene query string syntax
695     * $params['routing']          = (string) Specific routing value
696     * $params['_source']          = (list) True or false to return the _source field or not, or a list of fields to return
697     * $params['_source_excludes'] = (list) A list of fields to exclude from the returned _source field
698     * $params['_source_includes'] = (list) A list of fields to extract and return from the _source field
699     * $params['body']             = (array) The query definition using the Query DSL
700     *
701     * @param array $params Associative array of parameters
702     * @return array
703     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html
704     */
705    public function explain(array $params = [])
706    {
707        $id = $this->extractArgument($params, 'id');
708        $index = $this->extractArgument($params, 'index');
709        $type = $this->extractArgument($params, 'type');
710        $body = $this->extractArgument($params, 'body');
711
712        $endpointBuilder = $this->endpoints;
713        $endpoint = $endpointBuilder('Explain');
714        $endpoint->setParams($params);
715        $endpoint->setId($id);
716        $endpoint->setIndex($index);
717        $endpoint->setType($type);
718        $endpoint->setBody($body);
719
720        return $this->performRequest($endpoint);
721    }
722    /**
723     * Returns the information about the capabilities of fields among multiple indices.
724     *
725     * $params['index']              = (list) A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
726     * $params['fields']             = (list) A comma-separated list of field names
727     * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
728     * $params['allow_no_indices']   = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
729     * $params['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
730     * $params['include_unmapped']   = (boolean) Indicates whether unmapped fields should be included in the response. (Default = false)
731     * $params['body']               = (array) An index filter specified with the Query DSL
732     *
733     * @param array $params Associative array of parameters
734     * @return array
735     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html
736     */
737    public function fieldCaps(array $params = [])
738    {
739        $index = $this->extractArgument($params, 'index');
740        $body = $this->extractArgument($params, 'body');
741
742        $endpointBuilder = $this->endpoints;
743        $endpoint = $endpointBuilder('FieldCaps');
744        $endpoint->setParams($params);
745        $endpoint->setIndex($index);
746        $endpoint->setBody($body);
747
748        return $this->performRequest($endpoint);
749    }
750    /**
751     * Returns a document.
752     *
753     * $params['id']               = (string) The document ID (Required)
754     * $params['index']            = (string) The name of the index (Required)
755     * $params['type']             = DEPRECATED (string) The type of the document (use `_all` to fetch the first document matching the ID across all types)
756     * $params['stored_fields']    = (list) A comma-separated list of stored fields to return in the response
757     * $params['preference']       = (string) Specify the node or shard the operation should be performed on (default: random)
758     * $params['realtime']         = (boolean) Specify whether to perform the operation in realtime or search mode
759     * $params['refresh']          = (boolean) Refresh the shard containing the document before performing the operation
760     * $params['routing']          = (string) Specific routing value
761     * $params['_source']          = (list) True or false to return the _source field or not, or a list of fields to return
762     * $params['_source_excludes'] = (list) A list of fields to exclude from the returned _source field
763     * $params['_source_includes'] = (list) A list of fields to extract and return from the _source field
764     * $params['version']          = (number) Explicit version number for concurrency control
765     * $params['version_type']     = (enum) Specific version type (Options = internal,external,external_gte,force)
766     *
767     * @param array $params Associative array of parameters
768     * @return array
769     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
770     */
771    public function get(array $params = [])
772    {
773        $id = $this->extractArgument($params, 'id');
774        $index = $this->extractArgument($params, 'index');
775        $type = $this->extractArgument($params, 'type');
776
777        $endpointBuilder = $this->endpoints;
778        $endpoint = $endpointBuilder('Get');
779        $endpoint->setParams($params);
780        $endpoint->setId($id);
781        $endpoint->setIndex($index);
782        $endpoint->setType($type);
783
784        return $this->performRequest($endpoint);
785    }
786    /**
787     * Returns a script.
788     *
789     * $params['id']             = (string) Script ID
790     * $params['master_timeout'] = (time) Specify timeout for connection to master
791     *
792     * @param array $params Associative array of parameters
793     * @return array
794     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
795     */
796    public function getScript(array $params = [])
797    {
798        $id = $this->extractArgument($params, 'id');
799
800        $endpointBuilder = $this->endpoints;
801        $endpoint = $endpointBuilder('GetScript');
802        $endpoint->setParams($params);
803        $endpoint->setId($id);
804
805        return $this->performRequest($endpoint);
806    }
807    /**
808     * Returns all script contexts.
809     *
810     *
811     * @param array $params Associative array of parameters
812     * @return array
813     * @see https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html
814     *
815     * @note This API is EXPERIMENTAL and may be changed or removed completely in a future release
816     *
817     */
818    public function getScriptContext(array $params = [])
819    {
820
821        $endpointBuilder = $this->endpoints;
822        $endpoint = $endpointBuilder('GetScriptContext');
823        $endpoint->setParams($params);
824
825        return $this->performRequest($endpoint);
826    }
827    /**
828     * Returns available script types, languages and contexts
829     *
830     *
831     * @param array $params Associative array of parameters
832     * @return array
833     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
834     *
835     * @note This API is EXPERIMENTAL and may be changed or removed completely in a future release
836     *
837     */
838    public function getScriptLanguages(array $params = [])
839    {
840
841        $endpointBuilder = $this->endpoints;
842        $endpoint = $endpointBuilder('GetScriptLanguages');
843        $endpoint->setParams($params);
844
845        return $this->performRequest($endpoint);
846    }
847    /**
848     * Returns the source of a document.
849     *
850     * $params['id']               = (string) The document ID (Required)
851     * $params['index']            = (string) The name of the index (Required)
852     * $params['type']             = DEPRECATED (string) The type of the document; deprecated and optional starting with 7.0
853     * $params['preference']       = (string) Specify the node or shard the operation should be performed on (default: random)
854     * $params['realtime']         = (boolean) Specify whether to perform the operation in realtime or search mode
855     * $params['refresh']          = (boolean) Refresh the shard containing the document before performing the operation
856     * $params['routing']          = (string) Specific routing value
857     * $params['_source']          = (list) True or false to return the _source field or not, or a list of fields to return
858     * $params['_source_excludes'] = (list) A list of fields to exclude from the returned _source field
859     * $params['_source_includes'] = (list) A list of fields to extract and return from the _source field
860     * $params['version']          = (number) Explicit version number for concurrency control
861     * $params['version_type']     = (enum) Specific version type (Options = internal,external,external_gte,force)
862     *
863     * @param array $params Associative array of parameters
864     * @return array
865     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html
866     */
867    public function getSource(array $params = [])
868    {
869        $id = $this->extractArgument($params, 'id');
870        $index = $this->extractArgument($params, 'index');
871        $type = $this->extractArgument($params, 'type');
872
873        $endpointBuilder = $this->endpoints;
874        $endpoint = $endpointBuilder('GetSource');
875        $endpoint->setParams($params);
876        $endpoint->setId($id);
877        $endpoint->setIndex($index);
878        $endpoint->setType($type);
879
880        return $this->performRequest($endpoint);
881    }
882    /**
883     * Creates or updates a document in an index.
884     *
885     * $params['id']                     = (string) Document ID
886     * $params['index']                  = (string) The name of the index (Required)
887     * $params['type']                   = DEPRECATED (string) The type of the document
888     * $params['wait_for_active_shards'] = (string) Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
889     * $params['op_type']                = (enum) Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID (Options = index,create)
890     * $params['refresh']                = (enum) If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (Options = true,false,wait_for)
891     * $params['routing']                = (string) Specific routing value
892     * $params['timeout']                = (time) Explicit operation timeout
893     * $params['version']                = (number) Explicit version number for concurrency control
894     * $params['version_type']           = (enum) Specific version type (Options = internal,external,external_gte)
895     * $params['if_seq_no']              = (number) only perform the index operation if the last operation that has changed the document has the specified sequence number
896     * $params['if_primary_term']        = (number) only perform the index operation if the last operation that has changed the document has the specified primary term
897     * $params['pipeline']               = (string) The pipeline id to preprocess incoming documents with
898     * $params['require_alias']          = (boolean) When true, requires destination to be an alias. Default is false
899     * $params['body']                   = (array) The document (Required)
900     *
901     * @param array $params Associative array of parameters
902     * @return array
903     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html
904     */
905    public function index(array $params = [])
906    {
907        $id = $this->extractArgument($params, 'id');
908        $index = $this->extractArgument($params, 'index');
909        $type = $this->extractArgument($params, 'type');
910        $body = $this->extractArgument($params, 'body');
911
912        $endpointBuilder = $this->endpoints;
913        $endpoint = $endpointBuilder('Index');
914        $endpoint->setParams($params);
915        $endpoint->setId($id);
916        $endpoint->setIndex($index);
917        $endpoint->setType($type);
918        $endpoint->setBody($body);
919
920        return $this->performRequest($endpoint);
921    }
922    /**
923     * Returns basic information about the cluster.
924     *
925     *
926     * @param array $params Associative array of parameters
927     * @return array
928     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
929     */
930    public function info(array $params = [])
931    {
932
933        $endpointBuilder = $this->endpoints;
934        $endpoint = $endpointBuilder('Info');
935        $endpoint->setParams($params);
936
937        return $this->performRequest($endpoint);
938    }
939    /**
940     * Allows to get multiple documents in one request.
941     *
942     * $params['index']            = (string) The name of the index
943     * $params['type']             = DEPRECATED (string) The type of the document
944     * $params['stored_fields']    = (list) A comma-separated list of stored fields to return in the response
945     * $params['preference']       = (string) Specify the node or shard the operation should be performed on (default: random)
946     * $params['realtime']         = (boolean) Specify whether to perform the operation in realtime or search mode
947     * $params['refresh']          = (boolean) Refresh the shard containing the document before performing the operation
948     * $params['routing']          = (string) Specific routing value
949     * $params['_source']          = (list) True or false to return the _source field or not, or a list of fields to return
950     * $params['_source_excludes'] = (list) A list of fields to exclude from the returned _source field
951     * $params['_source_includes'] = (list) A list of fields to extract and return from the _source field
952     * $params['body']             = (array) Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. (Required)
953     *
954     * @param array $params Associative array of parameters
955     * @return array
956     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html
957     */
958    public function mget(array $params = [])
959    {
960        $index = $this->extractArgument($params, 'index');
961        $type = $this->extractArgument($params, 'type');
962        $body = $this->extractArgument($params, 'body');
963
964        $endpointBuilder = $this->endpoints;
965        $endpoint = $endpointBuilder('Mget');
966        $endpoint->setParams($params);
967        $endpoint->setIndex($index);
968        $endpoint->setType($type);
969        $endpoint->setBody($body);
970
971        return $this->performRequest($endpoint);
972    }
973    /**
974     * Allows to execute several search operations in one request.
975     *
976     * $params['index']                         = (list) A comma-separated list of index names to use as default
977     * $params['type']                          = DEPRECATED (list) A comma-separated list of document types to use as default
978     * $params['search_type']                   = (enum) Search operation type (Options = query_then_fetch,dfs_query_then_fetch)
979     * $params['max_concurrent_searches']       = (number) Controls the maximum number of concurrent searches the multi search api will execute
980     * $params['typed_keys']                    = (boolean) Specify whether aggregation and suggester names should be prefixed by their respective types in the response
981     * $params['pre_filter_shard_size']         = (number) A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
982     * $params['max_concurrent_shard_requests'] = (number) The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests (Default = 5)
983     * $params['rest_total_hits_as_int']        = (boolean) Indicates whether hits.total should be rendered as an integer or an object in the rest search response (Default = false)
984     * $params['ccs_minimize_roundtrips']       = (boolean) Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution (Default = true)
985     * $params['body']                          = (array) The request definitions (metadata-search request definition pairs), separated by newlines (Required)
986     *
987     * @param array $params Associative array of parameters
988     * @return array
989     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html
990     */
991    public function msearch(array $params = [])
992    {
993        $index = $this->extractArgument($params, 'index');
994        $type = $this->extractArgument($params, 'type');
995        $body = $this->extractArgument($params, 'body');
996
997        $endpointBuilder = $this->endpoints;
998        $endpoint = $endpointBuilder('Msearch');
999        $endpoint->setParams($params);
1000        $endpoint->setIndex($index);
1001        $endpoint->setType($type);
1002        $endpoint->setBody($body);
1003
1004        return $this->performRequest($endpoint);
1005    }
1006    /**
1007     * Allows to execute several search template operations in one request.
1008     *
1009     * $params['index']                   = (list) A comma-separated list of index names to use as default
1010     * $params['type']                    = DEPRECATED (list) A comma-separated list of document types to use as default
1011     * $params['search_type']             = (enum) Search operation type (Options = query_then_fetch,dfs_query_then_fetch)
1012     * $params['typed_keys']              = (boolean) Specify whether aggregation and suggester names should be prefixed by their respective types in the response
1013     * $params['max_concurrent_searches'] = (number) Controls the maximum number of concurrent searches the multi search api will execute
1014     * $params['rest_total_hits_as_int']  = (boolean) Indicates whether hits.total should be rendered as an integer or an object in the rest search response (Default = false)
1015     * $params['ccs_minimize_roundtrips'] = (boolean) Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution (Default = true)
1016     * $params['body']                    = (array) The request definitions (metadata-search request definition pairs), separated by newlines (Required)
1017     *
1018     * @param array $params Associative array of parameters
1019     * @return array
1020     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html
1021     */
1022    public function msearchTemplate(array $params = [])
1023    {
1024        $index = $this->extractArgument($params, 'index');
1025        $type = $this->extractArgument($params, 'type');
1026        $body = $this->extractArgument($params, 'body');
1027
1028        $endpointBuilder = $this->endpoints;
1029        $endpoint = $endpointBuilder('MsearchTemplate');
1030        $endpoint->setParams($params);
1031        $endpoint->setIndex($index);
1032        $endpoint->setType($type);
1033        $endpoint->setBody($body);
1034
1035        return $this->performRequest($endpoint);
1036    }
1037    /**
1038     * Returns multiple termvectors in one request.
1039     *
1040     * $params['index']            = (string) The index in which the document resides.
1041     * $params['type']             = DEPRECATED (string) The type of the document.
1042     * $params['ids']              = (list) A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body
1043     * $params['term_statistics']  = (boolean) Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". (Default = false)
1044     * $params['field_statistics'] = (boolean) Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". (Default = true)
1045     * $params['fields']           = (list) A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs".
1046     * $params['offsets']          = (boolean) Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". (Default = true)
1047     * $params['positions']        = (boolean) Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". (Default = true)
1048     * $params['payloads']         = (boolean) Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". (Default = true)
1049     * $params['preference']       = (string) Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs".
1050     * $params['routing']          = (string) Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs".
1051     * $params['realtime']         = (boolean) Specifies if requests are real-time as opposed to near-real-time (default: true).
1052     * $params['version']          = (number) Explicit version number for concurrency control
1053     * $params['version_type']     = (enum) Specific version type (Options = internal,external,external_gte,force)
1054     * $params['body']             = (array) Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation.
1055     *
1056     * @param array $params Associative array of parameters
1057     * @return array
1058     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html
1059     */
1060    public function mtermvectors(array $params = [])
1061    {
1062        $index = $this->extractArgument($params, 'index');
1063        $type = $this->extractArgument($params, 'type');
1064        $body = $this->extractArgument($params, 'body');
1065
1066        $endpointBuilder = $this->endpoints;
1067        $endpoint = $endpointBuilder('MTermVectors');
1068        $endpoint->setParams($params);
1069        $endpoint->setIndex($index);
1070        $endpoint->setType($type);
1071        $endpoint->setBody($body);
1072
1073        return $this->performRequest($endpoint);
1074    }
1075    /**
1076     * Open a point in time that can be used in subsequent searches
1077     *
1078     * $params['index']              = (list) A comma-separated list of index names to open point in time; use `_all` or empty string to perform the operation on all indices
1079     * $params['preference']         = (string) Specify the node or shard the operation should be performed on (default: random)
1080     * $params['routing']            = (string) Specific routing value
1081     * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1082     * $params['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
1083     * $params['keep_alive']         = (string) Specific the time to live for the point in time
1084     *
1085     * @param array $params Associative array of parameters
1086     * @return array
1087     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/point-in-time-api.html
1088     */
1089    public function openPointInTime(array $params = [])
1090    {
1091        $index = $this->extractArgument($params, 'index');
1092
1093        $endpointBuilder = $this->endpoints;
1094        $endpoint = $endpointBuilder('OpenPointInTime');
1095        $endpoint->setParams($params);
1096        $endpoint->setIndex($index);
1097
1098        return $this->performRequest($endpoint);
1099    }
1100    /**
1101     * Returns whether the cluster is running.
1102     *
1103     *
1104     * @param array $params Associative array of parameters
1105     * @return bool
1106     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html
1107     */
1108    public function ping(array $params = []): bool
1109    {
1110
1111        // manually make this verbose so we can check status code
1112        $params['client']['verbose'] = true;
1113
1114        $endpointBuilder = $this->endpoints;
1115        $endpoint = $endpointBuilder('Ping');
1116        $endpoint->setParams($params);
1117
1118        return BooleanRequestWrapper::performRequest($endpoint, $this->transport);
1119    }
1120    /**
1121     * Creates or updates a script.
1122     *
1123     * $params['id']             = (string) Script ID (Required)
1124     * $params['context']        = (string) Script context
1125     * $params['timeout']        = (time) Explicit operation timeout
1126     * $params['master_timeout'] = (time) Specify timeout for connection to master
1127     * $params['body']           = (array) The document (Required)
1128     *
1129     * @param array $params Associative array of parameters
1130     * @return array
1131     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
1132     */
1133    public function putScript(array $params = [])
1134    {
1135        $id = $this->extractArgument($params, 'id');
1136        $context = $this->extractArgument($params, 'context');
1137        $body = $this->extractArgument($params, 'body');
1138
1139        $endpointBuilder = $this->endpoints;
1140        $endpoint = $endpointBuilder('PutScript');
1141        $endpoint->setParams($params);
1142        $endpoint->setId($id);
1143        $endpoint->setContext($context);
1144        $endpoint->setBody($body);
1145
1146        return $this->performRequest($endpoint);
1147    }
1148    /**
1149     * Allows to evaluate the quality of ranked search results over a set of typical search queries
1150     *
1151     * $params['index']              = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
1152     * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1153     * $params['allow_no_indices']   = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
1154     * $params['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
1155     * $params['search_type']        = (enum) Search operation type (Options = query_then_fetch,dfs_query_then_fetch)
1156     * $params['body']               = (array) The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. (Required)
1157     *
1158     * @param array $params Associative array of parameters
1159     * @return array
1160     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html
1161     *
1162     * @note This API is EXPERIMENTAL and may be changed or removed completely in a future release
1163     *
1164     */
1165    public function rankEval(array $params = [])
1166    {
1167        $index = $this->extractArgument($params, 'index');
1168        $body = $this->extractArgument($params, 'body');
1169
1170        $endpointBuilder = $this->endpoints;
1171        $endpoint = $endpointBuilder('RankEval');
1172        $endpoint->setParams($params);
1173        $endpoint->setIndex($index);
1174        $endpoint->setBody($body);
1175
1176        return $this->performRequest($endpoint);
1177    }
1178    /**
1179     * Allows to copy documents from one index to another, optionally filtering the sourcedocuments by a query, changing the destination index settings, or fetching thedocuments from a remote cluster.
1180     *
1181     * $params['refresh']                = (boolean) Should the affected indexes be refreshed?
1182     * $params['timeout']                = (time) Time each individual bulk request should wait for shards that are unavailable. (Default = 1m)
1183     * $params['wait_for_active_shards'] = (string) Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
1184     * $params['wait_for_completion']    = (boolean) Should the request should block until the reindex is complete. (Default = true)
1185     * $params['requests_per_second']    = (number) The throttle to set on this request in sub-requests per second. -1 means no throttle. (Default = 0)
1186     * $params['scroll']                 = (time) Control how long to keep the search context alive (Default = 5m)
1187     * $params['slices']                 = (number|string) The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. (Default = 1)
1188     * $params['max_docs']               = (number) Maximum number of documents to process (default: all documents)
1189     * $params['body']                   = (array) The search definition using the Query DSL and the prototype for the index request. (Required)
1190     *
1191     * @param array $params Associative array of parameters
1192     * @return array
1193     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html
1194     */
1195    public function reindex(array $params = [])
1196    {
1197        $body = $this->extractArgument($params, 'body');
1198
1199        $endpointBuilder = $this->endpoints;
1200        $endpoint = $endpointBuilder('Reindex');
1201        $endpoint->setParams($params);
1202        $endpoint->setBody($body);
1203
1204        return $this->performRequest($endpoint);
1205    }
1206    /**
1207     * Changes the number of requests per second for a particular Reindex operation.
1208     *
1209     * $params['task_id']             = (string) The task id to rethrottle
1210     * $params['requests_per_second'] = (number) The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (Required)
1211     *
1212     * @param array $params Associative array of parameters
1213     * @return array
1214     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html
1215     */
1216    public function reindexRethrottle(array $params = [])
1217    {
1218        $task_id = $this->extractArgument($params, 'task_id');
1219
1220        $endpointBuilder = $this->endpoints;
1221        $endpoint = $endpointBuilder('ReindexRethrottle');
1222        $endpoint->setParams($params);
1223        $endpoint->setTaskId($task_id);
1224
1225        return $this->performRequest($endpoint);
1226    }
1227    /**
1228     * Allows to use the Mustache language to pre-render a search definition.
1229     *
1230     * $params['id']   = (string) The id of the stored search template
1231     * $params['body'] = (array) The search definition template and its params
1232     *
1233     * @param array $params Associative array of parameters
1234     * @return array
1235     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/render-search-template-api.html
1236     */
1237    public function renderSearchTemplate(array $params = [])
1238    {
1239        $id = $this->extractArgument($params, 'id');
1240        $body = $this->extractArgument($params, 'body');
1241
1242        $endpointBuilder = $this->endpoints;
1243        $endpoint = $endpointBuilder('RenderSearchTemplate');
1244        $endpoint->setParams($params);
1245        $endpoint->setId($id);
1246        $endpoint->setBody($body);
1247
1248        return $this->performRequest($endpoint);
1249    }
1250    /**
1251     * Allows an arbitrary script to be executed and a result to be returned
1252     *
1253     * $params['body'] = (array) The script to execute
1254     *
1255     * @param array $params Associative array of parameters
1256     * @return array
1257     * @see https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html
1258     *
1259     * @note This API is EXPERIMENTAL and may be changed or removed completely in a future release
1260     *
1261     */
1262    public function scriptsPainlessExecute(array $params = [])
1263    {
1264        $body = $this->extractArgument($params, 'body');
1265
1266        $endpointBuilder = $this->endpoints;
1267        $endpoint = $endpointBuilder('ScriptsPainlessExecute');
1268        $endpoint->setParams($params);
1269        $endpoint->setBody($body);
1270
1271        return $this->performRequest($endpoint);
1272    }
1273    /**
1274     * Allows to retrieve a large numbers of results from a single search request.
1275     *
1276     * $params['scroll_id']              = DEPRECATED (string) The scroll ID
1277     * $params['scroll']                 = (time) Specify how long a consistent view of the index should be maintained for scrolled search
1278     * $params['rest_total_hits_as_int'] = (boolean) Indicates whether hits.total should be rendered as an integer or an object in the rest search response (Default = false)
1279     * $params['body']                   = (array) The scroll ID if not passed by URL or query parameter.
1280     *
1281     * @param array $params Associative array of parameters
1282     * @return array
1283     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll
1284     */
1285    public function scroll(array $params = [])
1286    {
1287        $scroll_id = $this->extractArgument($params, 'scroll_id');
1288        $body = $this->extractArgument($params, 'body');
1289
1290        $endpointBuilder = $this->endpoints;
1291        $endpoint = $endpointBuilder('Scroll');
1292        $endpoint->setParams($params);
1293        $endpoint->setScrollId($scroll_id);
1294        $endpoint->setBody($body);
1295
1296        return $this->performRequest($endpoint);
1297    }
1298    /**
1299     * Returns results matching a query.
1300     *
1301     * $params['index']                         = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
1302     * $params['type']                          = DEPRECATED (list) A comma-separated list of document types to search; leave empty to perform the operation on all types
1303     * $params['analyzer']                      = (string) The analyzer to use for the query string
1304     * $params['analyze_wildcard']              = (boolean) Specify whether wildcard and prefix queries should be analyzed (default: false)
1305     * $params['ccs_minimize_roundtrips']       = (boolean) Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution (Default = true)
1306     * $params['default_operator']              = (enum) The default operator for query string query (AND or OR) (Options = AND,OR) (Default = OR)
1307     * $params['df']                            = (string) The field to use as default where no field prefix is given in the query string
1308     * $params['explain']                       = (boolean) Specify whether to return detailed information about score computation as part of a hit
1309     * $params['stored_fields']                 = (list) A comma-separated list of stored fields to return as part of a hit
1310     * $params['docvalue_fields']               = (list) A comma-separated list of fields to return as the docvalue representation of a field for each hit
1311     * $params['from']                          = (number) Starting offset (default: 0)
1312     * $params['ignore_unavailable']            = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1313     * $params['ignore_throttled']              = (boolean) Whether specified concrete, expanded or aliased indices should be ignored when throttled
1314     * $params['allow_no_indices']              = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
1315     * $params['expand_wildcards']              = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
1316     * $params['lenient']                       = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
1317     * $params['preference']                    = (string) Specify the node or shard the operation should be performed on (default: random)
1318     * $params['q']                             = (string) Query in the Lucene query string syntax
1319     * $params['routing']                       = (list) A comma-separated list of specific routing values
1320     * $params['scroll']                        = (time) Specify how long a consistent view of the index should be maintained for scrolled search
1321     * $params['search_type']                   = (enum) Search operation type (Options = query_then_fetch,dfs_query_then_fetch)
1322     * $params['size']                          = (number) Number of hits to return (default: 10)
1323     * $params['sort']                          = (list) A comma-separated list of <field>:<direction> pairs
1324     * $params['_source']                       = (list) True or false to return the _source field or not, or a list of fields to return
1325     * $params['_source_excludes']              = (list) A list of fields to exclude from the returned _source field
1326     * $params['_source_includes']              = (list) A list of fields to extract and return from the _source field
1327     * $params['terminate_after']               = (number) The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
1328     * $params['stats']                         = (list) Specific 'tag' of the request for logging and statistical purposes
1329     * $params['suggest_field']                 = (string) Specify which field to use for suggestions
1330     * $params['suggest_mode']                  = (enum) Specify suggest mode (Options = missing,popular,always) (Default = missing)
1331     * $params['suggest_size']                  = (number) How many suggestions to return in response
1332     * $params['suggest_text']                  = (string) The source text for which the suggestions should be returned
1333     * $params['timeout']                       = (time) Explicit operation timeout
1334     * $params['track_scores']                  = (boolean) Whether to calculate and return scores even if they are not used for sorting
1335     * $params['track_total_hits']              = (boolean) Indicate if the number of documents that match the query should be tracked
1336     * $params['allow_partial_search_results']  = (boolean) Indicate if an error should be returned if there is a partial search failure or timeout (Default = true)
1337     * $params['typed_keys']                    = (boolean) Specify whether aggregation and suggester names should be prefixed by their respective types in the response
1338     * $params['version']                       = (boolean) Specify whether to return document version as part of a hit
1339     * $params['seq_no_primary_term']           = (boolean) Specify whether to return sequence number and primary term of the last modification of each hit
1340     * $params['request_cache']                 = (boolean) Specify if request cache should be used for this request or not, defaults to index level setting
1341     * $params['batched_reduce_size']           = (number) 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. (Default = 512)
1342     * $params['max_concurrent_shard_requests'] = (number) 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 (Default = 5)
1343     * $params['pre_filter_shard_size']         = (number) A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
1344     * $params['rest_total_hits_as_int']        = (boolean) Indicates whether hits.total should be rendered as an integer or an object in the rest search response (Default = false)
1345     * $params['min_compatible_shard_node']     = (string) The minimum compatible version that all shards involved in search should have for this request to be successful
1346     * $params['body']                          = (array) The search definition using the Query DSL
1347     *
1348     * @param array $params Associative array of parameters
1349     * @return array
1350     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html
1351     */
1352    public function search(array $params = [])
1353    {
1354        $index = $this->extractArgument($params, 'index');
1355        $type = $this->extractArgument($params, 'type');
1356        $body = $this->extractArgument($params, 'body');
1357
1358        $endpointBuilder = $this->endpoints;
1359        $endpoint = $endpointBuilder('Search');
1360        $endpoint->setParams($params);
1361        $endpoint->setIndex($index);
1362        $endpoint->setType($type);
1363        $endpoint->setBody($body);
1364
1365        return $this->performRequest($endpoint);
1366    }
1367    /**
1368     * Searches a vector tile for geospatial values. Returns results as a binary Mapbox vector tile.
1369     *
1370     * $params['index']          = (list) Comma-separated list of data streams, indices, or aliases to search
1371     * $params['field']          = (string) Field containing geospatial data to return
1372     * $params['zoom']           = (int) Zoom level for the vector tile to search
1373     * $params['x']              = (int) X coordinate for the vector tile to search
1374     * $params['y']              = (int) Y coordinate for the vector tile to search
1375     * $params['exact_bounds']   = (boolean) If false, the meta layer's feature is the bounding box of the tile. If true, the meta layer's feature is a bounding box resulting from a `geo_bounds` aggregation. (Default = false)
1376     * $params['extent']         = (int) Size, in pixels, of a side of the vector tile. (Default = 4096)
1377     * $params['grid_precision'] = (int) Additional zoom levels available through the aggs layer. Accepts 0-8. (Default = 8)
1378     * $params['grid_type']      = (enum) Determines the geometry type for features in the aggs layer. (Options = grid,point) (Default = grid)
1379     * $params['size']           = (int) Maximum number of features to return in the hits layer. Accepts 0-10000. (Default = 10000)
1380     * $params['body']           = (array) Search request body.
1381     *
1382     * @param array $params Associative array of parameters
1383     * @return array
1384     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-vector-tile-api.html
1385     *
1386     * @note This API is EXPERIMENTAL and may be changed or removed completely in a future release
1387     *
1388     */
1389    public function searchMvt(array $params = [])
1390    {
1391        $index = $this->extractArgument($params, 'index');
1392        $field = $this->extractArgument($params, 'field');
1393        $zoom = $this->extractArgument($params, 'zoom');
1394        $x = $this->extractArgument($params, 'x');
1395        $y = $this->extractArgument($params, 'y');
1396        $body = $this->extractArgument($params, 'body');
1397
1398        $endpointBuilder = $this->endpoints;
1399        $endpoint = $endpointBuilder('SearchMvt');
1400        $endpoint->setParams($params);
1401        $endpoint->setIndex($index);
1402        $endpoint->setField($field);
1403        $endpoint->setZoom($zoom);
1404        $endpoint->setX($x);
1405        $endpoint->setY($y);
1406        $endpoint->setBody($body);
1407
1408        return $this->performRequest($endpoint);
1409    }
1410    /**
1411     * Returns information about the indices and shards that a search request would be executed against.
1412     *
1413     * $params['index']              = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
1414     * $params['preference']         = (string) Specify the node or shard the operation should be performed on (default: random)
1415     * $params['routing']            = (string) Specific routing value
1416     * $params['local']              = (boolean) Return local information, do not retrieve the state from master node (default: false)
1417     * $params['ignore_unavailable'] = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1418     * $params['allow_no_indices']   = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
1419     * $params['expand_wildcards']   = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
1420     *
1421     * @param array $params Associative array of parameters
1422     * @return array
1423     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html
1424     */
1425    public function searchShards(array $params = [])
1426    {
1427        $index = $this->extractArgument($params, 'index');
1428
1429        $endpointBuilder = $this->endpoints;
1430        $endpoint = $endpointBuilder('SearchShards');
1431        $endpoint->setParams($params);
1432        $endpoint->setIndex($index);
1433
1434        return $this->performRequest($endpoint);
1435    }
1436    /**
1437     * Allows to use the Mustache language to pre-render a search definition.
1438     *
1439     * $params['index']                   = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
1440     * $params['type']                    = DEPRECATED (list) A comma-separated list of document types to search; leave empty to perform the operation on all types
1441     * $params['ignore_unavailable']      = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1442     * $params['ignore_throttled']        = (boolean) Whether specified concrete, expanded or aliased indices should be ignored when throttled
1443     * $params['allow_no_indices']        = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
1444     * $params['expand_wildcards']        = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
1445     * $params['preference']              = (string) Specify the node or shard the operation should be performed on (default: random)
1446     * $params['routing']                 = (list) A comma-separated list of specific routing values
1447     * $params['scroll']                  = (time) Specify how long a consistent view of the index should be maintained for scrolled search
1448     * $params['search_type']             = (enum) Search operation type (Options = query_then_fetch,dfs_query_then_fetch)
1449     * $params['explain']                 = (boolean) Specify whether to return detailed information about score computation as part of a hit
1450     * $params['profile']                 = (boolean) Specify whether to profile the query execution
1451     * $params['typed_keys']              = (boolean) Specify whether aggregation and suggester names should be prefixed by their respective types in the response
1452     * $params['rest_total_hits_as_int']  = (boolean) Indicates whether hits.total should be rendered as an integer or an object in the rest search response (Default = false)
1453     * $params['ccs_minimize_roundtrips'] = (boolean) Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution (Default = true)
1454     * $params['body']                    = (array) The search definition template and its params (Required)
1455     *
1456     * @param array $params Associative array of parameters
1457     * @return array
1458     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
1459     */
1460    public function searchTemplate(array $params = [])
1461    {
1462        $index = $this->extractArgument($params, 'index');
1463        $type = $this->extractArgument($params, 'type');
1464        $body = $this->extractArgument($params, 'body');
1465
1466        $endpointBuilder = $this->endpoints;
1467        $endpoint = $endpointBuilder('SearchTemplate');
1468        $endpoint->setParams($params);
1469        $endpoint->setIndex($index);
1470        $endpoint->setType($type);
1471        $endpoint->setBody($body);
1472
1473        return $this->performRequest($endpoint);
1474    }
1475    /**
1476     * The terms enum API  can be used to discover terms in the index that begin with the provided string. It is designed for low-latency look-ups used in auto-complete scenarios.
1477     *
1478     * $params['index'] = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices
1479     * $params['body']  = (array) field name, string which is the prefix expected in matching terms, timeout and size for max number of results
1480     *
1481     * @param array $params Associative array of parameters
1482     * @return array
1483     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-terms-enum.html
1484     *
1485     * @note This API is BETA and may change in ways that are not backwards compatible
1486     *
1487     */
1488    public function termsEnum(array $params = [])
1489    {
1490        $index = $this->extractArgument($params, 'index');
1491        $body = $this->extractArgument($params, 'body');
1492
1493        $endpointBuilder = $this->endpoints;
1494        $endpoint = $endpointBuilder('TermsEnum');
1495        $endpoint->setParams($params);
1496        $endpoint->setIndex($index);
1497        $endpoint->setBody($body);
1498
1499        return $this->performRequest($endpoint);
1500    }
1501    /**
1502     * Returns information and statistics about terms in the fields of a particular document.
1503     *
1504     * $params['index']            = (string) The index in which the document resides. (Required)
1505     * $params['id']               = (string) The id of the document, when not specified a doc param should be supplied.
1506     * $params['type']             = DEPRECATED (string) The type of the document.
1507     * $params['term_statistics']  = (boolean) Specifies if total term frequency and document frequency should be returned. (Default = false)
1508     * $params['field_statistics'] = (boolean) Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. (Default = true)
1509     * $params['fields']           = (list) A comma-separated list of fields to return.
1510     * $params['offsets']          = (boolean) Specifies if term offsets should be returned. (Default = true)
1511     * $params['positions']        = (boolean) Specifies if term positions should be returned. (Default = true)
1512     * $params['payloads']         = (boolean) Specifies if term payloads should be returned. (Default = true)
1513     * $params['preference']       = (string) Specify the node or shard the operation should be performed on (default: random).
1514     * $params['routing']          = (string) Specific routing value.
1515     * $params['realtime']         = (boolean) Specifies if request is real-time as opposed to near-real-time (default: true).
1516     * $params['version']          = (number) Explicit version number for concurrency control
1517     * $params['version_type']     = (enum) Specific version type (Options = internal,external,external_gte,force)
1518     * $params['body']             = (array) Define parameters and or supply a document to get termvectors for. See documentation.
1519     *
1520     * @param array $params Associative array of parameters
1521     * @return array
1522     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html
1523     */
1524    public function termvectors(array $params = [])
1525    {
1526        $index = $this->extractArgument($params, 'index');
1527        $id = $this->extractArgument($params, 'id');
1528        $type = $this->extractArgument($params, 'type');
1529        $body = $this->extractArgument($params, 'body');
1530
1531        $endpointBuilder = $this->endpoints;
1532        $endpoint = $endpointBuilder('TermVectors');
1533        $endpoint->setParams($params);
1534        $endpoint->setIndex($index);
1535        $endpoint->setId($id);
1536        $endpoint->setType($type);
1537        $endpoint->setBody($body);
1538
1539        return $this->performRequest($endpoint);
1540    }
1541    /**
1542     * Updates a document with a script or partial document.
1543     *
1544     * $params['id']                     = (string) Document ID (Required)
1545     * $params['index']                  = (string) The name of the index (Required)
1546     * $params['type']                   = DEPRECATED (string) The type of the document
1547     * $params['wait_for_active_shards'] = (string) Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
1548     * $params['_source']                = (list) True or false to return the _source field or not, or a list of fields to return
1549     * $params['_source_excludes']       = (list) A list of fields to exclude from the returned _source field
1550     * $params['_source_includes']       = (list) A list of fields to extract and return from the _source field
1551     * $params['lang']                   = (string) The script language (default: painless)
1552     * $params['refresh']                = (enum) If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (Options = true,false,wait_for)
1553     * $params['retry_on_conflict']      = (number) Specify how many times should the operation be retried when a conflict occurs (default: 0)
1554     * $params['routing']                = (string) Specific routing value
1555     * $params['timeout']                = (time) Explicit operation timeout
1556     * $params['if_seq_no']              = (number) only perform the update operation if the last operation that has changed the document has the specified sequence number
1557     * $params['if_primary_term']        = (number) only perform the update operation if the last operation that has changed the document has the specified primary term
1558     * $params['require_alias']          = (boolean) When true, requires destination is an alias. Default is false
1559     * $params['body']                   = (array) The request definition requires either `script` or partial `doc` (Required)
1560     *
1561     * @param array $params Associative array of parameters
1562     * @return array
1563     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html
1564     */
1565    public function update(array $params = [])
1566    {
1567        $id = $this->extractArgument($params, 'id');
1568        $index = $this->extractArgument($params, 'index');
1569        $type = $this->extractArgument($params, 'type');
1570        $body = $this->extractArgument($params, 'body');
1571
1572        $endpointBuilder = $this->endpoints;
1573        $endpoint = $endpointBuilder('Update');
1574        $endpoint->setParams($params);
1575        $endpoint->setId($id);
1576        $endpoint->setIndex($index);
1577        $endpoint->setType($type);
1578        $endpoint->setBody($body);
1579
1580        return $this->performRequest($endpoint);
1581    }
1582    /**
1583     * Performs an update on every document in the index without changing the source,for example to pick up a mapping change.
1584     *
1585     * $params['index']                  = (list) A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (Required)
1586     * $params['type']                   = DEPRECATED (list) A comma-separated list of document types to search; leave empty to perform the operation on all types
1587     * $params['analyzer']               = (string) The analyzer to use for the query string
1588     * $params['analyze_wildcard']       = (boolean) Specify whether wildcard and prefix queries should be analyzed (default: false)
1589     * $params['default_operator']       = (enum) The default operator for query string query (AND or OR) (Options = AND,OR) (Default = OR)
1590     * $params['df']                     = (string) The field to use as default where no field prefix is given in the query string
1591     * $params['from']                   = (number) Starting offset (default: 0)
1592     * $params['ignore_unavailable']     = (boolean) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1593     * $params['allow_no_indices']       = (boolean) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
1594     * $params['conflicts']              = (enum) What to do when the update by query hits version conflicts? (Options = abort,proceed) (Default = abort)
1595     * $params['expand_wildcards']       = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. (Options = open,closed,hidden,none,all) (Default = open)
1596     * $params['lenient']                = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
1597     * $params['pipeline']               = (string) Ingest pipeline to set on index requests made by this action. (default: none)
1598     * $params['preference']             = (string) Specify the node or shard the operation should be performed on (default: random)
1599     * $params['q']                      = (string) Query in the Lucene query string syntax
1600     * $params['routing']                = (list) A comma-separated list of specific routing values
1601     * $params['scroll']                 = (time) Specify how long a consistent view of the index should be maintained for scrolled search
1602     * $params['search_type']            = (enum) Search operation type (Options = query_then_fetch,dfs_query_then_fetch)
1603     * $params['search_timeout']         = (time) Explicit timeout for each search request. Defaults to no timeout.
1604     * $params['size']                   = (number) Deprecated, please use `max_docs` instead
1605     * $params['max_docs']               = (number) Maximum number of documents to process (default: all documents)
1606     * $params['sort']                   = (list) A comma-separated list of <field>:<direction> pairs
1607     * $params['_source']                = (list) True or false to return the _source field or not, or a list of fields to return
1608     * $params['_source_excludes']       = (list) A list of fields to exclude from the returned _source field
1609     * $params['_source_includes']       = (list) A list of fields to extract and return from the _source field
1610     * $params['terminate_after']        = (number) The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
1611     * $params['stats']                  = (list) Specific 'tag' of the request for logging and statistical purposes
1612     * $params['version']                = (boolean) Specify whether to return document version as part of a hit
1613     * $params['version_type']           = (boolean) Should the document increment the version number (internal) on hit or not (reindex)
1614     * $params['request_cache']          = (boolean) Specify if request cache should be used for this request or not, defaults to index level setting
1615     * $params['refresh']                = (boolean) Should the affected indexes be refreshed?
1616     * $params['timeout']                = (time) Time each individual bulk request should wait for shards that are unavailable. (Default = 1m)
1617     * $params['wait_for_active_shards'] = (string) Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
1618     * $params['scroll_size']            = (number) Size on the scroll request powering the update by query (Default = 100)
1619     * $params['wait_for_completion']    = (boolean) Should the request should block until the update by query operation is complete. (Default = true)
1620     * $params['requests_per_second']    = (number) The throttle to set on this request in sub-requests per second. -1 means no throttle. (Default = 0)
1621     * $params['slices']                 = (number|string) The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. (Default = 1)
1622     * $params['body']                   = (array) The search definition using the Query DSL
1623     *
1624     * @param array $params Associative array of parameters
1625     * @return array
1626     * @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html
1627     */
1628    public function updateByQuery(array $params = [])
1629    {
1630        $index = $this->extractArgument($params, 'index');
1631        $type = $this->extractArgument($params, 'type');
1632        $body = $this->extractArgument($params, 'body');
1633
1634        $endpointBuilder = $this->endpoints;
1635        $endpoint = $endpointBuilder('UpdateByQuery');
1636        $endpoint->setParams($params);
1637        $endpoint->setIndex($index);
1638        $endpoint->setType($type);
1639        $endpoint->setBody($body);
1640
1641        return $this->performRequest($endpoint);
1642    }
1643    /**
1644     * Changes the number of requests per second for a particular Update By Query operation.
1645     *
1646     * $params['task_id']             = (string) The task id to rethrottle
1647     * $params['requests_per_second'] = (number) The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (Required)
1648     *
1649     * @param array $params Associative array of parameters
1650     * @return array
1651     * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
1652     */
1653    public function updateByQueryRethrottle(array $params = [])
1654    {
1655        $task_id = $this->extractArgument($params, 'task_id');
1656
1657        $endpointBuilder = $this->endpoints;
1658        $endpoint = $endpointBuilder('UpdateByQueryRethrottle');
1659        $endpoint->setParams($params);
1660        $endpoint->setTaskId($task_id);
1661
1662        return $this->performRequest($endpoint);
1663    }
1664    /**
1665     * Returns the asyncSearch namespace
1666     */
1667    public function asyncSearch(): AsyncSearchNamespace
1668    {
1669        return $this->asyncSearch;
1670    }
1671    /**
1672     * Returns the autoscaling namespace
1673     */
1674    public function autoscaling(): AutoscalingNamespace
1675    {
1676        return $this->autoscaling;
1677    }
1678    /**
1679     * Returns the cat namespace
1680     */
1681    public function cat(): CatNamespace
1682    {
1683        return $this->cat;
1684    }
1685    /**
1686     * Returns the ccr namespace
1687     */
1688    public function ccr(): CcrNamespace
1689    {
1690        return $this->ccr;
1691    }
1692    /**
1693     * Returns the cluster namespace
1694     */
1695    public function cluster(): ClusterNamespace
1696    {
1697        return $this->cluster;
1698    }
1699    /**
1700     * Returns the danglingIndices namespace
1701     */
1702    public function danglingIndices(): DanglingIndicesNamespace
1703    {
1704        return $this->danglingIndices;
1705    }
1706    /**
1707     * Returns the dataFrameTransformDeprecated namespace
1708     */
1709    public function dataFrameTransformDeprecated(): DataFrameTransformDeprecatedNamespace
1710    {
1711        return $this->dataFrameTransformDeprecated;
1712    }
1713    /**
1714     * Returns the enrich namespace
1715     */
1716    public function enrich(): EnrichNamespace
1717    {
1718        return $this->enrich;
1719    }
1720    /**
1721     * Returns the eql namespace
1722     */
1723    public function eql(): EqlNamespace
1724    {
1725        return $this->eql;
1726    }
1727    /**
1728     * Returns the features namespace
1729     */
1730    public function features(): FeaturesNamespace
1731    {
1732        return $this->features;
1733    }
1734    /**
1735     * Returns the fleet namespace
1736     */
1737    public function fleet(): FleetNamespace
1738    {
1739        return $this->fleet;
1740    }
1741    /**
1742     * Returns the graph namespace
1743     */
1744    public function graph(): GraphNamespace
1745    {
1746        return $this->graph;
1747    }
1748    /**
1749     * Returns the ilm namespace
1750     */
1751    public function ilm(): IlmNamespace
1752    {
1753        return $this->ilm;
1754    }
1755    /**
1756     * Returns the indices namespace
1757     */
1758    public function indices(): IndicesNamespace
1759    {
1760        return $this->indices;
1761    }
1762    /**
1763     * Returns the ingest namespace
1764     */
1765    public function ingest(): IngestNamespace
1766    {
1767        return $this->ingest;
1768    }
1769    /**
1770     * Returns the license namespace
1771     */
1772    public function license(): LicenseNamespace
1773    {
1774        return $this->license;
1775    }
1776    /**
1777     * Returns the logstash namespace
1778     */
1779    public function logstash(): LogstashNamespace
1780    {
1781        return $this->logstash;
1782    }
1783    /**
1784     * Returns the migration namespace
1785     */
1786    public function migration(): MigrationNamespace
1787    {
1788        return $this->migration;
1789    }
1790    /**
1791     * Returns the ml namespace
1792     */
1793    public function ml(): MlNamespace
1794    {
1795        return $this->ml;
1796    }
1797    /**
1798     * Returns the monitoring namespace
1799     */
1800    public function monitoring(): MonitoringNamespace
1801    {
1802        return $this->monitoring;
1803    }
1804    /**
1805     * Returns the nodes namespace
1806     */
1807    public function nodes(): NodesNamespace
1808    {
1809        return $this->nodes;
1810    }
1811    /**
1812     * Returns the rollup namespace
1813     */
1814    public function rollup(): RollupNamespace
1815    {
1816        return $this->rollup;
1817    }
1818    /**
1819     * Returns the searchableSnapshots namespace
1820     */
1821    public function searchableSnapshots(): SearchableSnapshotsNamespace
1822    {
1823        return $this->searchableSnapshots;
1824    }
1825    /**
1826     * Returns the security namespace
1827     */
1828    public function security(): SecurityNamespace
1829    {
1830        return $this->security;
1831    }
1832    /**
1833     * Returns the shutdown namespace
1834     */
1835    public function shutdown(): ShutdownNamespace
1836    {
1837        return $this->shutdown;
1838    }
1839    /**
1840     * Returns the slm namespace
1841     */
1842    public function slm(): SlmNamespace
1843    {
1844        return $this->slm;
1845    }
1846    /**
1847     * Returns the snapshot namespace
1848     */
1849    public function snapshot(): SnapshotNamespace
1850    {
1851        return $this->snapshot;
1852    }
1853    /**
1854     * Returns the sql namespace
1855     */
1856    public function sql(): SqlNamespace
1857    {
1858        return $this->sql;
1859    }
1860    /**
1861     * Returns the ssl namespace
1862     */
1863    public function ssl(): SslNamespace
1864    {
1865        return $this->ssl;
1866    }
1867    /**
1868     * Returns the tasks namespace
1869     */
1870    public function tasks(): TasksNamespace
1871    {
1872        return $this->tasks;
1873    }
1874    /**
1875     * Returns the textStructure namespace
1876     */
1877    public function textStructure(): TextStructureNamespace
1878    {
1879        return $this->textStructure;
1880    }
1881    /**
1882     * Returns the transform namespace
1883     */
1884    public function transform(): TransformNamespace
1885    {
1886        return $this->transform;
1887    }
1888    /**
1889     * Returns the watcher namespace
1890     */
1891    public function watcher(): WatcherNamespace
1892    {
1893        return $this->watcher;
1894    }
1895    /**
1896     * Returns the xpack namespace
1897     */
1898    public function xpack(): XpackNamespace
1899    {
1900        return $this->xpack;
1901    }
1902
1903    /**
1904     * Catchall for registered namespaces
1905     *
1906     * @return object
1907     * @throws BadMethodCallException if the namespace cannot be found
1908     */
1909    public function __call(string $name, array $arguments)
1910    {
1911        if (isset($this->registeredNamespaces[$name])) {
1912            return $this->registeredNamespaces[$name];
1913        }
1914        throw new BadMethodCallException("Namespace [$name] not found");
1915    }
1916
1917    /**
1918     * Extract an argument from the array of parameters
1919     *
1920     * @return null|mixed
1921     */
1922    public function extractArgument(array &$params, string $arg)
1923    {
1924        if (array_key_exists($arg, $params) === true) {
1925            $value = $params[$arg];
1926            $value = (is_object($value) && !is_iterable($value)) ?
1927                (array) $value :
1928                $value;
1929            unset($params[$arg]);
1930            return $value;
1931        } else {
1932            return null;
1933        }
1934    }
1935
1936    /**
1937     * @return callable|array
1938     */
1939    private function performRequest(AbstractEndpoint $endpoint)
1940    {
1941        $promise =  $this->transport->performRequest(
1942            $endpoint->getMethod(),
1943            $endpoint->getURI(),
1944            $endpoint->getParams(),
1945            $endpoint->getBody(),
1946            $endpoint->getOptions()
1947        );
1948
1949        return $this->transport->resultOrFuture($promise, $endpoint->getOptions());
1950    }
1951}
1952