Analyze.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Elasticsearch\Endpoints\Indices;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class Analyze
  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 Analyze 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. $uri = "/_analyze";
  37. if (isset($index) === true) {
  38. $uri = "/$index/_analyze";
  39. }
  40. return $uri;
  41. }
  42. /**
  43. * @return string[]
  44. */
  45. public function getParamWhitelist()
  46. {
  47. return array(
  48. 'analyzer',
  49. 'field',
  50. 'filter',
  51. 'index',
  52. 'prefer_local',
  53. 'text',
  54. 'tokenizer',
  55. 'format',
  56. 'char_filter',
  57. 'explain',
  58. 'attributes',
  59. 'format'
  60. );
  61. }
  62. /**
  63. * @return string
  64. */
  65. public function getMethod()
  66. {
  67. return 'GET';
  68. }
  69. }