1: <?php
2:
3: declare(strict_types=1);
4:
5: /**
6: * SPDX-License-Identifier: Apache-2.0
7: *
8: * The OpenSearch Contributors require contributions made to
9: * this file be licensed under the Apache-2.0 license or a
10: * compatible open source license.
11: *
12: * Modifications Copyright OpenSearch Contributors. See
13: * GitHub history for details.
14: */
15:
16: namespace OpenSearch\Namespaces;
17:
18: use OpenSearch\Endpoints\Ppl\Explain;
19: use OpenSearch\Endpoints\Ppl\GetStats;
20: use OpenSearch\Endpoints\Ppl\PostStats;
21: use OpenSearch\Endpoints\Ppl\Query;
22:
23: /**
24: * Class PplNamespace
25: *
26: * NOTE: This file is autogenerated using util/GenerateEndpoints.php
27: */
28: class PplNamespace extends AbstractNamespace
29: {
30: /**
31: * Returns the execution plan for a PPL query.
32: *
33: * $params['format'] = (string) Specifies the response format (JSON, YAML).
34: * $params['sanitize'] = (boolean) Whether to escape special characters in the results. (Default = true)
35: * $params['pretty'] = (boolean) Whether to pretty-format the returned JSON response. (Default = false)
36: * $params['human'] = (boolean) Whether to return human-readable values for statistics. (Default = false)
37: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
38: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
39: * $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 `-`.
40: *
41: * @param array $params Associative array of parameters
42: * @return array
43: */
44: public function explain(array $params = [])
45: {
46: $body = $this->extractArgument($params, 'body');
47:
48: $endpoint = $this->endpointFactory->getEndpoint(Explain::class);
49: $endpoint->setParams($params);
50: $endpoint->setBody($body);
51:
52: return $this->performRequest($endpoint);
53: }
54:
55: /**
56: * Retrieves performance metrics for the PPL plugin.
57: *
58: * $params['format'] = (string) Specifies the response format (JSON, YAML).
59: * $params['sanitize'] = (boolean) Whether to escape special characters in the results. (Default = true)
60: * $params['pretty'] = (boolean) Whether to pretty-format the returned JSON response. (Default = false)
61: * $params['human'] = (boolean) Whether to return human-readable values for statistics. (Default = false)
62: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
63: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
64: * $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 `-`.
65: *
66: * @param array $params Associative array of parameters
67: * @return array
68: */
69: public function getStats(array $params = [])
70: {
71: $endpoint = $this->endpointFactory->getEndpoint(GetStats::class);
72: $endpoint->setParams($params);
73:
74: return $this->performRequest($endpoint);
75: }
76:
77: /**
78: * Retrieves filtered performance metrics for the PPL plugin.
79: *
80: * $params['format'] = (string) Specifies the response format (JSON, YAML).
81: * $params['sanitize'] = (boolean) Whether to escape special characters in the results. (Default = true)
82: * $params['pretty'] = (boolean) Whether to pretty-format the returned JSON response. (Default = false)
83: * $params['human'] = (boolean) Whether to return human-readable values for statistics. (Default = false)
84: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
85: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
86: * $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 `-`.
87: *
88: * @param array $params Associative array of parameters
89: * @return array
90: */
91: public function postStats(array $params = [])
92: {
93: $body = $this->extractArgument($params, 'body');
94:
95: $endpoint = $this->endpointFactory->getEndpoint(PostStats::class);
96: $endpoint->setParams($params);
97: $endpoint->setBody($body);
98:
99: return $this->performRequest($endpoint);
100: }
101:
102: /**
103: * Executes a PPL query against OpenSearch indexes.
104: *
105: * $params['format'] = (string) Specifies the response format (JSON OR YAML).
106: * $params['sanitize'] = (boolean) Whether to sanitize special characters in the results. (Default = true)
107: * $params['pretty'] = (boolean) Whether to pretty-format the returned JSON response. (Default = false)
108: * $params['human'] = (boolean) Whether to return human-readable values for statistics. (Default = false)
109: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
110: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
111: * $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 `-`.
112: *
113: * @param array $params Associative array of parameters
114: * @return array
115: */
116: public function query(array $params = [])
117: {
118: $body = $this->extractArgument($params, 'body');
119:
120: $endpoint = $this->endpointFactory->getEndpoint(Query::class);
121: $endpoint->setParams($params);
122: $endpoint->setBody($body);
123:
124: return $this->performRequest($endpoint);
125: }
126:
127: }
128: