Question: I am new to Elasticsearch so I know I'm forgetting something but I don't know what.

I ran this code:

```php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require 'vendor/autoload.php';

use Elasticsearch\ClientBuilder;

$client = ClientBuilder::create()->build();
$params = [
  'index' => 'my_index'
];

// Create the index
$response = $client->indices()->create($params);

```

But got this error:

```
{
  "error": {
    "root_cause": [
      {
        "type":"index_not_found_exception",
        "reason":"no such index",
        "resource.type":"index_or_alias",
        "resource.id":"elasticsearch-i.php",
        "index_uuid":"_na_",
        "index":"elasticsearch-i.php"
      }
    ],
    "type":"index_not_found_exception",
    "reason":"no such index",
    "resource.type":"index_or_alias",
    "resource.id":"elasticsearch-i.php",
    "index_uuid":"_na_",
    "index":"elasticsearch-i.php"
  },
  "status":404
}

```

Answer: 
I had not yet created an index on the elasticsearch server itself.

I have to create it first before I can access it on the php-api

To do that,I run:

```
curl -X PUT -x  "" "http://127.0.0.1:9200"/test

```

on the command prompt
There are couple of reasons not saving the index. First check your elasticsearch cluster status then try to create the index from any client.

Check Status of Elasticsearch
-----------------------------

### Health or state of the cluster

`curl -X GET "localhost:9200/_cluster/health"`

OR

`curl -X GET "localhost:9200/_cluster/state"`

OR

`curl -X GET "localhost:9200/_nodes/stats"`

### Create Index using `curl`

`curl -X PUT "localhost:9200/twitter"`

Here is the simple code to create using php:

```
$client = ClientBuilder::create()->build();
$params = [
    'index' => 'twitter_2'
];

$response = $client->indices()->create($params);

```

For complete details check with <https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_index_management_operations.html>