1<?php
2
3namespace Elastica\Bulk\Action;
4
5use Elastica\AbstractUpdateAction;
6use Elastica\Document;
7
8class IndexDocument extends AbstractDocument
9{
10    /**
11     * @var string
12     */
13    protected $_opType = self::OP_TYPE_INDEX;
14
15    /**
16     * {@inheritdoc}
17     */
18    public function setDocument(Document $document): AbstractDocument
19    {
20        parent::setDocument($document);
21
22        $this->setSource($document->getData());
23
24        return $this;
25    }
26
27    /**
28     * {@inheritdoc}
29     */
30    protected function _getMetadata(AbstractUpdateAction $action): array
31    {
32        return $action->getOptions([
33            '_index',
34            '_id',
35            'version',
36            'version_type',
37            'routing',
38            'parent',
39            'retry_on_conflict',
40        ]);
41    }
42}
43