public function document($value, $id = null, $update = false)
    {
        if (!$this->batch instanceof BatchCommand) {
                        throw new exceptions\RuntimeException("Cannot add a new document to an external BatchCommandInterface");
        }

        $this->finalizeCurrentCommand();


        if (is_array($value)) {
            $this->params['doc'] = $value;

        } elseif (is_string($value)) {
            $this->params['doc'] = json_decode($value, true);
        }

        if ($id !== null) {
            $this->currentCommand->id($id)
                ->action('put');

            $this->params['update'] = $update;

        } else {
            $this->currentCommand->action('post');

            $this->params['update'] = false;
        }


        return $this;
    }
public function document($value, $id = null, $update = false)
    {
        if (!$this->batch instanceof BatchCommand) {
                        throw new exceptions\RuntimeException("Cannot add a new document to an external BatchCommandInterface");
        }

        $this->finalizeCurrentCommand();


        if (is_array($value)) {
            $this->params['doc'] = $value;

        } elseif (is_string($value)) {
            $this->params['doc'] = json_decode($value, true);
        }

        if ($id !== null) {
            $this->currentCommand->id($id)
                ->action('put');

            $this->params['update'] = $update;

        } else {
            $this->currentCommand->action('post');

            $this->params['update'] = false;
        }


        return $this;
    }
public function document ( $ value , $ id = null , $ update = false ) { if ( ! $ this -> batch instanceof BatchCommand ) { throw new exceptions \ RuntimeException ( "Cannot add a new document to an external BatchCommandInterface" ) ; } $ this -> finalizeCurrentCommand ( ) ; if ( is_array ( $ value ) ) { $ this -> params [ 'doc' ] = $ value ; } elseif ( is_string ( $ value ) ) { $ this -> params [ 'doc' ] = json_decode ( $ value , true ) ; } if ( $ id !== null ) { $ this -> currentCommand -> id ( $ id ) -> action ( 'put' ) ; $ this -> params [ 'update' ] = $ update ; } else { $ this -> currentCommand -> action ( 'post' ) ; $ this -> params [ 'update' ] = false ; } return $ this ; }
The document to index

@param  \string|\array $value
@param  null           $id
@param bool|null       $update

@throws \Sherlock\common\exceptions\RuntimeException
@return IndexDocumentRequest
The document to index