Get.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace Elasticsearch\Endpoints\Indices\Field;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class Get
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Endpoints\Indices\Field
  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 Get extends AbstractEndpoint
  15. {
  16. // A comma-separated list of fields
  17. private $field;
  18. /**
  19. * @param $field
  20. *
  21. * @return $this
  22. */
  23. public function setField($field)
  24. {
  25. if (isset($field) !== true) {
  26. return $this;
  27. }
  28. $this->field = $field;
  29. return $this;
  30. }
  31. /**
  32. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  33. * @return string
  34. */
  35. public function getURI()
  36. {
  37. if (isset($this->field) !== true) {
  38. throw new Exceptions\RuntimeException(
  39. 'field is required for Get'
  40. );
  41. }
  42. $index = $this->index;
  43. $type = $this->type;
  44. $field = $this->field;
  45. $uri = "/_mapping/field/$field";
  46. if (isset($index) === true && isset($type) === true && isset($field) === true) {
  47. $uri = "/$index/_mapping/$type/field/$field";
  48. } elseif (isset($type) === true && isset($field) === true) {
  49. $uri = "/_mapping/$type/field/$field";
  50. } elseif (isset($index) === true && isset($field) === true) {
  51. $uri = "/$index/_mapping/field/$field";
  52. } elseif (isset($field) === true) {
  53. $uri = "/_mapping/field/$field";
  54. }
  55. return $uri;
  56. }
  57. /**
  58. * @return string[]
  59. */
  60. public function getParamWhitelist()
  61. {
  62. return array(
  63. 'include_defaults',
  64. 'ignore_unavailable',
  65. 'allow_no_indices',
  66. 'expand_wildcards',
  67. 'local',
  68. );
  69. }
  70. /**
  71. * @return string
  72. */
  73. public function getMethod()
  74. {
  75. return 'GET';
  76. }
  77. }