1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * Copyright OpenSearch Contributors
7: * SPDX-License-Identifier: Apache-2.0
8: *
9: * OpenSearch PHP client
10: *
11: * @link https://github.com/opensearch-project/opensearch-php/
12: * @copyright Copyright (c) Elasticsearch B.V (https://www.elastic.co)
13: * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
14: * @license https://www.gnu.org/licenses/lgpl-2.1.html GNU Lesser General Public License, Version 2.1
15: *
16: * Licensed to Elasticsearch B.V under one or more agreements.
17: * Elasticsearch B.V licenses this file to you under the Apache 2.0 License or
18: * the GNU Lesser General Public License, Version 2.1, at your option.
19: * See the LICENSE file in the project root for more information.
20: */
21:
22: namespace OpenSearch;
23:
24: use OpenSearch\Endpoints\AbstractEndpoint;
25: use OpenSearch\Namespaces\BooleanRequestWrapper;
26: use OpenSearch\Namespaces\NamespaceBuilderInterface;
27: use OpenSearch\Namespaces\AsyncSearchNamespace;
28: use OpenSearch\Namespaces\AsynchronousSearchNamespace;
29: use OpenSearch\Namespaces\CatNamespace;
30: use OpenSearch\Namespaces\ClusterNamespace;
31: use OpenSearch\Namespaces\DanglingIndicesNamespace;
32: use OpenSearch\Namespaces\DataFrameTransformDeprecatedNamespace;
33: use OpenSearch\Namespaces\FlowFrameworkNamespace;
34: use OpenSearch\Namespaces\IndicesNamespace;
35: use OpenSearch\Namespaces\IngestNamespace;
36: use OpenSearch\Namespaces\InsightsNamespace;
37: use OpenSearch\Namespaces\IsmNamespace;
38: use OpenSearch\Namespaces\KnnNamespace;
39: use OpenSearch\Namespaces\ListNamespace;
40: use OpenSearch\Namespaces\LtrNamespace;
41: use OpenSearch\Namespaces\MlNamespace;
42: use OpenSearch\Namespaces\MonitoringNamespace;
43: use OpenSearch\Namespaces\NodesNamespace;
44: use OpenSearch\Namespaces\NotificationsNamespace;
45: use OpenSearch\Namespaces\ObservabilityNamespace;
46: use OpenSearch\Namespaces\PplNamespace;
47: use OpenSearch\Namespaces\QueryNamespace;
48: use OpenSearch\Namespaces\RemoteStoreNamespace;
49: use OpenSearch\Namespaces\ReplicationNamespace;
50: use OpenSearch\Namespaces\RollupsNamespace;
51: use OpenSearch\Namespaces\SearchPipelineNamespace;
52: use OpenSearch\Namespaces\SearchableSnapshotsNamespace;
53: use OpenSearch\Namespaces\SecurityNamespace;
54: use OpenSearch\Namespaces\SmNamespace;
55: use OpenSearch\Namespaces\SnapshotNamespace;
56: use OpenSearch\Namespaces\SqlNamespace;
57: use OpenSearch\Namespaces\SslNamespace;
58: use OpenSearch\Namespaces\TasksNamespace;
59: use OpenSearch\Namespaces\TransformsNamespace;
60: use OpenSearch\Namespaces\WlmNamespace;
61: use OpenSearch\Endpoints\Bulk;
62: use OpenSearch\Endpoints\BulkStream;
63: use OpenSearch\Endpoints\ClearScroll;
64: use OpenSearch\Endpoints\Count;
65: use OpenSearch\Endpoints\Create;
66: use OpenSearch\Endpoints\CreatePit;
67: use OpenSearch\Endpoints\Delete;
68: use OpenSearch\Endpoints\DeleteAllPits;
69: use OpenSearch\Endpoints\DeleteByQuery;
70: use OpenSearch\Endpoints\DeleteByQueryRethrottle;
71: use OpenSearch\Endpoints\DeletePit;
72: use OpenSearch\Endpoints\DeleteScript;
73: use OpenSearch\Endpoints\Exists;
74: use OpenSearch\Endpoints\ExistsSource;
75: use OpenSearch\Endpoints\Explain;
76: use OpenSearch\Endpoints\FieldCaps;
77: use OpenSearch\Endpoints\Get;
78: use OpenSearch\Endpoints\GetAllPits;
79: use OpenSearch\Endpoints\GetScript;
80: use OpenSearch\Endpoints\GetScriptContext;
81: use OpenSearch\Endpoints\GetScriptLanguages;
82: use OpenSearch\Endpoints\GetSource;
83: use OpenSearch\Endpoints\Index;
84: use OpenSearch\Endpoints\Info;
85: use OpenSearch\Endpoints\MTermVectors;
86: use OpenSearch\Endpoints\Mget;
87: use OpenSearch\Endpoints\Msearch;
88: use OpenSearch\Endpoints\MsearchTemplate;
89: use OpenSearch\Endpoints\Ping;
90: use OpenSearch\Endpoints\PutScript;
91: use OpenSearch\Endpoints\RankEval;
92: use OpenSearch\Endpoints\Reindex;
93: use OpenSearch\Endpoints\ReindexRethrottle;
94: use OpenSearch\Endpoints\RenderSearchTemplate;
95: use OpenSearch\Endpoints\ScriptsPainlessExecute;
96: use OpenSearch\Endpoints\Scroll;
97: use OpenSearch\Endpoints\Search;
98: use OpenSearch\Endpoints\SearchShards;
99: use OpenSearch\Endpoints\SearchTemplate;
100: use OpenSearch\Endpoints\TermVectors;
101: use OpenSearch\Endpoints\Update;
102: use OpenSearch\Endpoints\UpdateByQuery;
103: use OpenSearch\Endpoints\UpdateByQueryRethrottle;
104:
105: /**
106: * Class Client
107: *
108: * NOTE: This file is autogenerated using util/GenerateEndpoints.php
109: */
110: class Client
111: {
112: public const VERSION = '2.4.4';
113:
114: /**
115: * @var Transport
116: *
117: * @deprecated in 2.4.0 and will be removed in 3.0.0.
118: */
119: public $transport;
120:
121: private TransportInterface $httpTransport;
122:
123: /**
124: * @var array
125: */
126: protected $params;
127:
128: private EndpointFactoryInterface $endpointFactory;
129:
130: /**
131: * @var callable
132: *
133: * @deprecated in 2.4.0 and will be removed in 3.0.0.
134: */
135: protected $endpoints;
136:
137: /**
138: * @var NamespaceBuilderInterface[]
139: */
140: protected $registeredNamespaces = [];
141:
142: /**
143: * @var AsyncSearchNamespace
144: *
145: * @deprecated in 2.4.2 and will be removed in 3.0.0.
146: */
147: protected $asyncSearch;
148:
149: /**
150: * @var AsynchronousSearchNamespace
151: */
152: protected $asynchronousSearch;
153:
154: /**
155: * @var CatNamespace
156: */
157: protected $cat;
158:
159: /**
160: * @var ClusterNamespace
161: */
162: protected $cluster;
163:
164: /**
165: * @var DanglingIndicesNamespace
166: */
167: protected $danglingIndices;
168:
169: /**
170: * @var DataFrameTransformDeprecatedNamespace
171: *
172: * @deprecated in 2.4.2 and will be removed in 3.0.0.
173: */
174: protected $dataFrameTransformDeprecated;
175:
176: /**
177: * @var FlowFrameworkNamespace
178: */
179: protected $flowFramework;
180:
181: /**
182: * @var IndicesNamespace
183: */
184: protected $indices;
185:
186: /**
187: * @var IngestNamespace
188: */
189: protected $ingest;
190:
191: /**
192: * @var InsightsNamespace
193: */
194: protected $insights;
195:
196: /**
197: * @var IsmNamespace
198: */
199: protected $ism;
200:
201: /**
202: * @var KnnNamespace
203: */
204: protected $knn;
205:
206: /**
207: * @var ListNamespace
208: */
209: protected $list;
210:
211: /**
212: * @var LtrNamespace
213: */
214: protected $ltr;
215:
216: /**
217: * @var MlNamespace
218: */
219: protected $ml;
220:
221: /**
222: * @var MonitoringNamespace
223: *
224: * @deprecated in 2.4.2 and will be removed in 3.0.0.
225: */
226: protected $monitoring;
227:
228: /**
229: * @var NodesNamespace
230: */
231: protected $nodes;
232:
233: /**
234: * @var NotificationsNamespace
235: */
236: protected $notifications;
237:
238: /**
239: * @var ObservabilityNamespace
240: */
241: protected $observability;
242:
243: /**
244: * @var PplNamespace
245: */
246: protected $ppl;
247:
248: /**
249: * @var QueryNamespace
250: */
251: protected $query;
252:
253: /**
254: * @var RemoteStoreNamespace
255: */
256: protected $remoteStore;
257:
258: /**
259: * @var ReplicationNamespace
260: */
261: protected $replication;
262:
263: /**
264: * @var RollupsNamespace
265: */
266: protected $rollups;
267:
268: /**
269: * @var SearchPipelineNamespace
270: */
271: protected $searchPipeline;
272:
273: /**
274: * @var SearchableSnapshotsNamespace
275: *
276: * @deprecated in 2.4.2 and will be removed in 3.0.0.
277: */
278: protected $searchableSnapshots;
279:
280: /**
281: * @var SecurityNamespace
282: */
283: protected $security;
284:
285: /**
286: * @var SmNamespace
287: */
288: protected $sm;
289:
290: /**
291: * @var SnapshotNamespace
292: */
293: protected $snapshot;
294:
295: /**
296: * @var SqlNamespace
297: */
298: protected $sql;
299:
300: /**
301: * @var SslNamespace
302: *
303: * @deprecated in 2.4.2 and will be removed in 3.0.0.
304: */
305: protected $ssl;
306:
307: /**
308: * @var TasksNamespace
309: */
310: protected $tasks;
311:
312: /**
313: * @var TransformsNamespace
314: */
315: protected $transforms;
316:
317: /**
318: * @var WlmNamespace
319: */
320: protected $wlm;
321:
322: /**
323: * Client constructor
324: *
325: * @param TransportInterface|Transport $transport
326: * @param callable|EndpointFactoryInterface|null $endpointFactory
327: * @param NamespaceBuilderInterface[] $registeredNamespaces
328: *
329: * @phpstan-ignore parameter.deprecatedClass
330: */
331: public function __construct(
332: TransportInterface|Transport $transport,
333: callable|EndpointFactoryInterface|null $endpointFactory = null,
334: array $registeredNamespaces = [],
335: ) {
336: if (!$transport instanceof TransportInterface) {
337: @trigger_error('Passing an instance of \OpenSearch\Transport to ' . __METHOD__ . '() is deprecated in 2.4.0 and will be removed in 3.0.0. Pass an instance of \OpenSearch\TransportInterface instead.', E_USER_DEPRECATED);
338: // @phpstan-ignore property.deprecated
339: $this->transport = $transport;
340: // @phpstan-ignore new.deprecated
341: $this->httpTransport = new LegacyTransportWrapper($transport);
342: } else {
343: $this->httpTransport = $transport;
344: }
345:
346: if (is_callable($endpointFactory)) {
347: @trigger_error('Passing a callable as the $endpointFactory param in ' . __METHOD__ . ' is deprecated in 2.4.0 and will be removed in 3.0.0. Pass an instance of \OpenSearch\EndpointFactoryInterface instead.', E_USER_DEPRECATED);
348: $endpoints = $endpointFactory;
349: // @phpstan-ignore new.deprecated
350: $endpointFactory = new LegacyEndpointFactory($endpointFactory);
351: } else {
352: if ($endpointFactory === null) {
353: $endpointFactory = new EndpointFactory();
354: }
355: $endpoints = function ($c) use ($endpointFactory) {
356: @trigger_error('The $endpoints property is deprecated in 2.4.0 and will be removed in 3.0.0.', E_USER_DEPRECATED);
357: return $endpointFactory->getEndpoint('OpenSearch\\Endpoints\\' . $c);
358: };
359: }
360:
361: // @phpstan-ignore property.deprecated
362: $this->endpoints = $endpoints;
363: $this->endpointFactory = $endpointFactory;
364: // @phpstan-ignore new.deprecated, property.deprecated
365: $this->asyncSearch = new AsyncSearchNamespace($transport, $this->endpointFactory);
366: $this->asynchronousSearch = new AsynchronousSearchNamespace($transport, $this->endpointFactory);
367: $this->cat = new CatNamespace($transport, $this->endpointFactory);
368: $this->cluster = new ClusterNamespace($transport, $this->endpointFactory);
369: $this->danglingIndices = new DanglingIndicesNamespace($transport, $this->endpointFactory);
370: // @phpstan-ignore new.deprecated, property.deprecated
371: $this->dataFrameTransformDeprecated = new DataFrameTransformDeprecatedNamespace($transport, $this->endpointFactory);
372: $this->flowFramework = new FlowFrameworkNamespace($transport, $this->endpointFactory);
373: $this->indices = new IndicesNamespace($transport, $this->endpointFactory);
374: $this->ingest = new IngestNamespace($transport, $this->endpointFactory);
375: $this->insights = new InsightsNamespace($transport, $this->endpointFactory);
376: $this->ism = new IsmNamespace($transport, $this->endpointFactory);
377: $this->knn = new KnnNamespace($transport, $this->endpointFactory);
378: $this->list = new ListNamespace($transport, $this->endpointFactory);
379: $this->ltr = new LtrNamespace($transport, $this->endpointFactory);
380: $this->ml = new MlNamespace($transport, $this->endpointFactory);
381: // @phpstan-ignore new.deprecated, property.deprecated
382: $this->monitoring = new MonitoringNamespace($transport, $this->endpointFactory);
383: $this->nodes = new NodesNamespace($transport, $this->endpointFactory);
384: $this->notifications = new NotificationsNamespace($transport, $this->endpointFactory);
385: $this->observability = new ObservabilityNamespace($transport, $this->endpointFactory);
386: $this->ppl = new PplNamespace($transport, $this->endpointFactory);
387: $this->query = new QueryNamespace($transport, $this->endpointFactory);
388: $this->remoteStore = new RemoteStoreNamespace($transport, $this->endpointFactory);
389: $this->replication = new ReplicationNamespace($transport, $this->endpointFactory);
390: $this->rollups = new RollupsNamespace($transport, $this->endpointFactory);
391: $this->searchPipeline = new SearchPipelineNamespace($transport, $this->endpointFactory);
392: // @phpstan-ignore new.deprecated, property.deprecated
393: $this->searchableSnapshots = new SearchableSnapshotsNamespace($transport, $this->endpointFactory);
394: $this->security = new SecurityNamespace($transport, $this->endpointFactory);
395: $this->sm = new SmNamespace($transport, $this->endpointFactory);
396: $this->snapshot = new SnapshotNamespace($transport, $this->endpointFactory);
397: $this->sql = new SqlNamespace($transport, $this->endpointFactory);
398: // @phpstan-ignore new.deprecated, property.deprecated
399: $this->ssl = new SslNamespace($transport, $this->endpointFactory);
400: $this->tasks = new TasksNamespace($transport, $this->endpointFactory);
401: $this->transforms = new TransformsNamespace($transport, $this->endpointFactory);
402: $this->wlm = new WlmNamespace($transport, $this->endpointFactory);
403:
404: $this->registeredNamespaces = $registeredNamespaces;
405: }
406:
407: /**
408: * Allows to perform multiple index/update/delete operations in a single request.
409: *
410: * $params['index'] = (string) Name of the data stream, index, or index alias to perform bulk actions on.
411: * $params['_source'] = (any) `true` or `false` to return the `_source` field or not, or a list of fields to return.
412: * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude from the response.
413: * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.
414: * $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter.
415: * $params['refresh'] = (any) If `true`, OpenSearch refreshes 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` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
416: * $params['require_alias'] = (boolean) If `true`, the request's actions must target an index alias. (Default = false)
417: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
418: * $params['timeout'] = (string) Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.
419: * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
420: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
421: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
422: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
423: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
424: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
425: * $params['body'] = (array) The operation definition and data (action-data pairs), separated by newlines (Required)
426: *
427: * @param array $params Associative array of parameters
428: * @return array
429: */
430: public function bulk(array $params = [])
431: {
432: $index = $this->extractArgument($params, 'index');
433: $body = $this->extractArgument($params, 'body');
434:
435: $endpoint = $this->endpointFactory->getEndpoint(Bulk::class);
436: $endpoint->setParams($params);
437: $endpoint->setIndex($index);
438: $endpoint->setBody($body);
439:
440: return $this->performRequest($endpoint);
441: }
442:
443: /**
444: * Allows to perform multiple index/update/delete operations using request response streaming.
445: *
446: * $params['index'] = (string) Name of the data stream, index, or index alias to perform bulk actions on.
447: * $params['_source'] = (any) `true` or `false` to return the `_source` field or not, or a list of fields to return.
448: * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude from the response.
449: * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.
450: * $params['batch_interval'] = (string) Specifies for how long bulk operations should be accumulated into a batch before sending the batch to data nodes.
451: * $params['batch_size'] = (integer) Specifies how many bulk operations should be accumulated into a batch before sending the batch to data nodes.
452: * $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter.
453: * $params['refresh'] = (any) If `true`, OpenSearch refreshes 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` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
454: * $params['require_alias'] = (boolean) If `true`, the request's actions must target an index alias. (Default = false)
455: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
456: * $params['timeout'] = (string) Period each action waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.
457: * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
458: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
459: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
460: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
461: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
462: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
463: * $params['body'] = (array) The operation definition and data (action-data pairs), separated by newlines (Required)
464: *
465: * @param array $params Associative array of parameters
466: * @return array
467: */
468: public function bulkStream(array $params = [])
469: {
470: $index = $this->extractArgument($params, 'index');
471: $body = $this->extractArgument($params, 'body');
472:
473: $endpoint = $this->endpointFactory->getEndpoint(BulkStream::class);
474: $endpoint->setParams($params);
475: $endpoint->setIndex($index);
476: $endpoint->setBody($body);
477:
478: return $this->performRequest($endpoint);
479: }
480:
481: /**
482: * Explicitly clears the search context for a scroll.
483: *
484: * $params['scroll_id'] = DEPRECATED (array) Comma-separated list of scroll IDs to clear. To clear all scroll IDs, use `_all`.
485: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
486: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
487: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
488: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
489: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
490: * $params['body'] = (array) Comma-separated list of scroll IDs to clear if none was specified using the `scroll_id` parameter
491: *
492: * @param array $params Associative array of parameters
493: * @return array
494: */
495: public function clearScroll(array $params = [])
496: {
497: $scroll_id = $this->extractArgument($params, 'scroll_id');
498: $body = $this->extractArgument($params, 'body');
499:
500: $endpoint = $this->endpointFactory->getEndpoint(ClearScroll::class);
501: $endpoint->setParams($params);
502: $endpoint->setScrollId($scroll_id);
503: $endpoint->setBody($body);
504:
505: return $this->performRequest($endpoint);
506: }
507:
508: /**
509: * Returns number of documents matching a query.
510: *
511: * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams and indexes, omit this parameter or use `*` or `_all`.
512: * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.
513: * $params['analyze_wildcard'] = (boolean) If `true`, wildcard and prefix queries are analyzed.This parameter can only be used when the `q` query string parameter is specified. (Default = false)
514: * $params['analyzer'] = (string) Analyzer to use for the query string.This parameter can only be used when the `q` query string parameter is specified.
515: * $params['default_operator'] = (enum) The default operator for query string query: `AND` or `OR`.This parameter can only be used when the `q` query string parameter is specified. (Options = and,AND,or,OR)
516: * $params['df'] = (string) Field to use as default where no field prefix is given in the query string.This parameter can only be used when the `q` query string parameter is specified.
517: * $params['expand_wildcards'] = (any)
518: * $params['ignore_throttled'] = (boolean) If `true`, concrete, expanded or aliased indexes are ignored when frozen.
519: * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index.
520: * $params['lenient'] = (boolean) If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.
521: * $params['min_score'] = (number) Sets the minimum `_score` value that documents must have to be included in the result.
522: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
523: * $params['q'] = (string) Query in the Lucene query string syntax.
524: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
525: * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.
526: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
527: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
528: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
529: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
530: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
531: * $params['body'] = (array) Query to restrict the results specified with the Query DSL (optional)
532: *
533: * @param array $params Associative array of parameters
534: * @return array
535: */
536: public function count(array $params = [])
537: {
538: $index = $this->extractArgument($params, 'index');
539: $body = $this->extractArgument($params, 'body');
540:
541: $endpoint = $this->endpointFactory->getEndpoint(Count::class);
542: $endpoint->setParams($params);
543: $endpoint->setIndex($index);
544: $endpoint->setBody($body);
545:
546: return $this->performRequest($endpoint);
547: }
548:
549: /**
550: * Creates point in time context.
551: *
552: * $params['index'] = (array) Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. (Required)
553: * $params['allow_partial_pit_creation'] = (boolean) Allow if point in time can be created with partial failures.
554: * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both.
555: * $params['keep_alive'] = (string) Specify the keep alive for point in time.
556: * $params['preference'] = (string) Specify the node or shard the operation should be performed on. (Default = random)
557: * $params['routing'] = (any) Comma-separated list of specific routing values.
558: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
559: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
560: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
561: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
562: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
563: *
564: * @param array $params Associative array of parameters
565: * @return array
566: */
567: public function createPit(array $params = [])
568: {
569: $index = $this->extractArgument($params, 'index');
570:
571: $endpoint = $this->endpointFactory->getEndpoint(CreatePit::class);
572: $endpoint->setParams($params);
573: $endpoint->setIndex($index);
574:
575: return $this->performRequest($endpoint);
576: }
577:
578: /**
579: * Removes a document from the index.
580: *
581: * $params['id'] = (string) Unique identifier for the document. (Required)
582: * $params['index'] = (string) Name of the target index. (Required)
583: * $params['if_primary_term'] = (integer) Only perform the operation if the document has this primary term.
584: * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number.
585: * $params['refresh'] = (any) If `true`, OpenSearch refreshes 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` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
586: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
587: * $params['timeout'] = (string) Period to wait for active shards.
588: * $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
589: * $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal)
590: * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
591: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
592: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
593: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
594: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
595: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
596: *
597: * @param array $params Associative array of parameters
598: * @return array
599: */
600: public function delete(array $params = [])
601: {
602: $id = $this->extractArgument($params, 'id');
603: $index = $this->extractArgument($params, 'index');
604:
605: $endpoint = $this->endpointFactory->getEndpoint(Delete::class);
606: $endpoint->setParams($params);
607: $endpoint->setId($id);
608: $endpoint->setIndex($index);
609:
610: return $this->performRequest($endpoint);
611: }
612:
613: /**
614: * Deletes all active point in time searches.
615: *
616: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
617: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
618: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
619: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
620: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
621: *
622: * @param array $params Associative array of parameters
623: * @return array
624: */
625: public function deleteAllPits(array $params = [])
626: {
627: $endpoint = $this->endpointFactory->getEndpoint(DeleteAllPits::class);
628: $endpoint->setParams($params);
629:
630: return $this->performRequest($endpoint);
631: }
632:
633: /**
634: * Deletes documents matching the provided query.
635: *
636: * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. (Required)
637: * $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
638: * $params['_source_excludes'] = (array) List of fields to exclude from the returned `_source` field.
639: * $params['_source_includes'] = (array) List of fields to extract and return from the `_source` field.
640: * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.
641: * $params['analyze_wildcard'] = (boolean) If `true`, wildcard and prefix queries are analyzed. (Default = false)
642: * $params['analyzer'] = (string) Analyzer to use for the query string.
643: * $params['conflicts'] = (enum) What to do if delete by query hits version conflicts: `abort` or `proceed`. (Options = abort,proceed)
644: * $params['default_operator'] = (enum) The default operator for query string query: `AND` or `OR`. (Options = and,AND,or,OR)
645: * $params['df'] = (string) Field to use as default where no field prefix is given in the query string.
646: * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`. Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
647: * $params['from'] = (integer) Starting offset. (Default = 0)
648: * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index.
649: * $params['lenient'] = (boolean) If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.
650: * $params['max_docs'] = (integer) Maximum number of documents to process.Defaults to all documents.
651: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
652: * $params['q'] = (string) Query in the Lucene query string syntax.
653: * $params['refresh'] = (any) If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes.
654: * $params['request_cache'] = (boolean) If `true`, the request cache is used for this request.Defaults to the index-level setting.
655: * $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second. (Default = 0)
656: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
657: * $params['scroll'] = (string) Period to retain the search context for scrolling.
658: * $params['scroll_size'] = (integer) Size of the scroll request that powers the operation. (Default = 100)
659: * $params['search_timeout'] = (string) Explicit timeout for each search request.Defaults to no timeout.
660: * $params['search_type'] = (any) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`.
661: * $params['size'] = (integer) Deprecated, use `max_docs` instead.
662: * $params['slices'] = (any) The number of slices this task should be divided into.
663: * $params['sort'] = (array) A comma-separated list of <field>:<direction> pairs.
664: * $params['stats'] = (array) Specific `tag` of the request for logging and statistical purposes.
665: * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.Use with caution.OpenSearch applies this parameter to each shard handling the request.When possible, let OpenSearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers.
666: * $params['timeout'] = (string) Period each deletion request waits for active shards.
667: * $params['version'] = (boolean) If `true`, returns the document version as part of a hit.
668: * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
669: * $params['wait_for_completion'] = (boolean) If `true`, the request blocks until the operation is complete. (Default = true)
670: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
671: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
672: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
673: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
674: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
675: * $params['body'] = (array) The search definition using the Query DSL (Required)
676: *
677: * @param array $params Associative array of parameters
678: * @return array
679: */
680: public function deleteByQuery(array $params = [])
681: {
682: $index = $this->extractArgument($params, 'index');
683: $body = $this->extractArgument($params, 'body');
684:
685: $endpoint = $this->endpointFactory->getEndpoint(DeleteByQuery::class);
686: $endpoint->setParams($params);
687: $endpoint->setIndex($index);
688: $endpoint->setBody($body);
689:
690: return $this->performRequest($endpoint);
691: }
692:
693: /**
694: * Changes the number of requests per second for a particular Delete By Query operation.
695: *
696: * $params['task_id'] = (string) The ID for the task. (Required)
697: * $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second.
698: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
699: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
700: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
701: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
702: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
703: *
704: * @param array $params Associative array of parameters
705: * @return array
706: */
707: public function deleteByQueryRethrottle(array $params = [])
708: {
709: $task_id = $this->extractArgument($params, 'task_id');
710:
711: $endpoint = $this->endpointFactory->getEndpoint(DeleteByQueryRethrottle::class);
712: $endpoint->setParams($params);
713: $endpoint->setTaskId($task_id);
714:
715: return $this->performRequest($endpoint);
716: }
717:
718: /**
719: * Deletes one or more point in time searches based on the IDs passed.
720: *
721: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
722: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
723: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
724: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
725: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
726: * $params['body'] = (array) The point-in-time ids to be deleted
727: *
728: * @param array $params Associative array of parameters
729: * @return array
730: */
731: public function deletePit(array $params = [])
732: {
733: $body = $this->extractArgument($params, 'body');
734:
735: $endpoint = $this->endpointFactory->getEndpoint(DeletePit::class);
736: $endpoint->setParams($params);
737: $endpoint->setBody($body);
738:
739: return $this->performRequest($endpoint);
740: }
741:
742: /**
743: * Deletes a script.
744: *
745: * $params['id'] = (string) Identifier for the stored script or search template. (Required)
746: * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node.
747: * $params['master_timeout'] = (string) Period to wait for a connection to the cluster-manager node.If no response is received before the timeout expires, the request fails and returns an error.
748: * $params['timeout'] = (string) Period to wait for a response.If no response is received before the timeout expires, the request fails and returns an error.
749: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
750: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
751: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
752: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
753: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
754: *
755: * @param array $params Associative array of parameters
756: * @return array
757: */
758: public function deleteScript(array $params = [])
759: {
760: $id = $this->extractArgument($params, 'id');
761:
762: $endpoint = $this->endpointFactory->getEndpoint(DeleteScript::class);
763: $endpoint->setParams($params);
764: $endpoint->setId($id);
765:
766: return $this->performRequest($endpoint);
767: }
768:
769: /**
770: * Returns information about whether a document exists in an index.
771: *
772: * $params['id'] = (string) Identifier of the document. (Required)
773: * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). (Required)
774: * $params['_source'] = (any) `true` or `false` to return the `_source` field or not, or a list of fields to return.
775: * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude in the response.
776: * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.
777: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
778: * $params['realtime'] = (boolean) If `true`, the request is real-time as opposed to near-real-time.
779: * $params['refresh'] = (any) If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes.
780: * $params['routing'] = (any) Target the specified primary shard.
781: * $params['stored_fields'] = (any) List of stored fields to return as part of a hit.If no fields are specified, no stored fields are included in the response.If this field is specified, the `_source` parameter defaults to false.
782: * $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
783: * $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal)
784: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
785: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
786: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
787: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
788: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
789: *
790: * @param array $params Associative array of parameters
791: * @return bool
792: */
793: public function exists(array $params = []): bool
794: {
795: $id = $this->extractArgument($params, 'id');
796: $index = $this->extractArgument($params, 'index');
797:
798: // Legacy option to manually make this verbose so we can check status code.
799: // @todo remove in 3.0.0
800: $params['client']['verbose'] = true;
801:
802: $endpoint = $this->endpointFactory->getEndpoint(Exists::class);
803: $endpoint->setParams($params);
804: $endpoint->setId($id);
805: $endpoint->setIndex($index);
806:
807: return BooleanRequestWrapper::sendRequest($endpoint, $this->httpTransport);
808: }
809:
810: /**
811: * Returns information about whether a document source exists in an index.
812: *
813: * $params['id'] = (string) Identifier of the document. (Required)
814: * $params['index'] = (string) Comma-separated list of data streams, indexes, and aliases. Supports wildcards (`*`). (Required)
815: * $params['_source'] = (any) `true` or `false` to return the `_source` field or not, or a list of fields to return.
816: * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude in the response.
817: * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.
818: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
819: * $params['realtime'] = (boolean) If `true`, the request is real-time as opposed to near-real-time.
820: * $params['refresh'] = (any) If `true`, OpenSearch refreshes all shards involved in the delete by query after the request completes.
821: * $params['routing'] = (any) Target the specified primary shard.
822: * $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
823: * $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal)
824: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
825: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
826: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
827: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
828: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
829: *
830: * @param array $params Associative array of parameters
831: * @return bool
832: */
833: public function existsSource(array $params = []): bool
834: {
835: $id = $this->extractArgument($params, 'id');
836: $index = $this->extractArgument($params, 'index');
837:
838: // Legacy option to manually make this verbose so we can check status code.
839: // @todo remove in 3.0.0
840: $params['client']['verbose'] = true;
841:
842: $endpoint = $this->endpointFactory->getEndpoint(ExistsSource::class);
843: $endpoint->setParams($params);
844: $endpoint->setId($id);
845: $endpoint->setIndex($index);
846:
847: return BooleanRequestWrapper::sendRequest($endpoint, $this->httpTransport);
848: }
849:
850: /**
851: * Returns information about why a specific matches (or doesn't match) a query.
852: *
853: * $params['id'] = (string) Defines the document ID. (Required)
854: * $params['index'] = (string) Index names used to limit the request. Only a single index name can be provided to this parameter. (Required)
855: * $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
856: * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude from the response.
857: * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.
858: * $params['analyze_wildcard'] = (boolean) If `true`, wildcard and prefix queries are analyzed. (Default = false)
859: * $params['analyzer'] = (string) Analyzer to use for the query string.This parameter can only be used when the `q` query string parameter is specified.
860: * $params['default_operator'] = (enum) The default operator for query string query: `AND` or `OR`. (Options = and,AND,or,OR)
861: * $params['df'] = (string) Field to use as default where no field prefix is given in the query string. (Default = _all)
862: * $params['lenient'] = (boolean) If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.
863: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
864: * $params['q'] = (string) Query in the Lucene query string syntax.
865: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
866: * $params['stored_fields'] = (any) A comma-separated list of stored fields to return in the response.
867: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
868: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
869: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
870: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
871: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
872: * $params['body'] = (array) The query definition using the Query DSL
873: *
874: * @param array $params Associative array of parameters
875: * @return array
876: */
877: public function explain(array $params = [])
878: {
879: $id = $this->extractArgument($params, 'id');
880: $index = $this->extractArgument($params, 'index');
881: $body = $this->extractArgument($params, 'body');
882:
883: $endpoint = $this->endpointFactory->getEndpoint(Explain::class);
884: $endpoint->setParams($params);
885: $endpoint->setId($id);
886: $endpoint->setIndex($index);
887: $endpoint->setBody($body);
888:
889: return $this->performRequest($endpoint);
890: }
891:
892: /**
893: * Returns the information about the capabilities of fields among multiple indexes.
894: *
895: * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indexes, omit this parameter or use * or `_all`.
896: * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias,or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a requesttargeting `foo*,bar*` returns an error if an index starts with foo but no index starts with bar.
897: * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as `open,hidden`.
898: * $params['fields'] = (any) Comma-separated list of fields to retrieve capabilities for. Wildcard (`*`) expressions are supported.
899: * $params['ignore_unavailable'] = (boolean) If `true`, missing or closed indexes are not included in the response.
900: * $params['include_unmapped'] = (boolean) If `true`, unmapped fields are included in the response. (Default = false)
901: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
902: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
903: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
904: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
905: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
906: * $params['body'] = (array) An index filter specified with the Query DSL
907: *
908: * @param array $params Associative array of parameters
909: * @return array
910: */
911: public function fieldCaps(array $params = [])
912: {
913: $index = $this->extractArgument($params, 'index');
914: $body = $this->extractArgument($params, 'body');
915:
916: $endpoint = $this->endpointFactory->getEndpoint(FieldCaps::class);
917: $endpoint->setParams($params);
918: $endpoint->setIndex($index);
919: $endpoint->setBody($body);
920:
921: return $this->performRequest($endpoint);
922: }
923:
924: /**
925: * Returns a document.
926: *
927: * $params['id'] = (string) Unique identifier of the document. (Required)
928: * $params['index'] = (string) Name of the index that contains the document. (Required)
929: * $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
930: * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude in the response.
931: * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.
932: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on. Random by default. (Default = random)
933: * $params['realtime'] = (boolean) If `true`, the request is real-time as opposed to near-real-time.
934: * $params['refresh'] = (any) If `true`, OpenSearch refreshes the affected shards to make this operation visible to search. If `false`, do nothing with refreshes.
935: * $params['routing'] = (any) Target the specified primary shard.
936: * $params['stored_fields'] = (any) List of stored fields to return as part of a hit.If no fields are specified, no stored fields are included in the response.If this field is specified, the `_source` parameter defaults to false.
937: * $params['version'] = (integer) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
938: * $params['version_type'] = (enum) Specific version type: `internal`, `external`, `external_gte`. (Options = external,external_gte,force,internal)
939: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
940: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
941: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
942: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
943: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
944: *
945: * @param array $params Associative array of parameters
946: * @return array
947: */
948: public function get(array $params = [])
949: {
950: $id = $this->extractArgument($params, 'id');
951: $index = $this->extractArgument($params, 'index');
952:
953: $endpoint = $this->endpointFactory->getEndpoint(Get::class);
954: $endpoint->setParams($params);
955: $endpoint->setId($id);
956: $endpoint->setIndex($index);
957:
958: return $this->performRequest($endpoint);
959: }
960:
961: /**
962: * Lists all active point in time searches.
963: *
964: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
965: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
966: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
967: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
968: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
969: *
970: * @param array $params Associative array of parameters
971: * @return array
972: */
973: public function getAllPits(array $params = [])
974: {
975: $endpoint = $this->endpointFactory->getEndpoint(GetAllPits::class);
976: $endpoint->setParams($params);
977:
978: return $this->performRequest($endpoint);
979: }
980:
981: /**
982: * Returns a script.
983: *
984: * $params['id'] = (string) Identifier for the stored script or search template. (Required)
985: * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node.
986: * $params['master_timeout'] = (string) Specify timeout for connection to master
987: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
988: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
989: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
990: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
991: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
992: *
993: * @param array $params Associative array of parameters
994: * @return array
995: */
996: public function getScript(array $params = [])
997: {
998: $id = $this->extractArgument($params, 'id');
999:
1000: $endpoint = $this->endpointFactory->getEndpoint(GetScript::class);
1001: $endpoint->setParams($params);
1002: $endpoint->setId($id);
1003:
1004: return $this->performRequest($endpoint);
1005: }
1006:
1007: /**
1008: * Returns all script contexts.
1009: *
1010: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1011: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1012: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1013: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1014: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1015: *
1016: * @param array $params Associative array of parameters
1017: * @return array
1018: */
1019: public function getScriptContext(array $params = [])
1020: {
1021: $endpoint = $this->endpointFactory->getEndpoint(GetScriptContext::class);
1022: $endpoint->setParams($params);
1023:
1024: return $this->performRequest($endpoint);
1025: }
1026:
1027: /**
1028: * Returns available script types, languages and contexts.
1029: *
1030: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1031: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1032: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1033: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1034: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1035: *
1036: * @param array $params Associative array of parameters
1037: * @return array
1038: */
1039: public function getScriptLanguages(array $params = [])
1040: {
1041: $endpoint = $this->endpointFactory->getEndpoint(GetScriptLanguages::class);
1042: $endpoint->setParams($params);
1043:
1044: return $this->performRequest($endpoint);
1045: }
1046:
1047: /**
1048: * Returns the source of a document.
1049: *
1050: * $params['id'] = (string) Unique identifier of the document. (Required)
1051: * $params['index'] = (string) Name of the index that contains the document. (Required)
1052: * $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
1053: * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude in the response.
1054: * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.
1055: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on. Random by default. (Default = random)
1056: * $params['realtime'] = (boolean) Boolean) If `true`, the request is real-time as opposed to near-real-time.
1057: * $params['refresh'] = (any) If `true`, OpenSearch refreshes the affected shards to make this operation visible to search. If `false`, do nothing with refreshes.
1058: * $params['routing'] = (any) Target the specified primary shard.
1059: * $params['version'] = (integer) Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.
1060: * $params['version_type'] = (enum) Specific version type. One of `internal`, `external`, `external_gte`. (Options = external,external_gte,force,internal)
1061: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1062: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1063: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1064: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1065: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1066: *
1067: * @param array $params Associative array of parameters
1068: * @return array
1069: */
1070: public function getSource(array $params = [])
1071: {
1072: $id = $this->extractArgument($params, 'id');
1073: $index = $this->extractArgument($params, 'index');
1074:
1075: $endpoint = $this->endpointFactory->getEndpoint(GetSource::class);
1076: $endpoint->setParams($params);
1077: $endpoint->setId($id);
1078: $endpoint->setIndex($index);
1079:
1080: return $this->performRequest($endpoint);
1081: }
1082:
1083: /**
1084: * Creates or updates a document in an index.
1085: *
1086: * $params['index'] = (string) Name of the data stream or index to target. (Required)
1087: * $params['id'] = (string) Unique identifier for the document.
1088: * $params['if_primary_term'] = (integer) Only perform the operation if the document has this primary term.
1089: * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number.
1090: * $params['op_type'] = (enum) Set to create to only index the document if it does not already exist (put if absent).If a document with the specified `_id` already exists, the indexing operation will fail.Same as using the `<index>/_create` endpoint.Valid values: `index`, `create`.If document id is specified, it defaults to `index`.Otherwise, it defaults to `create`. (Options = create,index)
1091: * $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter.
1092: * $params['refresh'] = (any) If `true`, OpenSearch refreshes 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` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`.
1093: * $params['require_alias'] = (boolean) If `true`, the destination must be an index alias. (Default = false)
1094: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
1095: * $params['timeout'] = (string) Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.
1096: * $params['version'] = (integer) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
1097: * $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = external,external_gte,force,internal)
1098: * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to all or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
1099: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1100: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1101: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1102: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1103: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1104: * $params['body'] = (array) The document (Required)
1105: *
1106: * @param array $params Associative array of parameters
1107: * @return array
1108: */
1109: public function index(array $params = [])
1110: {
1111: $index = $this->extractArgument($params, 'index');
1112: $id = $this->extractArgument($params, 'id');
1113: $body = $this->extractArgument($params, 'body');
1114:
1115: $endpoint = $this->endpointFactory->getEndpoint(Index::class);
1116: $endpoint->setParams($params);
1117: $endpoint->setIndex($index);
1118: $endpoint->setId($id);
1119: $endpoint->setBody($body);
1120:
1121: return $this->performRequest($endpoint);
1122: }
1123:
1124: /**
1125: * Returns basic information about the cluster.
1126: *
1127: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1128: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1129: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1130: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1131: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1132: *
1133: * @param array $params Associative array of parameters
1134: * @return array
1135: */
1136: public function info(array $params = [])
1137: {
1138: $endpoint = $this->endpointFactory->getEndpoint(Info::class);
1139: $endpoint->setParams($params);
1140:
1141: return $this->performRequest($endpoint);
1142: }
1143:
1144: /**
1145: * Allows to get multiple documents in one request.
1146: *
1147: * $params['index'] = (string) Name of the index to retrieve documents from when `ids` are specified, or when a document in the `docs` array does not specify an index.
1148: * $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
1149: * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude from the response.You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter.
1150: * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.If this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the `_source_excludes` query parameter.If the `_source` parameter is `false`, this parameter is ignored.
1151: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on. Random by default. (Default = random)
1152: * $params['realtime'] = (boolean) If `true`, the request is real-time as opposed to near-real-time.
1153: * $params['refresh'] = (any) If `true`, the request refreshes relevant shards before retrieving documents.
1154: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
1155: * $params['stored_fields'] = (any) If `true`, retrieves the document fields stored in the index rather than the document `_source`.
1156: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1157: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1158: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1159: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1160: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1161: * $params['body'] = (array) Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL. (Required)
1162: *
1163: * @param array $params Associative array of parameters
1164: * @return array
1165: */
1166: public function mget(array $params = [])
1167: {
1168: $index = $this->extractArgument($params, 'index');
1169: $body = $this->extractArgument($params, 'body');
1170:
1171: $endpoint = $this->endpointFactory->getEndpoint(Mget::class);
1172: $endpoint->setParams($params);
1173: $endpoint->setIndex($index);
1174: $endpoint->setBody($body);
1175:
1176: return $this->performRequest($endpoint);
1177: }
1178:
1179: /**
1180: * Allows to execute several search operations in one request.
1181: *
1182: * $params['index'] = (array) Comma-separated list of data streams, indexes, and index aliases to search.
1183: * $params['ccs_minimize_roundtrips'] = (boolean) If `true`, network round-trips between the coordinating node and remote clusters are minimized for cross-cluster search requests. (Default = true)
1184: * $params['max_concurrent_searches'] = (integer) Maximum number of concurrent searches the multi search API can execute.
1185: * $params['max_concurrent_shard_requests'] = (integer) Maximum number of concurrent shard requests that each sub-search request executes per node. (Default = 5)
1186: * $params['pre_filter_shard_size'] = (integer) Defines 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 i.e., if date filters are mandatory to match but the shard bounds and the query are disjoint.
1187: * $params['rest_total_hits_as_int'] = (boolean) If `true`, `hits.total` are returned as an integer in the response. Defaults to false, which returns an object. (Default = false)
1188: * $params['search_type'] = (any) Indicates whether global term and document frequencies should be used when scoring returned documents.
1189: * $params['typed_keys'] = (boolean) Specifies whether aggregation and suggester names should be prefixed by their respective types in the response.
1190: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1191: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1192: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1193: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1194: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1195: * $params['body'] = (array) The request definitions (metadata-search request definition pairs), separated by newlines (Required)
1196: *
1197: * @param array $params Associative array of parameters
1198: * @return array
1199: */
1200: public function msearch(array $params = [])
1201: {
1202: $index = $this->extractArgument($params, 'index');
1203: $body = $this->extractArgument($params, 'body');
1204:
1205: $endpoint = $this->endpointFactory->getEndpoint(Msearch::class);
1206: $endpoint->setParams($params);
1207: $endpoint->setIndex($index);
1208: $endpoint->setBody($body);
1209:
1210: return $this->performRequest($endpoint);
1211: }
1212:
1213: /**
1214: * Allows to execute several search template operations in one request.
1215: *
1216: * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams and indexes, omit this parameter or use `*`.
1217: * $params['ccs_minimize_roundtrips'] = (boolean) If `true`, network round-trips are minimized for cross-cluster search requests. (Default = true)
1218: * $params['max_concurrent_searches'] = (integer) Maximum number of concurrent searches the API can run.
1219: * $params['rest_total_hits_as_int'] = (boolean) If `true`, the response returns `hits.total` as an integer.If `false`, it returns `hits.total` as an object. (Default = false)
1220: * $params['search_type'] = (any) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`.
1221: * $params['typed_keys'] = (boolean) If `true`, the response prefixes aggregation and suggester names with their respective types.
1222: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1223: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1224: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1225: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1226: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1227: * $params['body'] = (array) The request definitions (metadata-search request definition pairs), separated by newlines (Required)
1228: *
1229: * @param array $params Associative array of parameters
1230: * @return array
1231: */
1232: public function msearchTemplate(array $params = [])
1233: {
1234: $index = $this->extractArgument($params, 'index');
1235: $body = $this->extractArgument($params, 'body');
1236:
1237: $endpoint = $this->endpointFactory->getEndpoint(MsearchTemplate::class);
1238: $endpoint->setParams($params);
1239: $endpoint->setIndex($index);
1240: $endpoint->setBody($body);
1241:
1242: return $this->performRequest($endpoint);
1243: }
1244:
1245: /**
1246: * Returns multiple termvectors in one request.
1247: *
1248: * $params['index'] = (string) Name of the index that contains the documents.
1249: * $params['field_statistics'] = (boolean) If `true`, the response includes the document count, sum of document frequencies, and sum of total term frequencies. (Default = true)
1250: * $params['fields'] = (any) Comma-separated list or wildcard expressions of fields to include in the statistics.Used as the default list unless a specific field list is provided in the `completion_fields` or `fielddata_fields` parameters.
1251: * $params['ids'] = (array) A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body
1252: * $params['offsets'] = (boolean) If `true`, the response includes term offsets. (Default = true)
1253: * $params['payloads'] = (boolean) If `true`, the response includes term payloads. (Default = true)
1254: * $params['positions'] = (boolean) If `true`, the response includes term positions. (Default = true)
1255: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
1256: * $params['realtime'] = (boolean) If `true`, the request is real-time as opposed to near-real-time. (Default = true)
1257: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
1258: * $params['term_statistics'] = (boolean) If `true`, the response includes term frequency and document frequency. (Default = false)
1259: * $params['version'] = (integer) If `true`, returns the document version as part of a hit.
1260: * $params['version_type'] = (enum) Specific version type. (Options = external,external_gte,force,internal)
1261: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1262: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1263: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1264: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1265: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1266: * $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.
1267: *
1268: * @param array $params Associative array of parameters
1269: * @return array
1270: */
1271: public function mtermvectors(array $params = [])
1272: {
1273: $index = $this->extractArgument($params, 'index');
1274: $body = $this->extractArgument($params, 'body');
1275:
1276: $endpoint = $this->endpointFactory->getEndpoint(MTermVectors::class);
1277: $endpoint->setParams($params);
1278: $endpoint->setIndex($index);
1279: $endpoint->setBody($body);
1280:
1281: return $this->performRequest($endpoint);
1282: }
1283:
1284: /**
1285: * Returns whether the cluster is running.
1286: *
1287: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1288: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1289: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1290: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1291: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1292: *
1293: * @param array $params Associative array of parameters
1294: * @return bool
1295: */
1296: public function ping(array $params = []): bool
1297: {
1298: // Legacy option to manually make this verbose so we can check status code.
1299: // @todo remove in 3.0.0
1300: $params['client']['verbose'] = true;
1301:
1302: $endpoint = $this->endpointFactory->getEndpoint(Ping::class);
1303: $endpoint->setParams($params);
1304:
1305: return BooleanRequestWrapper::sendRequest($endpoint, $this->httpTransport);
1306: }
1307:
1308: /**
1309: * Creates or updates a script.
1310: *
1311: * $params['id'] = (string) Identifier for the stored script or search template. Must be unique within the cluster. (Required)
1312: * $params['context'] = (string) Context in which the script or search template should run. To prevent errors, the API immediately compiles the script or template in this context.
1313: * $params['cluster_manager_timeout'] = (string) Operation timeout for connection to cluster-manager node.
1314: * $params['master_timeout'] = (string) Period to wait for a connection to the cluster-manager node.If no response is received before the timeout expires, the request fails and returns an error.
1315: * $params['timeout'] = (string) Period to wait for a response.If no response is received before the timeout expires, the request fails and returns an error.
1316: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1317: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1318: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1319: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1320: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1321: * $params['body'] = (array) The document (Required)
1322: *
1323: * @param array $params Associative array of parameters
1324: * @return array
1325: */
1326: public function putScript(array $params = [])
1327: {
1328: $id = $this->extractArgument($params, 'id');
1329: $context = $this->extractArgument($params, 'context');
1330: $body = $this->extractArgument($params, 'body');
1331:
1332: $endpoint = $this->endpointFactory->getEndpoint(PutScript::class);
1333: $endpoint->setParams($params);
1334: $endpoint->setId($id);
1335: $endpoint->setContext($context);
1336: $endpoint->setBody($body);
1337:
1338: return $this->performRequest($endpoint);
1339: }
1340:
1341: /**
1342: * Allows to evaluate the quality of ranked search results over a set of typical search queries.
1343: *
1344: * $params['index'] = (array) Comma-separated list of data streams, indexes, and index aliases used to limit the request. Wildcard (`*`) expressions are supported. To target all data streams and indexes in a cluster, omit this parameter or use `_all` or `*`.
1345: * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes. This behavior applies even if the request targets other open indexes. For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.
1346: * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both.
1347: * $params['ignore_unavailable'] = (boolean) If `true`, missing or closed indexes are not included in the response.
1348: * $params['search_type'] = (any) Search operation type
1349: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1350: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1351: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1352: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1353: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1354: * $params['body'] = (array) The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. (Required)
1355: *
1356: * @param array $params Associative array of parameters
1357: * @return array
1358: */
1359: public function rankEval(array $params = [])
1360: {
1361: $index = $this->extractArgument($params, 'index');
1362: $body = $this->extractArgument($params, 'body');
1363:
1364: $endpoint = $this->endpointFactory->getEndpoint(RankEval::class);
1365: $endpoint->setParams($params);
1366: $endpoint->setIndex($index);
1367: $endpoint->setBody($body);
1368:
1369: return $this->performRequest($endpoint);
1370: }
1371:
1372: /**
1373: * 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.
1374: *
1375: * $params['max_docs'] = (integer) Maximum number of documents to process. By default, all documents.
1376: * $params['refresh'] = (any) If `true`, the request refreshes affected shards to make this operation visible to search.
1377: * $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second.Defaults to no throttle. (Default = 0)
1378: * $params['require_alias'] = (boolean)
1379: * $params['scroll'] = (string) Specifies how long a consistent view of the index should be maintained for scrolled search.
1380: * $params['slices'] = (any) The number of slices this task should be divided into.Defaults to 1 slice, meaning the task isn't sliced into subtasks.
1381: * $params['timeout'] = (string) Period each indexing waits for automatic index creation, dynamic mapping updates, and waiting for active shards.
1382: * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
1383: * $params['wait_for_completion'] = (boolean) If `true`, the request blocks until the operation is complete. (Default = true)
1384: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1385: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1386: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1387: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1388: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1389: * $params['body'] = (array) The search definition using the Query DSL and the prototype for the index request. (Required)
1390: *
1391: * @param array $params Associative array of parameters
1392: * @return array
1393: */
1394: public function reindex(array $params = [])
1395: {
1396: $body = $this->extractArgument($params, 'body');
1397:
1398: $endpoint = $this->endpointFactory->getEndpoint(Reindex::class);
1399: $endpoint->setParams($params);
1400: $endpoint->setBody($body);
1401:
1402: return $this->performRequest($endpoint);
1403: }
1404:
1405: /**
1406: * Changes the number of requests per second for a particular reindex operation.
1407: *
1408: * $params['task_id'] = (string) Identifier for the task. (Required)
1409: * $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second.
1410: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1411: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1412: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1413: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1414: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1415: *
1416: * @param array $params Associative array of parameters
1417: * @return array
1418: */
1419: public function reindexRethrottle(array $params = [])
1420: {
1421: $task_id = $this->extractArgument($params, 'task_id');
1422:
1423: $endpoint = $this->endpointFactory->getEndpoint(ReindexRethrottle::class);
1424: $endpoint->setParams($params);
1425: $endpoint->setTaskId($task_id);
1426:
1427: return $this->performRequest($endpoint);
1428: }
1429:
1430: /**
1431: * Allows to use the Mustache language to pre-render a search definition.
1432: *
1433: * $params['id'] = (string) ID of the search template to render. If no `source` is specified, this or the `id` request body parameter is required.
1434: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1435: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1436: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1437: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1438: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1439: * $params['body'] = (array) The search definition template and its parameters.
1440: *
1441: * @param array $params Associative array of parameters
1442: * @return array
1443: */
1444: public function renderSearchTemplate(array $params = [])
1445: {
1446: $id = $this->extractArgument($params, 'id');
1447: $body = $this->extractArgument($params, 'body');
1448:
1449: $endpoint = $this->endpointFactory->getEndpoint(RenderSearchTemplate::class);
1450: $endpoint->setParams($params);
1451: $endpoint->setId($id);
1452: $endpoint->setBody($body);
1453:
1454: return $this->performRequest($endpoint);
1455: }
1456:
1457: /**
1458: * Allows an arbitrary script to be executed and a result to be returned.
1459: *
1460: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1461: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1462: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1463: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1464: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1465: * $params['body'] = (array) The script to execute
1466: *
1467: * @param array $params Associative array of parameters
1468: * @return array
1469: */
1470: public function scriptsPainlessExecute(array $params = [])
1471: {
1472: $body = $this->extractArgument($params, 'body');
1473:
1474: $endpoint = $this->endpointFactory->getEndpoint(ScriptsPainlessExecute::class);
1475: $endpoint->setParams($params);
1476: $endpoint->setBody($body);
1477:
1478: return $this->performRequest($endpoint);
1479: }
1480:
1481: /**
1482: * Allows to retrieve a large numbers of results from a single search request.
1483: *
1484: * $params['scroll_id'] = DEPRECATED (string) The scroll ID
1485: * $params['rest_total_hits_as_int'] = (boolean) If `true`, the API response's `hit.total` property is returned as an integer. If `false`, the API response's `hit.total` property is returned as an object. (Default = false)
1486: * $params['scroll'] = (string) Period to retain the search context for scrolling.
1487: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1488: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1489: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1490: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1491: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1492: *
1493: * @param array $params Associative array of parameters
1494: * @return array
1495: */
1496: public function scroll(array $params = [])
1497: {
1498: $scroll_id = $this->extractArgument($params, 'scroll_id');
1499: $body = $this->extractArgument($params, 'body');
1500:
1501: $endpoint = $this->endpointFactory->getEndpoint(Scroll::class);
1502: $endpoint->setParams($params);
1503: $endpoint->setScrollId($scroll_id);
1504: $endpoint->setBody($body);
1505:
1506: return $this->performRequest($endpoint);
1507: }
1508:
1509: /**
1510: * Returns results matching a query.
1511: *
1512: * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams and indexes, omit this parameter or use `*` or `_all`.
1513: * $params['_source'] = (any) Indicates which source fields are returned for matching documents.These fields are returned in the `hits._source` property of the search response.Valid values are:`true` to return the entire document source;`false` to not return the document source;`<string>` to return the source fields that are specified as a comma-separated list (supports wildcard (`*`) patterns).
1514: * $params['_source_excludes'] = (any) A comma-separated list of source fields to exclude from the response.You can also use this parameter to exclude fields from the subset specified in `_source_includes` query parameter.If the `_source` parameter is `false`, this parameter is ignored.
1515: * $params['_source_includes'] = (any) A comma-separated list of source fields to include in the response.If this parameter is specified, only these source fields are returned.You can exclude fields from this subset using the `_source_excludes` query parameter.If the `_source` parameter is `false`, this parameter is ignored.
1516: * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.
1517: * $params['allow_partial_search_results'] = (boolean) If `true`, returns partial results if there are shard request timeouts or shard failures. If `false`, returns an error with no partial results. (Default = true)
1518: * $params['analyze_wildcard'] = (boolean) If `true`, wildcard and prefix queries are analyzed.This parameter can only be used when the q query string parameter is specified. (Default = false)
1519: * $params['analyzer'] = (string) Analyzer to use for the query string.This parameter can only be used when the q query string parameter is specified.
1520: * $params['batched_reduce_size'] = (integer) 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)
1521: * $params['cancel_after_time_interval'] = (string) The time after which the search request will be canceled.Request-level parameter takes precedence over `cancel_after_time_interval` cluster setting.
1522: * $params['ccs_minimize_roundtrips'] = (boolean) If `true`, network round-trips between the coordinating node and the remote clusters are minimized when executing cross-cluster search (CCS) requests. (Default = true)
1523: * $params['default_operator'] = (enum) The default operator for query string query: AND or OR.This parameter can only be used when the `q` query string parameter is specified. (Options = and,AND,or,OR)
1524: * $params['df'] = (string) Field to use as default where no field prefix is given in the query string.This parameter can only be used when the q query string parameter is specified.
1525: * $params['docvalue_fields'] = (any) A comma-separated list of fields to return as the docvalue representation for each hit.
1526: * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.
1527: * $params['explain'] = (boolean) If `true`, returns detailed information about score computation as part of a hit.
1528: * $params['from'] = (integer) Starting document offset.Needs to be non-negative.By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters.To page through more hits, use the `search_after` parameter. (Default = 0)
1529: * $params['ignore_throttled'] = (boolean) If `true`, concrete, expanded or aliased indexes will be ignored when frozen.
1530: * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index.
1531: * $params['include_named_queries_score'] = (boolean) Indicates whether `hit.matched_queries` should be rendered as a map that includes the name of the matched query associated with its score (true) or as an array containing the name of the matched queries (false) (Default = false)
1532: * $params['lenient'] = (boolean) If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.This parameter can only be used when the `q` query string parameter is specified.
1533: * $params['max_concurrent_shard_requests'] = (integer) Defines 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)
1534: * $params['phase_took'] = (boolean) Indicates whether to return phase-level `took` time values in the response. (Default = false)
1535: * $params['pre_filter_shard_size'] = (integer) Defines 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 (if date filters are mandatory to match but the shard bounds and the query are disjoint).When unspecified, the pre-filter phase is executed if any of these conditions is met:the request targets more than 128 shards;the request targets one or more read-only index;the primary sort of the query targets an indexed field.
1536: * $params['preference'] = (string) Nodes and shards used for the search.By default, OpenSearch selects from eligible nodes and shards using adaptive replica selection, accounting for allocation awareness. Valid values are:`_only_local` to run the search only on shards on the local node;`_local` to, if possible, run the search on shards on the local node, or if not, select shards using the default method;`_only_nodes:<node-id>,<node-id>` to run the search on only the specified nodes IDs, where, if suitable shards exist on more than one selected node, use shards on those nodes using the default method, or if none of the specified nodes are available, select shards from any available node using the default method;`_prefer_nodes:<node-id>,<node-id>` to if possible, run the search on the specified nodes IDs, or if not, select shards using the default method;`_shards:<shard>,<shard>` to run the search only on the specified shards;`<custom-string>` (any string that does not start with `_`) to route searches with the same `<custom-string>` to the same shards in the same order. (Default = random)
1537: * $params['q'] = (string) Query in the Lucene query string syntax using query parameter search.Query parameter searches do not support the full OpenSearch Query DSL but are handy for testing.
1538: * $params['request_cache'] = (boolean) If `true`, the caching of search results is enabled for requests where `size` is `0`.Defaults to index level settings.
1539: * $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)
1540: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
1541: * $params['scroll'] = (string) Period to retain the search context for scrolling. See Scroll search results.By default, this value cannot exceed `1d` (24 hours).You can change this limit using the `search.max_keep_alive` cluster-level setting.
1542: * $params['search_pipeline'] = (string) Customizable sequence of processing stages applied to search queries.
1543: * $params['search_type'] = (any) How distributed term frequencies are calculated for relevance scoring.
1544: * $params['seq_no_primary_term'] = (boolean) If `true`, returns sequence number and primary term of the last modification of each hit.
1545: * $params['size'] = (integer) Defines the number of hits to return.By default, you cannot page through more than 10,000 hits using the `from` and `size` parameters.To page through more hits, use the `search_after` parameter. (Default = 10)
1546: * $params['sort'] = (any) A comma-separated list of <field>:<direction> pairs.
1547: * $params['stats'] = (array) Specific `tag` of the request for logging and statistical purposes.
1548: * $params['stored_fields'] = (any) A comma-separated list of stored fields to return as part of a hit.If no fields are specified, no stored fields are included in the response.If this field is specified, the `_source` parameter defaults to `false`.You can pass `_source: true` to return both source fields and stored fields in the search response.
1549: * $params['suggest_field'] = (string) Specifies which field to use for suggestions.
1550: * $params['suggest_mode'] = (enum) Specifies the suggest mode.This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified. (Options = always,missing,popular)
1551: * $params['suggest_size'] = (integer) Number of suggestions to return.This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified.
1552: * $params['suggest_text'] = (string) The source text for which the suggestions should be returned.This parameter can only be used when the `suggest_field` and `suggest_text` query string parameters are specified.
1553: * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.Use with caution.OpenSearch applies this parameter to each shard handling the request.When possible, let OpenSearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers.If set to `0` (default), the query does not terminate early.
1554: * $params['timeout'] = (string) Specifies the period of time to wait for a response from each shard.If no response is received before the timeout expires, the request fails and returns an error.
1555: * $params['track_scores'] = (boolean) If `true`, calculate and return document scores, even if the scores are not used for sorting.
1556: * $params['track_total_hits'] = (any) Number of hits matching the query to count accurately.If `true`, the exact number of hits is returned at the cost of some performance.If `false`, the response does not include the total number of hits matching the query.
1557: * $params['typed_keys'] = (boolean) If `true`, aggregation and suggester names are be prefixed by their respective types in the response.
1558: * $params['version'] = (boolean) If `true`, returns document version as part of a hit.
1559: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1560: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1561: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1562: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1563: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1564: * $params['body'] = (array) The search definition using the Query DSL
1565: *
1566: * @param array $params Associative array of parameters
1567: * @return array
1568: */
1569: public function search(array $params = [])
1570: {
1571: $index = $this->extractArgument($params, 'index');
1572: $body = $this->extractArgument($params, 'body');
1573:
1574: $endpoint = $this->endpointFactory->getEndpoint(Search::class);
1575: $endpoint->setParams($params);
1576: $endpoint->setIndex($index);
1577: $endpoint->setBody($body);
1578:
1579: return $this->performRequest($endpoint);
1580: }
1581:
1582: /**
1583: * Returns information about the indexes and shards that a search request would be executed against.
1584: *
1585: * $params['index'] = (array) Returns the indexes and shards that a search request would be executed against.
1586: * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.
1587: * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
1588: * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index.
1589: * $params['local'] = (boolean) If `true`, the request retrieves information from the local node only. (Default = false)
1590: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
1591: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
1592: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1593: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1594: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1595: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1596: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1597: *
1598: * @param array $params Associative array of parameters
1599: * @return array
1600: */
1601: public function searchShards(array $params = [])
1602: {
1603: $index = $this->extractArgument($params, 'index');
1604:
1605: $endpoint = $this->endpointFactory->getEndpoint(SearchShards::class);
1606: $endpoint->setParams($params);
1607: $endpoint->setIndex($index);
1608:
1609: return $this->performRequest($endpoint);
1610: }
1611:
1612: /**
1613: * Allows to use the Mustache language to pre-render a search definition.
1614: *
1615: * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (*).
1616: * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.
1617: * $params['ccs_minimize_roundtrips'] = (boolean) If `true`, network round-trips are minimized for cross-cluster search requests. (Default = true)
1618: * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
1619: * $params['explain'] = (boolean) If `true`, the response includes additional details about score computation as part of a hit.
1620: * $params['ignore_throttled'] = (boolean) If `true`, specified concrete, expanded, or aliased indexes are not included in the response when throttled.
1621: * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index.
1622: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
1623: * $params['profile'] = (boolean) If `true`, the query execution is profiled.
1624: * $params['rest_total_hits_as_int'] = (boolean) If `true`, `hits.total` are rendered as an integer in the response. (Default = false)
1625: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
1626: * $params['scroll'] = (string) Specifies how long a consistent view of the indexshould be maintained for scrolled search.
1627: * $params['search_type'] = (any) The type of the search operation.
1628: * $params['typed_keys'] = (boolean) If `true`, the response prefixes aggregation and suggester names with their respective types.
1629: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1630: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1631: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1632: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1633: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1634: * $params['body'] = (array) The search definition template and its parameters. (Required)
1635: *
1636: * @param array $params Associative array of parameters
1637: * @return array
1638: */
1639: public function searchTemplate(array $params = [])
1640: {
1641: $index = $this->extractArgument($params, 'index');
1642: $body = $this->extractArgument($params, 'body');
1643:
1644: $endpoint = $this->endpointFactory->getEndpoint(SearchTemplate::class);
1645: $endpoint->setParams($params);
1646: $endpoint->setIndex($index);
1647: $endpoint->setBody($body);
1648:
1649: return $this->performRequest($endpoint);
1650: }
1651:
1652: /**
1653: * Returns information and statistics about terms in the fields of a particular document.
1654: *
1655: * $params['index'] = (string) Name of the index that contains the document. (Required)
1656: * $params['id'] = (string) Unique identifier of the document.
1657: * $params['field_statistics'] = (boolean) If `true`, the response includes the document count, sum of document frequencies, and sum of total term frequencies. (Default = true)
1658: * $params['fields'] = (any) Comma-separated list or wildcard expressions of fields to include in the statistics.Used as the default list unless a specific field list is provided in the `completion_fields` or `fielddata_fields` parameters.
1659: * $params['offsets'] = (boolean) If `true`, the response includes term offsets. (Default = true)
1660: * $params['payloads'] = (boolean) If `true`, the response includes term payloads. (Default = true)
1661: * $params['positions'] = (boolean) If `true`, the response includes term positions. (Default = true)
1662: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
1663: * $params['realtime'] = (boolean) If `true`, the request is real-time as opposed to near-real-time. (Default = true)
1664: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
1665: * $params['term_statistics'] = (boolean) If `true`, the response includes term frequency and document frequency. (Default = false)
1666: * $params['version'] = (integer) If `true`, returns the document version as part of a hit.
1667: * $params['version_type'] = (enum) Specific version type. (Options = external,external_gte,force,internal)
1668: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1669: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1670: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1671: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1672: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1673: * $params['body'] = (array) Define parameters and or supply a document to get termvectors for. See documentation.
1674: *
1675: * @param array $params Associative array of parameters
1676: * @return array
1677: */
1678: public function termvectors(array $params = [])
1679: {
1680: $index = $this->extractArgument($params, 'index');
1681: $id = $this->extractArgument($params, 'id');
1682: $body = $this->extractArgument($params, 'body');
1683:
1684: $endpoint = $this->endpointFactory->getEndpoint(TermVectors::class);
1685: $endpoint->setParams($params);
1686: $endpoint->setIndex($index);
1687: $endpoint->setId($id);
1688: $endpoint->setBody($body);
1689:
1690: return $this->performRequest($endpoint);
1691: }
1692:
1693: /**
1694: * Updates a document with a script or partial document.
1695: *
1696: * $params['id'] = (string) Document ID (Required)
1697: * $params['index'] = (string) The name of the index (Required)
1698: * $params['_source'] = (any) Set to `false` to disable source retrieval. You can also specify a comma-separatedlist of the fields you want to retrieve.
1699: * $params['_source_excludes'] = (any) Specify the source fields you want to exclude.
1700: * $params['_source_includes'] = (any) Specify the source fields you want to retrieve.
1701: * $params['if_primary_term'] = (integer) Only perform the operation if the document has this primary term.
1702: * $params['if_seq_no'] = (integer) Only perform the operation if the document has this sequence number.
1703: * $params['lang'] = (string) The script language. (Default = painless)
1704: * $params['refresh'] = (any) If 'true', OpenSearch refreshes the affected shards to make this operationvisible to search, if `wait_for` then wait for a refresh to make this operationvisible to search, if `false` do nothing with refreshes.
1705: * $params['require_alias'] = (boolean) If `true`, the destination must be an index alias. (Default = false)
1706: * $params['retry_on_conflict'] = (integer) Specify how many times should the operation be retried when a conflict occurs. (Default = 0)
1707: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
1708: * $params['timeout'] = (string) Period to wait for dynamic mapping updates and active shards.This guarantees OpenSearch waits for at least the timeout before failing.The actual wait time could be longer, particularly when multiple waits occur.
1709: * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operations.Set to 'all' or any positive integer up to the total number of shards in the index(number_of_replicas+1). Defaults to 1 meaning the primary shard.
1710: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1711: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1712: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1713: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1714: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1715: * $params['body'] = (array) The request definition requires either `script` or partial `doc` (Required)
1716: *
1717: * @param array $params Associative array of parameters
1718: * @return array
1719: */
1720: public function update(array $params = [])
1721: {
1722: $id = $this->extractArgument($params, 'id');
1723: $index = $this->extractArgument($params, 'index');
1724: $body = $this->extractArgument($params, 'body');
1725:
1726: $endpoint = $this->endpointFactory->getEndpoint(Update::class);
1727: $endpoint->setParams($params);
1728: $endpoint->setId($id);
1729: $endpoint->setIndex($index);
1730: $endpoint->setBody($body);
1731:
1732: return $this->performRequest($endpoint);
1733: }
1734:
1735: /**
1736: * Performs an update on every document in the index without changing the source,for example to pick up a mapping change.
1737: *
1738: * $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. (Required)
1739: * $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
1740: * $params['_source_excludes'] = (array) List of fields to exclude from the returned `_source` field.
1741: * $params['_source_includes'] = (array) List of fields to extract and return from the `_source` field.
1742: * $params['allow_no_indices'] = (boolean) If `false`, the request returns an error if any wildcard expression, index alias, or `_all` value targets only missing or closed indexes.This behavior applies even if the request targets other open indexes.For example, a request targeting `foo*,bar*` returns an error if an index starts with `foo` but no index starts with `bar`.
1743: * $params['analyze_wildcard'] = (boolean) If `true`, wildcard and prefix queries are analyzed. (Default = false)
1744: * $params['analyzer'] = (string) Analyzer to use for the query string.
1745: * $params['conflicts'] = (enum) What to do if update by query hits version conflicts: `abort` or `proceed`. (Options = abort,proceed)
1746: * $params['default_operator'] = (enum) The default operator for query string query: `AND` or `OR`. (Options = and,AND,or,OR)
1747: * $params['df'] = (string) Field to use as default where no field prefix is given in the query string.
1748: * $params['expand_wildcards'] = (any) Type of index that wildcard patterns can match.If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams.Supports comma-separated values, such as `open,hidden`.Valid values are: `all`, `open`, `closed`, `hidden`, `none`.
1749: * $params['from'] = (integer) Starting offset. (Default = 0)
1750: * $params['ignore_unavailable'] = (boolean) If `false`, the request returns an error if it targets a missing or closed index.
1751: * $params['lenient'] = (boolean) If `true`, format-based query failures (such as providing text to a numeric field) in the query string will be ignored.
1752: * $params['max_docs'] = (integer) Maximum number of documents to process.Defaults to all documents.
1753: * $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter.
1754: * $params['preference'] = (string) Specifies the node or shard the operation should be performed on.Random by default. (Default = random)
1755: * $params['q'] = (string) Query in the Lucene query string syntax.
1756: * $params['refresh'] = (any) If `true`, OpenSearch refreshes affected shards to make the operation visible to search.
1757: * $params['request_cache'] = (boolean) If `true`, the request cache is used for this request.
1758: * $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second. (Default = 0)
1759: * $params['routing'] = (any) Custom value used to route operations to a specific shard.
1760: * $params['scroll'] = (string) Period to retain the search context for scrolling.
1761: * $params['scroll_size'] = (integer) Size of the scroll request that powers the operation. (Default = 100)
1762: * $params['search_timeout'] = (string) Explicit timeout for each search request.
1763: * $params['search_type'] = (any) The type of the search operation. Available options: `query_then_fetch`, `dfs_query_then_fetch`.
1764: * $params['size'] = (integer) Deprecated, use `max_docs` instead.
1765: * $params['slices'] = (any) The number of slices this task should be divided into.
1766: * $params['sort'] = (array) A comma-separated list of <field>:<direction> pairs.
1767: * $params['stats'] = (array) Specific `tag` of the request for logging and statistical purposes.
1768: * $params['terminate_after'] = (integer) Maximum number of documents to collect for each shard.If a query reaches this limit, OpenSearch terminates the query early.OpenSearch collects documents before sorting.Use with caution.OpenSearch applies this parameter to each shard handling the request.When possible, let OpenSearch perform early termination automatically.Avoid specifying this parameter for requests that target data streams with backing indexes across multiple data tiers.
1769: * $params['timeout'] = (string) Period each update request waits for the following operations: dynamic mapping updates, waiting for active shards.
1770: * $params['version'] = (boolean) If `true`, returns the document version as part of a hit.
1771: * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
1772: * $params['wait_for_completion'] = (boolean) If `true`, the request blocks until the operation is complete. (Default = true)
1773: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1774: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1775: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1776: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1777: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1778: * $params['body'] = (array) The search definition using the Query DSL
1779: *
1780: * @param array $params Associative array of parameters
1781: * @return array
1782: */
1783: public function updateByQuery(array $params = [])
1784: {
1785: $index = $this->extractArgument($params, 'index');
1786: $body = $this->extractArgument($params, 'body');
1787:
1788: $endpoint = $this->endpointFactory->getEndpoint(UpdateByQuery::class);
1789: $endpoint->setParams($params);
1790: $endpoint->setIndex($index);
1791: $endpoint->setBody($body);
1792:
1793: return $this->performRequest($endpoint);
1794: }
1795:
1796: /**
1797: * Changes the number of requests per second for a particular Update By Query operation.
1798: *
1799: * $params['task_id'] = (string) The ID for the task. (Required)
1800: * $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second.
1801: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
1802: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
1803: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
1804: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1805: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
1806: *
1807: * @param array $params Associative array of parameters
1808: * @return array
1809: */
1810: public function updateByQueryRethrottle(array $params = [])
1811: {
1812: $task_id = $this->extractArgument($params, 'task_id');
1813:
1814: $endpoint = $this->endpointFactory->getEndpoint(UpdateByQueryRethrottle::class);
1815: $endpoint->setParams($params);
1816: $endpoint->setTaskId($task_id);
1817:
1818: return $this->performRequest($endpoint);
1819: }
1820:
1821: /**
1822: * Proxy function to createPointInTime() to prevent BC break.
1823: * This API will be removed in a future version. Use 'createPit' API instead.
1824: */
1825: public function createPointInTime(array $params = [])
1826: {
1827: return $this->createPit($params);
1828: }
1829: /**
1830: * Creates a new document in the index.Returns a 409 response when a document with a same ID already exists in the index.
1831: *
1832: * $params['id'] = (string) Unique identifier for the document. (Required)
1833: * $params['index'] = (string) Name of the data stream or index to target. If the target doesn’t exist and matches the name or wildcard (`*`) pattern of an index template with a `data_stream` definition, this request creates the data stream. If the target doesn’t exist and doesn’t match a data stream template, this request creates the index. (Required)
1834: * $params['pipeline'] = (string) ID of the pipeline to use to preprocess incoming documents.If the index has a default ingest pipeline specified, then setting the value to `_none` disables the default ingest pipeline for this request.If a final pipeline is configured it will always run, regardless of the value of this parameter.
1835: * $params['refresh'] = (enum) If `true`, OpenSearch refreshes 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` do nothing with refreshes.Valid values: `true`, `false`, `wait_for`. (Options = true,false,wait_for)
1836: * $params['routing'] = (string) Custom value used to route operations to a specific shard.
1837: * $params['timeout'] = (string) Period the request waits for the following operations: automatic index creation, dynamic mapping updates, waiting for active shards.
1838: * $params['version'] = (number) Explicit version number for concurrency control.The specified version must match the current version of the document for the request to succeed.
1839: * $params['version_type'] = (enum) Specific version type: `external`, `external_gte`. (Options = internal,external,external_gte,force)
1840: * $params['wait_for_active_shards'] = (any) The number of shard copies that must be active before proceeding with the operation.Set to `all` or any positive integer up to the total number of shards in the index (`number_of_replicas+1`).
1841: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response.
1842: * $params['human'] = (boolean) Whether to return human readable values for statistics.
1843: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors.
1844: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
1845: * $params['filter_path'] = (any) Comma-separated list of filters used to reduce the response.
1846: * $params['body'] = (array) The document (Required)
1847: *
1848: * @param array $params Associative array of parameters
1849: * @return array
1850: */
1851: public function create(array $params = [])
1852: {
1853: $id = $this->extractArgument($params, 'id');
1854: $index = $this->extractArgument($params, 'index');
1855: $body = $this->extractArgument($params, 'body');
1856:
1857: $endpoint = $id ?
1858: $this->endpointFactory->getEndpoint(Create::class)
1859: : $this->endpointFactory->getEndpoint(Index::class);
1860: $endpoint->setParams($params);
1861: $endpoint->setId($id);
1862: $endpoint->setIndex($index);
1863: $endpoint->setBody($body);
1864:
1865: return $this->performRequest($endpoint);
1866: }
1867: /**
1868: * Proxy function to deletePointInTime() to prevent BC break.
1869: * This API will be removed in a future version. Use 'deletePit' API instead.
1870: */
1871: public function deletePointInTime(array $params = [])
1872: {
1873: return $this->deletePit($params);
1874: }
1875: /**
1876: * Returns the asyncSearch namespace
1877: *
1878: * @deprecated in 2.4.2 and will be removed in 3.0.0.
1879: */
1880: public function asyncSearch(): AsyncSearchNamespace
1881: {
1882: @trigger_error(__METHOD__ . '() is deprecated since 2.4.2 and will be removed in 3.0.0.', E_USER_DEPRECATED);
1883: return $this->asyncSearch;
1884: }
1885: /**
1886: * Returns the asynchronousSearch namespace
1887: */
1888: public function asynchronousSearch(): AsynchronousSearchNamespace
1889: {
1890: return $this->asynchronousSearch;
1891: }
1892: /**
1893: * Returns the cat namespace
1894: */
1895: public function cat(): CatNamespace
1896: {
1897: return $this->cat;
1898: }
1899: /**
1900: * Returns the cluster namespace
1901: */
1902: public function cluster(): ClusterNamespace
1903: {
1904: return $this->cluster;
1905: }
1906: /**
1907: * Returns the danglingIndices namespace
1908: */
1909: public function danglingIndices(): DanglingIndicesNamespace
1910: {
1911: return $this->danglingIndices;
1912: }
1913: /**
1914: * Returns the dataFrameTransformDeprecated namespace
1915: *
1916: * @deprecated in 2.4.2 and will be removed in 3.0.0.
1917: */
1918: public function dataFrameTransformDeprecated(): DataFrameTransformDeprecatedNamespace
1919: {
1920: @trigger_error(__METHOD__ . '() is deprecated since 2.4.2 and will be removed in 3.0.0.', E_USER_DEPRECATED);
1921: return $this->dataFrameTransformDeprecated;
1922: }
1923: /**
1924: * Returns the flowFramework namespace
1925: */
1926: public function flowFramework(): FlowFrameworkNamespace
1927: {
1928: return $this->flowFramework;
1929: }
1930: /**
1931: * Returns the indices namespace
1932: */
1933: public function indices(): IndicesNamespace
1934: {
1935: return $this->indices;
1936: }
1937: /**
1938: * Returns the ingest namespace
1939: */
1940: public function ingest(): IngestNamespace
1941: {
1942: return $this->ingest;
1943: }
1944: /**
1945: * Returns the insights namespace
1946: */
1947: public function insights(): InsightsNamespace
1948: {
1949: return $this->insights;
1950: }
1951: /**
1952: * Returns the ism namespace
1953: */
1954: public function ism(): IsmNamespace
1955: {
1956: return $this->ism;
1957: }
1958: /**
1959: * Returns the knn namespace
1960: */
1961: public function knn(): KnnNamespace
1962: {
1963: return $this->knn;
1964: }
1965: /**
1966: * Returns the list namespace
1967: */
1968: public function list(): ListNamespace
1969: {
1970: return $this->list;
1971: }
1972: /**
1973: * Returns the ltr namespace
1974: */
1975: public function ltr(): LtrNamespace
1976: {
1977: return $this->ltr;
1978: }
1979: /**
1980: * Returns the ml namespace
1981: */
1982: public function ml(): MlNamespace
1983: {
1984: return $this->ml;
1985: }
1986: /**
1987: * Returns the monitoring namespace
1988: *
1989: * @deprecated in 2.4.2 and will be removed in 3.0.0.
1990: */
1991: public function monitoring(): MonitoringNamespace
1992: {
1993: @trigger_error(__METHOD__ . '() is deprecated since 2.4.2 and will be removed in 3.0.0.', E_USER_DEPRECATED);
1994: return $this->monitoring;
1995: }
1996: /**
1997: * Returns the nodes namespace
1998: */
1999: public function nodes(): NodesNamespace
2000: {
2001: return $this->nodes;
2002: }
2003: /**
2004: * Returns the notifications namespace
2005: */
2006: public function notifications(): NotificationsNamespace
2007: {
2008: return $this->notifications;
2009: }
2010: /**
2011: * Returns the observability namespace
2012: */
2013: public function observability(): ObservabilityNamespace
2014: {
2015: return $this->observability;
2016: }
2017: /**
2018: * Returns the ppl namespace
2019: */
2020: public function ppl(): PplNamespace
2021: {
2022: return $this->ppl;
2023: }
2024: /**
2025: * Returns the query namespace
2026: */
2027: public function query(): QueryNamespace
2028: {
2029: return $this->query;
2030: }
2031: /**
2032: * Returns the remoteStore namespace
2033: */
2034: public function remoteStore(): RemoteStoreNamespace
2035: {
2036: return $this->remoteStore;
2037: }
2038: /**
2039: * Returns the replication namespace
2040: */
2041: public function replication(): ReplicationNamespace
2042: {
2043: return $this->replication;
2044: }
2045: /**
2046: * Returns the rollups namespace
2047: */
2048: public function rollups(): RollupsNamespace
2049: {
2050: return $this->rollups;
2051: }
2052: /**
2053: * Returns the searchPipeline namespace
2054: */
2055: public function searchPipeline(): SearchPipelineNamespace
2056: {
2057: return $this->searchPipeline;
2058: }
2059: /**
2060: * Returns the searchableSnapshots namespace
2061: *
2062: * @deprecated in 2.4.2 and will be removed in 3.0.0.
2063: */
2064: public function searchableSnapshots(): SearchableSnapshotsNamespace
2065: {
2066: @trigger_error(__METHOD__ . '() is deprecated since 2.4.2 and will be removed in 3.0.0.', E_USER_DEPRECATED);
2067: return $this->searchableSnapshots;
2068: }
2069: /**
2070: * Returns the security namespace
2071: */
2072: public function security(): SecurityNamespace
2073: {
2074: return $this->security;
2075: }
2076: /**
2077: * Returns the sm namespace
2078: */
2079: public function sm(): SmNamespace
2080: {
2081: return $this->sm;
2082: }
2083: /**
2084: * Returns the snapshot namespace
2085: */
2086: public function snapshot(): SnapshotNamespace
2087: {
2088: return $this->snapshot;
2089: }
2090: /**
2091: * Returns the sql namespace
2092: */
2093: public function sql(): SqlNamespace
2094: {
2095: return $this->sql;
2096: }
2097: /**
2098: * Returns the ssl namespace
2099: *
2100: * @deprecated in 2.4.2 and will be removed in 3.0.0.
2101: */
2102: public function ssl(): SslNamespace
2103: {
2104: @trigger_error(__METHOD__ . '() is deprecated since 2.4.2 and will be removed in 3.0.0.', E_USER_DEPRECATED);
2105: return $this->ssl;
2106: }
2107: /**
2108: * Returns the tasks namespace
2109: */
2110: public function tasks(): TasksNamespace
2111: {
2112: return $this->tasks;
2113: }
2114: /**
2115: * Returns the transforms namespace
2116: */
2117: public function transforms(): TransformsNamespace
2118: {
2119: return $this->transforms;
2120: }
2121: /**
2122: * Returns the wlm namespace
2123: */
2124: public function wlm(): WlmNamespace
2125: {
2126: return $this->wlm;
2127: }
2128:
2129: /**
2130: * Gets the endpoint factory.
2131: */
2132: protected function getEndpointFactory(): EndpointFactoryInterface
2133: {
2134: return $this->endpointFactory;
2135: }
2136:
2137: /**
2138: * Catchall for registered namespaces
2139: *
2140: * @return object
2141: * @throws \BadMethodCallException if the namespace cannot be found
2142: */
2143: public function __call(string $name, array $arguments)
2144: {
2145: if (isset($this->registeredNamespaces[$name])) {
2146: return $this->registeredNamespaces[$name];
2147: }
2148: throw new \BadMethodCallException("Namespace [$name] not found");
2149: }
2150:
2151: /**
2152: * Extract an argument from the array of parameters
2153: *
2154: * @return null|mixed
2155: */
2156: public function extractArgument(array &$params, string $arg)
2157: {
2158: if (array_key_exists($arg, $params) === true) {
2159: $value = $params[$arg];
2160: $value = (is_object($value) && !is_iterable($value)) ?
2161: (array) $value :
2162: $value;
2163: unset($params[$arg]);
2164: return $value;
2165: } else {
2166: return null;
2167: }
2168: }
2169:
2170: /**
2171: * Send a raw request to the cluster.
2172: *
2173: * @throws \Psr\Http\Client\ClientExceptionInterface
2174: * @throws \OpenSearch\Exception\HttpExceptionInterface
2175: */
2176: public function request(
2177: string $method,
2178: string $uri,
2179: array $attributes = []
2180: ): iterable|string|null {
2181: $params = $attributes['params'] ?? [];
2182: $body = $attributes['body'] ?? null;
2183: $options = $attributes['options'] ?? [];
2184:
2185: return $this->httpTransport->sendRequest($method, $uri, $params, $body, $options['headers'] ?? []);
2186: }
2187:
2188: /**
2189: * Send a request for an endpoint.
2190: *
2191: * @throws \Psr\Http\Client\ClientExceptionInterface
2192: * @throws \OpenSearch\Exception\HttpExceptionInterface
2193: */
2194: private function performRequest(AbstractEndpoint $endpoint): iterable|string|null
2195: {
2196: return $this->httpTransport->sendRequest(
2197: $endpoint->getMethod(),
2198: $endpoint->getURI(),
2199: $endpoint->getParams(),
2200: $endpoint->getBody(),
2201: $endpoint->getOptions()
2202: );
2203: }
2204:
2205: }
2206: