IndexDocument.php 972 B

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