ClearScroll.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace Elasticsearch\Endpoints;
  3. use Elasticsearch\Common\Exceptions;
  4. /**
  5. * Class Clearscroll
  6. *
  7. * @category Elasticsearch
  8. * @package Elasticsearch\Endpoints
  9. * @author Zachary Tong <zach@elastic.co>
  10. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  11. * @link http://elastic.co
  12. */
  13. class ClearScroll extends AbstractEndpoint
  14. {
  15. // A comma-separated list of scroll IDs to clear
  16. private $scrollId;
  17. /**
  18. * @param $scroll_id
  19. *
  20. * @return $this
  21. */
  22. public function setScrollId($scrollId)
  23. {
  24. if (isset($scrollId) !== true) {
  25. return $this;
  26. }
  27. $this->scrollId = $scrollId;
  28. return $this;
  29. }
  30. /**
  31. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  32. * @return string
  33. */
  34. public function getURI()
  35. {
  36. return "/_search/scroll/";
  37. }
  38. /**
  39. * @param array $body
  40. *
  41. * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
  42. * @return $this
  43. */
  44. public function setBody($body)
  45. {
  46. if (isset($body) !== true) {
  47. return $this;
  48. }
  49. $this->body = $body;
  50. return $this;
  51. }
  52. /**
  53. * @return array
  54. */
  55. public function getBody()
  56. {
  57. if (isset($this->body)) {
  58. return $this->body;
  59. }
  60. if (is_array($this->scrollId)) {
  61. return ['scroll_id' => $this->scrollId];
  62. }
  63. return ['scroll_id' => [$this->scrollId]];
  64. }
  65. /**
  66. * @return string[]
  67. */
  68. public function getParamWhitelist()
  69. {
  70. return array(
  71. );
  72. }
  73. /**
  74. * @return string
  75. */
  76. public function getMethod()
  77. {
  78. return 'DELETE';
  79. }
  80. }