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            '_type',
35            '_id',
36            'version',
37            'version_type',
38            'routing',
39            'parent',
40            'retry_on_conflict',
41        ]);
42    }
43}
44