Elastica\Bulk::addData PHP Method

addData() public method

public addData ( Elastica\Script\AbstractScript | Document | array $data, string $opType = null )
$data Elastica\Script\AbstractScript | Document | array
$opType string
    public function addData($data, $opType = null)
    {
        if (!is_array($data)) {
            $data = [$data];
        }
        foreach ($data as $actionData) {
            if ($actionData instanceof AbstractScript) {
                $this->addScript($actionData, $opType);
            } elseif ($actionData instanceof Document) {
                $this->addDocument($actionData, $opType);
            } else {
                throw new \InvalidArgumentException('Data should be a Document, a Script or an array containing Documents and/or Scripts');
            }
        }
        return $this;
    }