Convert.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Elastica\Processor;
  3. /**
  4. * Elastica Convert Processor.
  5. *
  6. * @author Federico Panini <fpanini@gmail.com>
  7. *
  8. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/append-processor.html
  9. */
  10. class Convert extends AbstractProcessor
  11. {
  12. public function __construct($field, $type)
  13. {
  14. $this->setField($field);
  15. $this->setType($type);
  16. }
  17. /**
  18. * Set field.
  19. *
  20. * @param string $field
  21. *
  22. * @return $this
  23. */
  24. public function setField(string $field)
  25. {
  26. return $this->setParam('field', $field);
  27. }
  28. /**
  29. * Set field value.
  30. *
  31. * @param string $type
  32. *
  33. * @return $this
  34. */
  35. public function setType(string $type)
  36. {
  37. return $this->setParam('type', $type);
  38. }
  39. /**
  40. * Set target_field. Default value field.
  41. *
  42. * @param string $targetField
  43. *
  44. * @return $this
  45. */
  46. public function setTargetField(string $targetField)
  47. {
  48. return $this->setParam('target_field', $targetField);
  49. }
  50. /**
  51. * Set ignore_missing. Default value false.
  52. *
  53. * @param bool $ignoreMissing only these values are allowed (integer|float|string|boolean|auto)
  54. *
  55. * @return $this
  56. */
  57. public function setIgnoreMissing(bool $ignoreMissing)
  58. {
  59. return $this->setParam('ignore_missing', $ignoreMissing);
  60. }
  61. }