You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 10, 2025. It is now read-only.
This is the official Elastic client for the **Elasticsearch Serverless** service. 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 {LANG} 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. 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/).
6
6
7
7
## Installation
8
8
9
+
You can install the library using [composer](https://getcomposer.org/) with the following command:
9
10
10
-
### Instantiate a Client
11
+
```bash
12
+
composer require elastic/elasticsearch-serverless
13
+
```
11
14
15
+
### Instantiate a Client
12
16
13
-
### Using the API
17
+
When you have installed elasticsearch-php you can start using it with the `Client`` class.
18
+
You can use the ClientBuilder class to create this object:
14
19
20
+
```php
21
+
require 'vendor/autoload.php';
15
22
16
-
Once you've instantiated a client with your API key and Elasticsearch endpoint, you can start ingesting documents into Elasticsearch Service. You can use the **Bulk API** for this. This API allows you to index, update and delete several documents in one request. You call the `bulk` API on the client with a body parameter, an Array of hashes that define the action and a document. Here's an example of indexing some classic books into the `books` index:
23
+
use Elastic\Elasticsearch\Serverless\ClientBuilder;
# $client is an object of Elastic\Elasticsearch\Serverless\Client class
40
31
```
41
32
42
-
When you use the client to make a request to Elasticsearch, it will return an API Response object. You can see the HTTP return code by calling `status` and the HTTP headers by calling `headers` on the response object. The Response object behaves as a Hash too, so you can access the body values directly as seen on the previous example with `response['items']`.
43
33
44
-
Now that some data is available, you can search your documents using the **Search API**:
0 commit comments