DeleteByQuery.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace Elasticsearch\Endpoints;
  3. use Elasticsearch\Common\Exceptions;
  4. /**
  5. * Class Deletebyquery
  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 DeleteByQuery extends AbstractEndpoint
  14. {
  15. /**
  16. * @param array $body
  17. *
  18. * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
  19. * @return $this
  20. */
  21. public function setBody($body)
  22. {
  23. if (isset($body) !== true) {
  24. return $this;
  25. }
  26. $this->body = $body;
  27. return $this;
  28. }
  29. /**
  30. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  31. * @return string
  32. */
  33. public function getURI()
  34. {
  35. if (!$this->index) {
  36. throw new Exceptions\RuntimeException(
  37. 'index is required for Deletebyquery'
  38. );
  39. }
  40. $uri = "/{$this->index}/_delete_by_query";
  41. if ($this->type) {
  42. $uri = "/{$this->index}/{$this->type}/_delete_by_query";
  43. }
  44. return $uri;
  45. }
  46. /**
  47. * @return string[]
  48. */
  49. public function getParamWhitelist()
  50. {
  51. return array(
  52. '_source',
  53. '_source_exclude',
  54. '_source_include',
  55. 'allow_no_indices',
  56. 'analyze_wildcard',
  57. 'analyzer',
  58. 'conflicts',
  59. 'default_operator',
  60. 'df',
  61. 'expand_wildcards',
  62. 'from',
  63. 'ignore_unavailable',
  64. 'lenient',
  65. 'preference',
  66. 'query',
  67. 'q',
  68. 'refresh',
  69. 'request_cache',
  70. 'requests_per_second',
  71. 'routing',
  72. 'scroll',
  73. 'scroll_size',
  74. 'search_timeout',
  75. 'search_type',
  76. 'size',
  77. 'slices',
  78. 'sort',
  79. 'stats',
  80. 'terminate_after',
  81. 'timeout',
  82. 'version',
  83. 'wait_for_active_shards',
  84. 'wait_for_completion',
  85. );
  86. }
  87. /**
  88. * @return string
  89. */
  90. public function getMethod()
  91. {
  92. return 'POST';
  93. }
  94. }