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\Namespaces\AbstractNamespace;
19:
20: /**
21: * Class KnnNamespace
22: *
23: * NOTE: This file is autogenerated using util/GenerateEndpoints.php
24: */
25: class KnnNamespace extends AbstractNamespace
26: {
27: /**
28: * Used to delete a particular model in the cluster.
29: *
30: * $params['model_id'] = (string) The id of the model.
31: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
32: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
33: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
34: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
35: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
36: *
37: * @param array $params Associative array of parameters
38: * @return array
39: */
40: public function deleteModel(array $params = [])
41: {
42: $model_id = $this->extractArgument($params, 'model_id');
43:
44: $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\DeleteModel::class);
45: $endpoint->setParams($params);
46: $endpoint->setModelId($model_id);
47:
48: return $this->performRequest($endpoint);
49: }
50:
51: /**
52: * Used to retrieve information about models present in the cluster.
53: *
54: * $params['model_id'] = (string) The id of the model.
55: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
56: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
57: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
58: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
59: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
60: *
61: * @param array $params Associative array of parameters
62: * @return array
63: */
64: public function getModel(array $params = [])
65: {
66: $model_id = $this->extractArgument($params, 'model_id');
67:
68: $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\GetModel::class);
69: $endpoint->setParams($params);
70: $endpoint->setModelId($model_id);
71:
72: return $this->performRequest($endpoint);
73: }
74:
75: /**
76: * Use an OpenSearch query to search for models in the index.
77: *
78: * $params['_source'] = (array) True or false to return the _source field or not, or a list of fields to return.
79: * $params['_source_excludes'] = (array) List of fields to exclude from the returned _source field.
80: * $params['_source_includes'] = (array) List of fields to extract and return from the _source field.
81: * $params['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indexes expression resolves into no concrete indexes. (This includes `_all` string or when no indexes have been specified).
82: * $params['allow_partial_search_results'] = (boolean) Indicate if an error should be returned if there is a partial search failure or timeout. (Default = true)
83: * $params['analyze_wildcard'] = (boolean) Specify whether wildcard and prefix queries should be analyzed. (Default = false)
84: * $params['analyzer'] = (string) The analyzer to use for the query string.
85: * $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)
86: * $params['ccs_minimize_roundtrips'] = (boolean) Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution. (Default = true)
87: * $params['default_operator'] = (enum) The default operator for query string query (AND or OR). (Options = AND,OR)
88: * $params['df'] = (string) The field to use as default where no field prefix is given in the query string.
89: * $params['docvalue_fields'] = (array) Comma-separated list of fields to return as the docvalue representation of a field for each hit.
90: * $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both.
91: * $params['explain'] = (boolean) Specify whether to return detailed information about score computation as part of a hit.
92: * $params['from'] = (integer) Starting offset. (Default = 0)
93: * $params['ignore_throttled'] = (boolean) Whether specified concrete, expanded or aliased indexes should be ignored when throttled.
94: * $params['ignore_unavailable'] = (boolean) Whether specified concrete indexes should be ignored when unavailable (missing or closed).
95: * $params['lenient'] = (boolean) Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.
96: * $params['max_concurrent_shard_requests'] = (integer) 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)
97: * $params['pre_filter_shard_size'] = (integer) Threshold that enforces a pre-filter round-trip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter round-trip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.
98: * $params['preference'] = (string) Specify the node or shard the operation should be performed on. (Default = random)
99: * $params['q'] = (string) Query in the Lucene query string syntax.
100: * $params['request_cache'] = (boolean) Specify if request cache should be used for this request or not, defaults to index level setting.
101: * $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)
102: * $params['routing'] = (any) Comma-separated list of specific routing values.
103: * $params['scroll'] = (string) Specify how long a consistent view of the index should be maintained for scrolled search.
104: * $params['search_type'] = (enum) Search operation type. (Options = dfs_query_then_fetch,query_then_fetch)
105: * $params['seq_no_primary_term'] = (boolean) Specify whether to return sequence number and primary term of the last modification of each hit.
106: * $params['size'] = (integer) Number of hits to return. (Default = 10)
107: * $params['sort'] = (array) Comma-separated list of <field>:<direction> pairs.
108: * $params['stats'] = (array) Specific 'tag' of the request for logging and statistical purposes.
109: * $params['stored_fields'] = (array) Comma-separated list of stored fields to return.
110: * $params['suggest_field'] = (string) Specify which field to use for suggestions.
111: * $params['suggest_mode'] = (enum) Specify suggest mode. (Options = always,missing,popular)
112: * $params['suggest_size'] = (integer) How many suggestions to return in response.
113: * $params['suggest_text'] = (string) The source text for which the suggestions should be returned.
114: * $params['terminate_after'] = (integer) The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
115: * $params['timeout'] = (string) Operation timeout.
116: * $params['track_scores'] = (boolean) Whether to calculate and return scores even if they are not used for sorting.
117: * $params['track_total_hits'] = (boolean) Indicate if the number of documents that match the query should be tracked.
118: * $params['typed_keys'] = (boolean) Specify whether aggregation and suggester names should be prefixed by their respective types in the response.
119: * $params['version'] = (boolean) Whether to return document version as part of a hit.
120: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
121: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
122: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
123: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
124: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
125: *
126: * @param array $params Associative array of parameters
127: * @return array
128: */
129: public function searchModels(array $params = [])
130: {
131: $body = $this->extractArgument($params, 'body');
132:
133: $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\SearchModels::class);
134: $endpoint->setParams($params);
135: $endpoint->setBody($body);
136:
137: return $this->performRequest($endpoint);
138: }
139:
140: /**
141: * Provides information about the current status of the k-NN plugin.
142: *
143: * $params['node_id'] = (array) Comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes.
144: * $params['stat'] = (array) Comma-separated list of stats to retrieve; use `_all` or empty string to retrieve all stats.
145: * $params['timeout'] = (string) Operation timeout.
146: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
147: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
148: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
149: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
150: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
151: *
152: * @param array $params Associative array of parameters
153: * @return array
154: */
155: public function stats(array $params = [])
156: {
157: $node_id = $this->extractArgument($params, 'node_id');
158: $stat = $this->extractArgument($params, 'stat');
159:
160: $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\Stats::class);
161: $endpoint->setParams($params);
162: $endpoint->setNodeId($node_id);
163: $endpoint->setStat($stat);
164:
165: return $this->performRequest($endpoint);
166: }
167:
168: /**
169: * Create and train a model that can be used for initializing k-NN native library indexes during indexing.
170: *
171: * $params['model_id'] = (string) The id of the model.
172: * $params['preference'] = (string) Preferred node to execute training.
173: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
174: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
175: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
176: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
177: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
178: *
179: * @param array $params Associative array of parameters
180: * @return array
181: */
182: public function trainModel(array $params = [])
183: {
184: $model_id = $this->extractArgument($params, 'model_id');
185: $body = $this->extractArgument($params, 'body');
186:
187: $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\TrainModel::class);
188: $endpoint->setParams($params);
189: $endpoint->setModelId($model_id);
190: $endpoint->setBody($body);
191:
192: return $this->performRequest($endpoint);
193: }
194:
195: /**
196: * Preloads native library files into memory, reducing initial search latency for specified indexes.
197: *
198: * $params['index'] = (array) Comma-separated list of indexes; use `_all` or empty string to perform the operation on all indexes. (Required)
199: * $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
200: * $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
201: * $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
202: * $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
203: * $params['filter_path'] = (any) Used to reduce the response. This parameter takes a comma-separated list of filters. It supports using wildcards to match any field or part of a field’s name. You can also exclude fields with "-".
204: *
205: * @param array $params Associative array of parameters
206: * @return array
207: */
208: public function warmup(array $params = [])
209: {
210: $index = $this->extractArgument($params, 'index');
211:
212: $endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\Knn\Warmup::class);
213: $endpoint->setParams($params);
214: $endpoint->setIndex($index);
215:
216: return $this->performRequest($endpoint);
217: }
218:
219: }
220: