Count.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace Elasticsearch\Endpoints;
  3. use Elasticsearch\Common\Exceptions;
  4. /**
  5. * Class Count
  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 Count 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. * @return string
  31. */
  32. public function getURI()
  33. {
  34. $index = $this->index;
  35. $type = $this->type;
  36. $uri = "/_count";
  37. if (isset($index) === true && isset($type) === true) {
  38. $uri = "/$index/$type/_count";
  39. } elseif (isset($type) === true) {
  40. $uri = "/_all/$type/_count";
  41. } elseif (isset($index) === true) {
  42. $uri = "/$index/_count";
  43. }
  44. return $uri;
  45. }
  46. /**
  47. * @return string[]
  48. */
  49. public function getParamWhitelist()
  50. {
  51. return array(
  52. 'ignore_unavailable',
  53. 'allow_no_indices',
  54. 'expand_wildcards',
  55. 'min_score',
  56. 'preference',
  57. 'routing',
  58. 'source',
  59. 'q',
  60. 'df',
  61. 'default_operator',
  62. 'analyzer',
  63. 'lowercase_expanded_terms',
  64. 'analyze_wildcard',
  65. 'lenient',
  66. 'lowercase_expanded_terms',
  67. 'terminate_after'
  68. );
  69. }
  70. /**
  71. * @return string
  72. */
  73. public function getMethod()
  74. {
  75. return 'GET';
  76. }
  77. }