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