Elasticsearch\Bulk::index PHP Метод

index() публичный Метод

Index a new document or update it if existing
public index ( array $document, mixed $id = null, string $index, string $type, array $options = [] ) : Bulk
$document array
$id mixed Optional
$index string Index
$type string Type
$options array Allow sending query parameters to control indexing further _refresh_ *bool* If set to true, immediately refresh the shard after indexing
Результат Bulk
    public function index($document, $id = null, $index, $type, array $options = array())
    {
        $params = array('_id' => $id, '_index' => $index, '_type' => $type);
        foreach ($options as $key => $value) {
            $params['_' . $key] = $value;
        }
        $operation = array(array('index' => $params), $document);
        $this->operations[] = $operation;
        return $this;
    }

Usage Example

Пример #1
0
 /**
  * Index a new document or update it if existing
  *
  * @return array
  * @param array $document
  * @param mixed $id Optional
  * @param array $options Allow sending query parameters to control indexing further
  *        _refresh_ *bool* If set to true, immediately refresh the shard after indexing
  */
 public function index($document, $id = false, $options = array())
 {
     if ($this->bulk) {
         return $this->bulk->index($document, $id, $this->index, $this->type, $options);
     }
     return $this->transport->index($document, $id, $options);
 }