Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 3d99537

Browse files
committed
Updated API for 0.1.0 release
1 parent fa092ea commit 3d99537

25 files changed

+1565
-311
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
[![main](https://github.com/elastic/elasticsearch-serverless-php/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/elastic/elasticsearch-serverless-php/actions/workflows/tests.yml)
44

5-
This is the official Elastic client for the **Elasticsearch Serverless** service, still in private preview.
6-
If you're looking to develop your PHP application with the Elasticsearch Stack, you should look at the [Elasticsearch Client](https://github.com/elastic/elasticsearch-php) instead. If you're looking to develop your PHP application with Elastic Enterprise Search, you should look at the [Enterprise Search Client](https://github.com/elastic/enterprise-search-php/).
5+
This is the official Elastic client for the **Elasticsearch Serverless** service.
6+
7+
If you're looking to develop your PHP application with the Elasticsearch Stack,
8+
you should look at the [Elasticsearch Client](https://github.com/elastic/elasticsearch-php) instead.
79

810
## Installation
911

@@ -24,10 +26,10 @@ Please remember that `alpha` releases are quite unstable, the code can change be
2426
Instead, a release candidate `rc` will not break the backward compatibility. Typically an `rc`
2527
version includes only bug fixes.
2628

27-
### Instantiate a Client
29+
### Instantiate the client
2830

29-
When you have installed elasticsearch-php you can start using it with the `Client`` class.
30-
You can use the ClientBuilder class to create this object:
31+
When you have installed elasticsearch-php you can start using it with the `Client` class.
32+
You can use the `ClientBuilder` to create this object:
3133

3234
```php
3335
require 'vendor/autoload.php';
@@ -52,10 +54,6 @@ page for a getting started guide.
5254

5355
See [CONTRIBUTING](./CONTRIBUTING.md).
5456

55-
### Docs
56-
57-
Some questions, assumptions and general notes about this project can be found in [the docs directory](./docs/questions-and-assumptions.md).
58-
5957
## License 📗
6058

6159
[MIT](LICENSE) © [Elastic](https://www.elastic.co/)

docs/landing-page.MDX

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ If you want to develop your PHP application with the Elasticsearch Stack, refer
1313
to the [Elasticsearch Client](https://github.com/elastic/elasticsearch-php)
1414
instead.
1515

16-
If you want to develop your PHP application with Elastic Enterprise Search,
17-
refer to the
18-
[Enterprise Search Client](https://github.com/elastic/enterprise-search-php/).
19-
2016
## Important materials
2117

2218
* [Elasticsearch Serverless Php client repository](https://github.com/elastic/elasticsearch-serverless-php)

docs/questions-and-assumptions.md

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
final class Client implements ClientInterface
2929
{
3030
const CLIENT_NAME = 'esv';
31-
const VERSION = '0.1.0-alpha2';
31+
const VERSION = '0.1.0';
3232
const API_VERSION_HEADER = 'Elastic-Api-Version';
3333
const API_VERSION = '2023-10-31';
3434

src/Endpoints/AsyncSearch.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class AsyncSearch extends AbstractEndpoint
4949
*/
5050
public function delete(string $id, array $params = []): Elasticsearch|Promise
5151
{
52-
$url = '/_async_search/' . $this->encode($id) . '';
52+
$url = '/_async_search/' . $this->encode($id);
5353
$method = 'DELETE';
5454
$url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
5555
$headers = [
@@ -83,7 +83,7 @@ public function delete(string $id, array $params = []): Elasticsearch|Promise
8383
*/
8484
public function get(string $id, array $params = []): Elasticsearch|Promise
8585
{
86-
$url = '/_async_search/' . $this->encode($id) . '';
86+
$url = '/_async_search/' . $this->encode($id);
8787
$method = 'GET';
8888
$url = $this->addQueryString($url, $params, [
8989
'keep_alive',
@@ -123,7 +123,7 @@ public function get(string $id, array $params = []): Elasticsearch|Promise
123123
*/
124124
public function status(string $id, array $params = []): Elasticsearch|Promise
125125
{
126-
$url = '/_async_search/status/' . $this->encode($id) . '';
126+
$url = '/_async_search/status/' . $this->encode($id);
127127
$method = 'GET';
128128
$url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
129129
$headers = [
@@ -148,7 +148,7 @@ public function status(string $id, array $params = []): Elasticsearch|Promise
148148
* allow_partial_search_results: bool, // Indicate if an error should be returned if there is a partial search failure or timeout
149149
* analyzer: string, // The analyzer to use for the query string
150150
* analyze_wildcard: bool, // Specify whether wildcard and prefix queries should be analyzed (default: false)
151-
* batched_reduce_size: integer, // Affects how often partial results become available, which happens whenever shard results are reduced.A partial reduction is performed every time the coordinating node has received a certain number of new shard responses (5 by default).
151+
* batched_reduce_size: int, // Affects how often partial results become available, which happens whenever shard results are reduced.A partial reduction is performed every time the coordinating node has received a certain number of new shard responses (5 by default).
152152
* ccs_minimize_roundtrips: bool, // The default value is the only supported value.
153153
* default_operator: string, // The default operator for query string query (AND or OR)
154154
* df: string, // The field to use as default where no field prefix is given in the query string
@@ -158,10 +158,10 @@ public function status(string $id, array $params = []): Elasticsearch|Promise
158158
* ignore_throttled: bool, // Whether specified concrete, expanded or aliased indices should be ignored when throttled
159159
* ignore_unavailable: bool, // Whether specified concrete indices should be ignored when unavailable (missing or closed)
160160
* lenient: bool, // Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
161-
* 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
161+
* max_concurrent_shard_requests: int, // 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
162162
* min_compatible_shard_node: string, //
163163
* preference: string, // Specify the node or shard the operation should be performed on (default: random)
164-
* pre_filter_shard_size: integer, // The default value cannot be changed, which enforces the execution of a pre-filter roundtrip to retrieve statistics from each shard so that the ones that surely don’t hold any document matching the query get skipped.
164+
* pre_filter_shard_size: int, // The default value cannot be changed, which enforces the execution of a pre-filter roundtrip to retrieve statistics from each shard so that the ones that surely don’t hold any document matching the query get skipped.
165165
* request_cache: bool, // Specify if request cache should be used for this request or not, defaults to true
166166
* routing: string, // A comma-separated list of specific routing values
167167
* scroll: string|integer, //
@@ -170,11 +170,11 @@ public function status(string $id, array $params = []): Elasticsearch|Promise
170170
* stored_fields: string|array, // A comma-separated list of stored fields to return as part of a hit
171171
* suggest_field: string, // Specifies which field to use for suggestions.
172172
* suggest_mode: string, // Specify suggest mode
173-
* suggest_size: integer, // How many suggestions to return in response
173+
* suggest_size: int, // How many suggestions to return in response
174174
* suggest_text: string, // The source text for which the suggestions should be returned.
175-
* terminate_after: integer, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
175+
* terminate_after: int, // The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
176176
* timeout: string|integer, // Explicit operation timeout
177-
* track_total_hits: bool|integer, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.
177+
* track_total_hits: bool|int, // Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number.
178178
* track_scores: bool, // Whether to calculate and return scores even if they are not used for sorting
179179
* typed_keys: bool, // Specify whether aggregation and suggester names should be prefixed by their respective types in the response
180180
* rest_total_hits_as_int: bool, //
@@ -184,8 +184,8 @@ public function status(string $id, array $params = []): Elasticsearch|Promise
184184
* _source_includes: string|array, // A list of fields to extract and return from the _source field
185185
* seq_no_primary_term: bool, // Specify whether to return sequence number and primary term of the last modification of each hit
186186
* q: string, // Query in the Lucene query string syntax
187-
* size: integer, // Number of hits to return (default: 10)
188-
* from: integer, // Starting offset (default: 0)
187+
* size: int, // Number of hits to return (default: 10)
188+
* from: int, // Starting offset (default: 0)
189189
* sort: string|array, // A comma-separated list of <field>:<direction> pairs
190190
* pretty: bool, // Pretty format the returned JSON response. (DEFAULT: false)
191191
* human: bool, // Return human readable values for statistics. (DEFAULT: true)

src/Endpoints/Cat.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function aliases(string|array $name = null, array $params = []): Elastics
5252
{
5353
$name = $this->convertValue($name);
5454
if (isset($name)) {
55-
$url = '/_cat/aliases/' . $this->encode($name) . '';
55+
$url = '/_cat/aliases/' . $this->encode($name);
5656
$method = 'GET';
5757
} else {
5858
$url = "/_cat/aliases";
@@ -95,7 +95,7 @@ public function aliases(string|array $name = null, array $params = []): Elastics
9595
public function componentTemplates(string $name = null, array $params = []): Elasticsearch|Promise
9696
{
9797
if (isset($name)) {
98-
$url = '/_cat/component_templates/' . $this->encode($name) . '';
98+
$url = '/_cat/component_templates/' . $this->encode($name);
9999
$method = 'GET';
100100
} else {
101101
$url = "/_cat/component_templates";
@@ -133,7 +133,7 @@ public function count(string|array $index = null, array $params = []): Elasticse
133133
{
134134
$index = $this->convertValue($index);
135135
if (isset($index)) {
136-
$url = '/_cat/count/' . $this->encode($index) . '';
136+
$url = '/_cat/count/' . $this->encode($index);
137137
$method = 'GET';
138138
} else {
139139
$url = "/_cat/count";
@@ -207,7 +207,7 @@ public function indices(string|array $index = null, array $params = []): Elastic
207207
{
208208
$index = $this->convertValue($index);
209209
if (isset($index)) {
210-
$url = '/_cat/indices/' . $this->encode($index) . '';
210+
$url = '/_cat/indices/' . $this->encode($index);
211211
$method = 'GET';
212212
} else {
213213
$url = "/_cat/indices";
@@ -260,7 +260,7 @@ public function indices(string|array $index = null, array $params = []): Elastic
260260
public function mlDataFrameAnalytics(string $id = null, array $params = []): Elasticsearch|Promise
261261
{
262262
if (isset($id)) {
263-
$url = '/_cat/ml/data_frame/analytics/' . $this->encode($id) . '';
263+
$url = '/_cat/ml/data_frame/analytics/' . $this->encode($id);
264264
$method = 'GET';
265265
} else {
266266
$url = "/_cat/ml/data_frame/analytics";
@@ -311,7 +311,7 @@ public function mlDataFrameAnalytics(string $id = null, array $params = []): Ela
311311
public function mlDatafeeds(string $datafeed_id = null, array $params = []): Elasticsearch|Promise
312312
{
313313
if (isset($datafeed_id)) {
314-
$url = '/_cat/ml/datafeeds/' . $this->encode($datafeed_id) . '';
314+
$url = '/_cat/ml/datafeeds/' . $this->encode($datafeed_id);
315315
$method = 'GET';
316316
} else {
317317
$url = "/_cat/ml/datafeeds";
@@ -362,7 +362,7 @@ public function mlDatafeeds(string $datafeed_id = null, array $params = []): Ela
362362
public function mlJobs(string $job_id = null, array $params = []): Elasticsearch|Promise
363363
{
364364
if (isset($job_id)) {
365-
$url = '/_cat/ml/anomaly_detectors/' . $this->encode($job_id) . '';
365+
$url = '/_cat/ml/anomaly_detectors/' . $this->encode($job_id);
366366
$method = 'GET';
367367
} else {
368368
$url = "/_cat/ml/anomaly_detectors";
@@ -398,8 +398,8 @@ public function mlJobs(string $job_id = null, array $params = []): Elasticsearch
398398
* bytes: string, // The unit used to display byte values.
399399
* h: string|array, // A comma-separated list of column names to display.
400400
* s: string|array, // A comma-separated list of column names or aliases used to sort the response.
401-
* from: integer, // Skips the specified number of transforms.
402-
* size: integer, // The maximum number of transforms to display.
401+
* from: int, // Skips the specified number of transforms.
402+
* size: int, // The maximum number of transforms to display.
403403
* pretty: bool, // Pretty format the returned JSON response. (DEFAULT: false)
404404
* human: bool, // Return human readable values for statistics. (DEFAULT: true)
405405
* error_trace: bool, // Include the stack trace of returned errors. (DEFAULT: false)
@@ -415,7 +415,7 @@ public function mlJobs(string $job_id = null, array $params = []): Elasticsearch
415415
public function mlTrainedModels(string $model_id = null, array $params = []): Elasticsearch|Promise
416416
{
417417
if (isset($model_id)) {
418-
$url = '/_cat/ml/trained_models/' . $this->encode($model_id) . '';
418+
$url = '/_cat/ml/trained_models/' . $this->encode($model_id);
419419
$method = 'GET';
420420
} else {
421421
$url = "/_cat/ml/trained_models";
@@ -450,11 +450,11 @@ public function mlTrainedModels(string $model_id = null, array $params = []): El
450450
* If you do not specify one of these options, the API returns information for all transforms.
451451
* @param array{
452452
* allow_no_match: bool, // Specifies what to do when the request: contains wildcard expressions and there are no transforms that match; contains the `_all` string or no identifiers and there are no matches; contains wildcard expressions and there are only partial matches.If `true`, it returns an empty transforms array when there are no matches and the subset of results when there are partial matches.If `false`, the request returns a 404 status code when there are no matches or only partial matches.
453-
* from: integer, // Skips the specified number of transforms.
453+
* from: int, // Skips the specified number of transforms.
454454
* h: string|array, // Comma-separated list of column names to display.
455455
* s: string|array, // Comma-separated list of column names or column aliases used to sort the response.
456456
* time: string, // The unit used to display time values.
457-
* size: integer, // The maximum number of transforms to obtain.
457+
* size: int, // The maximum number of transforms to obtain.
458458
* pretty: bool, // Pretty format the returned JSON response. (DEFAULT: false)
459459
* human: bool, // Return human readable values for statistics. (DEFAULT: true)
460460
* error_trace: bool, // Include the stack trace of returned errors. (DEFAULT: false)
@@ -470,7 +470,7 @@ public function mlTrainedModels(string $model_id = null, array $params = []): El
470470
public function transforms(string $transform_id = null, array $params = []): Elasticsearch|Promise
471471
{
472472
if (isset($transform_id)) {
473-
$url = '/_cat/transforms/' . $this->encode($transform_id) . '';
473+
$url = '/_cat/transforms/' . $this->encode($transform_id);
474474
$method = 'GET';
475475
} else {
476476
$url = "/_cat/transforms";

src/Endpoints/Cluster.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Cluster extends AbstractEndpoint
5252
public function deleteComponentTemplate(string|array $name, array $params = []): Elasticsearch|Promise
5353
{
5454
$name = $this->convertValue($name);
55-
$url = '/_component_template/' . $this->encode($name) . '';
55+
$url = '/_component_template/' . $this->encode($name);
5656
$method = 'DELETE';
5757
$url = $this->addQueryString($url, $params, [
5858
'master_timeout',
@@ -95,7 +95,7 @@ public function deleteComponentTemplate(string|array $name, array $params = []):
9595
public function existsComponentTemplate(string|array $name, array $params = []): Elasticsearch|Promise
9696
{
9797
$name = $this->convertValue($name);
98-
$url = '/_component_template/' . $this->encode($name) . '';
98+
$url = '/_component_template/' . $this->encode($name);
9999
$method = 'HEAD';
100100
$url = $this->addQueryString($url, $params, [
101101
'master_timeout',
@@ -140,7 +140,7 @@ public function existsComponentTemplate(string|array $name, array $params = []):
140140
public function getComponentTemplate(string $name = null, array $params = []): Elasticsearch|Promise
141141
{
142142
if (isset($name)) {
143-
$url = '/_component_template/' . $this->encode($name) . '';
143+
$url = '/_component_template/' . $this->encode($name);
144144
$method = 'GET';
145145
} else {
146146
$url = "/_component_template";
@@ -186,7 +186,7 @@ public function getComponentTemplate(string $name = null, array $params = []): E
186186
public function info(string|array $target, array $params = []): Elasticsearch|Promise
187187
{
188188
$target = $this->convertValue($target);
189-
$url = '/_info/' . $this->encode($target) . '';
189+
$url = '/_info/' . $this->encode($target);
190190
$method = 'GET';
191191
$url = $this->addQueryString($url, $params, ['pretty', 'human', 'error_trace', 'source', 'filter_path']);
192192
$headers = [
@@ -228,7 +228,7 @@ public function putComponentTemplate(
228228
array $params = [],
229229
): Elasticsearch|Promise
230230
{
231-
$url = '/_component_template/' . $this->encode($name) . '';
231+
$url = '/_component_template/' . $this->encode($name);
232232
$method = 'PUT';
233233
$url = $this->addQueryString($url, $params, [
234234
'create',

0 commit comments

Comments
 (0)