Skip to the content.

Document Operations

The elasticsearch-php-client provides a comprehensive set of operations for working with documents in Elasticsearch.

Available Document Operations

Document Structure

In Elasticsearch, documents are JSON objects stored in an index. Each document has:

All document operations in the elasticsearch-php-client follow a similar pattern:

<?php
use Zvonchuk\Elastic\Core\IndexRequest;  // or other request types

$request = new IndexRequest('my_index');  // Specify the index
$request->id('document_id');              // Specify the document ID
$request->source([                        // Provide the document source
    'field1' => 'value1',
    'field2' => 'value2'
]);

$response = $client->index($request);     // Execute the operation

Browse the sections to learn more about each document operation.