ValidateQuery.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace Elasticsearch\Endpoints\Indices;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class ValidateQuery
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Endpoints\Indices
  10. * @author Zachary Tong <zach@elastic.co>
  11. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  12. * @link http://elastic.co
  13. */
  14. class ValidateQuery extends AbstractEndpoint
  15. {
  16. /**
  17. * @param array $body
  18. *
  19. * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
  20. * @return $this
  21. */
  22. public function setBody($body)
  23. {
  24. if (isset($body) !== true) {
  25. return $this;
  26. }
  27. $this->body = $body;
  28. return $this;
  29. }
  30. /**
  31. * @return string
  32. */
  33. public function getURI()
  34. {
  35. $index = $this->index;
  36. $type = $this->type;
  37. $uri = "/_validate/query";
  38. if (isset($index) === true && isset($type) === true) {
  39. $uri = "/$index/$type/_validate/query";
  40. } elseif (isset($index) === true) {
  41. $uri = "/$index/_validate/query";
  42. }
  43. return $uri;
  44. }
  45. /**
  46. * @return string[]
  47. */
  48. public function getParamWhitelist()
  49. {
  50. return array(
  51. 'explain',
  52. 'ignore_unavailable',
  53. 'allow_no_indices',
  54. 'expand_wildcards',
  55. 'operation_threading',
  56. 'source',
  57. 'q',
  58. );
  59. }
  60. /**
  61. * @return string
  62. */
  63. public function getMethod()
  64. {
  65. return 'GET';
  66. }
  67. }