Json.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Elastica\Processor;
  3. /**
  4. * Elastica Json Processor.
  5. *
  6. * @author Federico Panini <fpanini@gmail.com>
  7. *
  8. * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/json-processor.html
  9. */
  10. class Json extends AbstractProcessor
  11. {
  12. public function __construct($field)
  13. {
  14. $this->setField($field);
  15. }
  16. /**
  17. * Set the field.
  18. *
  19. * @param string $field
  20. *
  21. * @return $this
  22. */
  23. public function setField(string $field)
  24. {
  25. return $this->setParam('field', $field);
  26. }
  27. /**
  28. * Set target_field. Default field.
  29. *
  30. * @param string $targetField
  31. *
  32. * @return $this
  33. */
  34. public function setTargetField(string $targetField)
  35. {
  36. return $this->setParam('target_field', $targetField);
  37. }
  38. /**
  39. * Set add_to_root. Default false.
  40. *
  41. * @param bool $addToRoot
  42. *
  43. * @return $this
  44. */
  45. public function setAddToRoot(bool $addToRoot)
  46. {
  47. return $this->setParam('add_to_root', $addToRoot);
  48. }
  49. }