src/Query.php
public function bulk($data)
    {

        if (is_callback_function($data)) {

            $bulk = new Bulk($this);

            $data($bulk);

            $params = $bulk->body();

        } else {

            $params = [];

            foreach ($data as $key => $value) {

                $params["body"][] = [

                    'index' => [
                        '_index' => $this->getIndex(),
                        '_type' => $this->getType(),
                        '_id' => $key
                    ]

                ];

                $params["body"][] = $value;

            }

        }

        return (object)$this->connection->bulk($params);
    }
public function bulk($data)
    {

        if (is_callback_function($data)) {

            $bulk = new Bulk($this);

            $data($bulk);

            $params = $bulk->body();

        } else {

            $params = [];

            foreach ($data as $key => $value) {

                $params["body"][] = [

                    'index' => [
                        '_index' => $this->getIndex(),
                        '_type' => $this->getType(),
                        '_id' => $key
                    ]

                ];

                $params["body"][] = $value;

            }

        }

        return (object)$this->connection->bulk($params);
    }
public function bulk ( $ data ) { if ( is_callback_function ( $ data ) ) { $ bulk = new Bulk ( $ this ) ; $ data ( $ bulk ) ; $ params = $ bulk -> body ( ) ; } else { $ params = [ ] ; foreach ( $ data as $ key => $ value ) { $ params [ "body" ] [ ] = [ 'index' => [ '_index' => $ this -> getIndex ( ) , '_type' => $ this -> getType ( ) , '_id' => $ key ] ] ; $ params [ "body" ] [ ] = $ value ; } } return ( object ) $ this -> connection -> bulk ( $ params ) ; }
Insert a bulk of documents
@param $data multidimensional array of [id => data] pairs
@return object
Insert a bulk of documents