$response = $client->indices()->create($params);
print_r($response);
- Indexing Documents
After creating an index, you can index documents into it. how to add a document to the my_index index:
php
Copy code
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'title' => 'Hello World',
'content' => 'This is Digital Marketing my first document.',
'published_at' => '2024-06-10'
]
];
$response = $client->index($params);
print_r($response);
- Retrieve Documents
After indexing a document, you can retrieve it by its document ID. The following code example demonstrates how to retrieve documents in the my_index index:

$params = [
'index' => 'my_index',
'id' => '1'
];
$response = $client->get($params);
print_r($response);