public function bulkSave($collection = [])
    {
        $params = [];

        $defaultIndex = $this->connection->getDefaultIndex();

        foreach ($collection as $item) {
            $modelIndex = $item->getDocumentIndex();

            $params['body'][] = [
                'index' => [
                    '_id'    => $item->getKey(),
                    '_type'  => $item->getDocumentType(),
                    '_index' => $modelIndex ? $modelIndex : $defaultIndex,
                ],
            ];
            $params['body'][] = $item->getDocumentData();
        }

        return $this->connection->bulkStatement($params);
    }
public function bulkSave($collection = [])
    {
        $params = [];

        $defaultIndex = $this->connection->getDefaultIndex();

        foreach ($collection as $item) {
            $modelIndex = $item->getDocumentIndex();

            $params['body'][] = [
                'index' => [
                    '_id'    => $item->getKey(),
                    '_type'  => $item->getDocumentType(),
                    '_index' => $modelIndex ? $modelIndex : $defaultIndex,
                ],
            ];
            $params['body'][] = $item->getDocumentData();
        }

        return $this->connection->bulkStatement($params);
    }
public function bulkSave ( $ collection = [ ] ) { $ params = [ ] ; $ defaultIndex = $ this -> connection -> getDefaultIndex ( ) ; foreach ( $ collection as $ item ) { $ modelIndex = $ item -> getDocumentIndex ( ) ; $ params [ 'body' ] [ ] = [ 'index' => [ '_id' => $ item -> getKey ( ) , '_type' => $ item -> getDocumentType ( ) , '_index' => $ modelIndex ? $ modelIndex : $ defaultIndex , ] , ] ; $ params [ 'body' ] [ ] = $ item -> getDocumentData ( ) ; } return $ this -> connection -> bulkStatement ( $ params ) ; }
Bulk save a collection Models.

@param array|Collection $collection

@return mixed
Bulk save a collection Models .