CountPercolate.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. namespace Elasticsearch\Endpoints;
  3. use Elasticsearch\Common\Exceptions;
  4. /**
  5. * Class CountPercolate
  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 CountPercolate 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 (isset($this->index) !== true) {
  36. throw new Exceptions\RuntimeException(
  37. 'index is required for CountPercolate'
  38. );
  39. }
  40. if (isset($this->type) !== true) {
  41. throw new Exceptions\RuntimeException(
  42. 'type is required for CountPercolate'
  43. );
  44. }
  45. $index = $this->index;
  46. $type = $this->type;
  47. $id = $this->id;
  48. $uri = "/$index/$type/_percolate/count";
  49. if (isset($id) === true) {
  50. $uri = "/$index/$type/$id/_percolate/count";
  51. }
  52. return $uri;
  53. }
  54. /**
  55. * @return string[]
  56. */
  57. public function getParamWhitelist()
  58. {
  59. return array(
  60. 'routing',
  61. 'preference',
  62. 'ignore_unavailable',
  63. 'allow_no_indices',
  64. 'expand_wildcards',
  65. 'percolate_index',
  66. 'percolate_type',
  67. 'version',
  68. 'version_type'
  69. );
  70. }
  71. /**
  72. * @return string
  73. */
  74. public function getMethod()
  75. {
  76. return 'GET';
  77. }
  78. }