Skip to content

Commit

Permalink
Updated opensearch-php to reflect the latest OpenSearch API spec (202…
Browse files Browse the repository at this point in the history
…5-01-11)

Signed-off-by: GitHub <[email protected]>
  • Loading branch information
dblock authored Jan 11, 2025
1 parent fbb73a3 commit 0c3e7bc
Show file tree
Hide file tree
Showing 19 changed files with 929 additions and 68 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fixed PHP 8.4 deprecations
- Fixed outdated tests
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@9efddb9](https://github.com/opensearch-project/opensearch-api-specification/commit/9efddb985a51ef988d6a37606d043d4d1577baf5)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@2395cb4](https://github.com/opensearch-project/opensearch-api-specification/commit/2395cb472ec5581656aac184f7b20548cd5b06ac)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@ebe0f8a](https://github.com/opensearch-project/opensearch-api-specification/commit/ebe0f8a885f7db7e882d160c101055a5aa70a707)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@398481e](https://github.com/opensearch-project/opensearch-api-specification/commit/398481e5bd1cc590d947c35379c47096f2114f00)
Expand Down
22 changes: 10 additions & 12 deletions src/OpenSearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ public function deleteAllPits(array $params = [])
* Deletes documents matching the provided query.
*
* $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. (Required)
* $params['_source'] = (array) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
* $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
* $params['_source_excludes'] = (array) List of fields to exclude from the returned `_source` field.
* $params['_source_includes'] = (array) List of fields to extract and return from the `_source` field.
* $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`.
Expand All @@ -608,7 +608,7 @@ public function deleteAllPits(array $params = [])
* $params['scroll'] = (string) Period to retain the search context for scrolling.
* $params['scroll_size'] = (integer) Size of the scroll request that powers the operation. (Default = 100)
* $params['search_timeout'] = (string) Explicit timeout for each search request.Defaults to no timeout.
* $params['search_type'] = (enum) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`. (Options = dfs_query_then_fetch,query_then_fetch)
* $params['search_type'] = (any) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`.
* $params['size'] = (integer) Deprecated, use `max_docs` instead.
* $params['slices'] = (any) The number of slices this task should be divided into.
* $params['sort'] = (array) A comma-separated list of <field>:<direction> pairs.
Expand Down Expand Up @@ -1134,7 +1134,7 @@ public function mget(array $params = [])
* $params['max_concurrent_shard_requests'] = (integer) Maximum number of concurrent shard requests that each sub-search request executes per node. (Default = 5)
* $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.
* $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)
* $params['search_type'] = (enum) Indicates whether global term and document frequencies should be used when scoring returned documents. (Options = dfs_query_then_fetch,query_then_fetch)
* $params['search_type'] = (any) Indicates whether global term and document frequencies should be used when scoring returned documents.
* $params['typed_keys'] = (boolean) Specifies whether aggregation and suggester names should be prefixed by their respective types in the response.
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
Expand Down Expand Up @@ -1166,7 +1166,7 @@ public function msearch(array $params = [])
* $params['ccs_minimize_roundtrips'] = (boolean) If `true`, network round-trips are minimized for cross-cluster search requests. (Default = true)
* $params['max_concurrent_searches'] = (integer) Maximum number of concurrent searches the API can run.
* $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)
* $params['search_type'] = (enum) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`. (Options = dfs_query_then_fetch,query_then_fetch)
* $params['search_type'] = (any) The type of the search operation.Available options: `query_then_fetch`, `dfs_query_then_fetch`.
* $params['typed_keys'] = (boolean) If `true`, the response prefixes aggregation and suggester names with their respective types.
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
Expand Down Expand Up @@ -1293,7 +1293,7 @@ public function putScript(array $params = [])
* $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`.
* $params['expand_wildcards'] = (any) Whether to expand wildcard expression to concrete indexes that are open, closed or both.
* $params['ignore_unavailable'] = (boolean) If `true`, missing or closed indexes are not included in the response.
* $params['search_type'] = (enum) Search operation type (Options = dfs_query_then_fetch,query_then_fetch)
* $params['search_type'] = (any) Search operation type
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
* $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
Expand Down Expand Up @@ -1323,6 +1323,7 @@ public function rankEval(array $params = [])
* $params['max_docs'] = (integer) Maximum number of documents to process. By default, all documents.
* $params['refresh'] = (any) If `true`, the request refreshes affected shards to make this operation visible to search.
* $params['requests_per_second'] = (number) The throttle for this request in sub-requests per second.Defaults to no throttle. (Default = 0)
* $params['require_alias'] = (boolean)
* $params['scroll'] = (string) Specifies how long a consistent view of the index should be maintained for scrolled search.
* $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.
* $params['timeout'] = (string) Period each indexing waits for automatic index creation, dynamic mapping updates, and waiting for active shards.
Expand Down Expand Up @@ -1487,7 +1488,7 @@ public function scroll(array $params = [])
* $params['routing'] = (any) Custom value used to route operations to a specific shard.
* $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.
* $params['search_pipeline'] = (string) Customizable sequence of processing stages applied to search queries.
* $params['search_type'] = (enum) How distributed term frequencies are calculated for relevance scoring. (Options = dfs_query_then_fetch,query_then_fetch)
* $params['search_type'] = (any) How distributed term frequencies are calculated for relevance scoring.
* $params['seq_no_primary_term'] = (boolean) If `true`, returns sequence number and primary term of the last modification of each hit.
* $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)
* $params['sort'] = (any) A comma-separated list of <field>:<direction> pairs.
Expand Down Expand Up @@ -1541,20 +1542,17 @@ public function search(array $params = [])
* $params['error_trace'] = (boolean) Whether to include the stack trace of returned errors. (Default = false)
* $params['source'] = (string) The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.
* $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 "-".
* $params['body'] = (array) Defines the parameters that can be used in the `search_shards` endpoint request. See documentation for supported query syntax.
*
* @param array $params Associative array of parameters
* @return array
*/
public function searchShards(array $params = [])
{
$index = $this->extractArgument($params, 'index');
$body = $this->extractArgument($params, 'body');

$endpoint = $this->endpointFactory->getEndpoint(\OpenSearch\Endpoints\SearchShards::class);
$endpoint->setParams($params);
$endpoint->setIndex($index);
$endpoint->setBody($body);

return $this->performRequest($endpoint);
}
Expand All @@ -1574,7 +1572,7 @@ public function searchShards(array $params = [])
* $params['rest_total_hits_as_int'] = (boolean) If `true`, `hits.total` are rendered as an integer in the response. (Default = false)
* $params['routing'] = (any) Custom value used to route operations to a specific shard.
* $params['scroll'] = (string) Specifies how long a consistent view of the indexshould be maintained for scrolled search.
* $params['search_type'] = (enum) The type of the search operation. (Options = dfs_query_then_fetch,query_then_fetch)
* $params['search_type'] = (any) The type of the search operation.
* $params['typed_keys'] = (boolean) If `true`, the response prefixes aggregation and suggester names with their respective types.
* $params['pretty'] = (boolean) Whether to pretty format the returned JSON response. (Default = false)
* $params['human'] = (boolean) Whether to return human readable values for statistics. (Default = true)
Expand Down Expand Up @@ -1686,7 +1684,7 @@ public function update(array $params = [])
* Performs an update on every document in the index without changing the source,for example to pick up a mapping change.
*
* $params['index'] = (array) Comma-separated list of data streams, indexes, and aliases to search. Supports wildcards (`*`). To search all data streams or indexes, omit this parameter or use `*` or `_all`. (Required)
* $params['_source'] = (array) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
* $params['_source'] = (any) Set to `true` or `false` to return the `_source` field or not, or a list of fields to return.
* $params['_source_excludes'] = (array) List of fields to exclude from the returned `_source` field.
* $params['_source_includes'] = (array) List of fields to extract and return from the `_source` field.
* $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`.
Expand All @@ -1710,7 +1708,7 @@ public function update(array $params = [])
* $params['scroll'] = (string) Period to retain the search context for scrolling.
* $params['scroll_size'] = (integer) Size of the scroll request that powers the operation. (Default = 100)
* $params['search_timeout'] = (string) Explicit timeout for each search request.
* $params['search_type'] = (enum) The type of the search operation. Available options: `query_then_fetch`, `dfs_query_then_fetch`. (Options = dfs_query_then_fetch,query_then_fetch)
* $params['search_type'] = (any) The type of the search operation. Available options: `query_then_fetch`, `dfs_query_then_fetch`.
* $params['size'] = (integer) Deprecated, use `max_docs` instead.
* $params['slices'] = (any) The number of slices this task should be divided into.
* $params['sort'] = (array) A comma-separated list of <field>:<direction> pairs.
Expand Down
87 changes: 87 additions & 0 deletions src/OpenSearch/Endpoints/Ml/ChunkModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\Ml;

use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
/**
* @deprecated Use `upload_chunk` instead.
*/
class ChunkModel extends AbstractEndpoint
{
protected $chunk_number;
protected $model_id;

public function getURI(): string
{
$chunk_number = $this->chunk_number ?? null;
$model_id = $this->model_id ?? null;
if (isset($model_id) && isset($chunk_number)) {
return "/_plugins/_ml/models/$model_id/chunk/$chunk_number";
}
throw new RuntimeException('Missing parameter for the endpoint ml.chunk_model');
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'POST';
}

public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;

return $this;
}

public function setChunkNumber($chunk_number): static
{
if (is_null($chunk_number)) {
return $this;
}
$this->chunk_number = $chunk_number;

return $this;
}

public function setModelId($model_id): static
{
if (is_null($model_id)) {
return $this;
}
$this->model_id = $model_id;

return $this;
}
}
58 changes: 58 additions & 0 deletions src/OpenSearch/Endpoints/Ml/CreateModelMeta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

/**
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

namespace OpenSearch\Endpoints\Ml;

use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
/**
* @deprecated Use `_register_meta` instead.
*/
class CreateModelMeta extends AbstractEndpoint
{
public function getURI(): string
{
return "/_plugins/_ml/models/meta";
}

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

public function getMethod(): string
{
return 'POST';
}

public function setBody($body): static
{
if (is_null($body)) {
return $this;
}
$this->body = $body;

return $this;
}
}
47 changes: 28 additions & 19 deletions src/OpenSearch/Endpoints/Ml/GetModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,45 @@
use OpenSearch\Common\Exceptions\RuntimeException;
use OpenSearch\Endpoints\AbstractEndpoint;

/**
* NOTE: This file is autogenerated using util/GenerateEndpoints.php
*/
class GetModel extends AbstractEndpoint
{
/**
* @return string[]
*/
public function getParamWhitelist(): array
{
return [];
}
protected $model_id;

/**
* @return string
*/
public function getURI(): string
{
if ($this->id) {
return "/_plugins/_ml/models/$this->id";
$model_id = $this->model_id ?? null;
if (isset($model_id)) {
return "/_plugins/_ml/models/$model_id";
}
throw new RuntimeException('Missing parameter for the endpoint ml.get_model');
}

throw new RuntimeException(
'id is required for get'
);

public function getParamWhitelist(): array
{
return [
'pretty',
'human',
'error_trace',
'source',
'filter_path'
];
}

/**
* @return string
*/
public function getMethod(): string
{
return 'GET';
}

public function setModelId($model_id): static
{
if (is_null($model_id)) {
return $this;
}
$this->model_id = $model_id;

return $this;
}
}
Loading

0 comments on commit 0c3e7bc

Please sign in to comment.