diff --git a/src/Elasticsearch/Client.php b/src/Elasticsearch/Client.php index 7bb64c972..3d28b2456 100644 --- a/src/Elasticsearch/Client.php +++ b/src/Elasticsearch/Client.php @@ -1344,6 +1344,33 @@ public function fieldStats($params = array()) return $this->performRequest($endpoint); } + /** + * $params['index'] = (list) A comma-separated list of indices to restrict the results + * ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed) + * ['allow_no_indices'] = (bool) Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * ['expand_wildcards'] = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both. + * + * @param $params array Associative array of parameters + * + * @return array + */ + public function fieldCaps($params = array()) + { + $index = $this->extractArgument($params, 'index'); + $body = $this->extractArgument($params, 'body'); + + /** @var callback $endpointBuilder */ + $endpointBuilder = $this->endpoints; + + /** @var \Elasticsearch\Endpoints\FieldCaps $endpoint */ + $endpoint = $endpointBuilder('FieldCaps'); + $endpoint->setIndex($index) + ->setBody($body) + ->setParams($params); + + return $this->performRequest($endpoint); + } + /** * $params['id'] = (string) ID of the template to render * diff --git a/src/Elasticsearch/Endpoints/FieldCaps.php b/src/Elasticsearch/Endpoints/FieldCaps.php new file mode 100644 index 000000000..33e53bc24 --- /dev/null +++ b/src/Elasticsearch/Endpoints/FieldCaps.php @@ -0,0 +1,69 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 + * @link http://elastic.co + */ +class FieldCaps extends AbstractEndpoint +{ + /** + * @param array $body + * + * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException + * @return $this + */ + public function setBody($body) + { + if (isset($body) !== true) { + return $this; + } + + $this->body = $body; + return $this; + } + + /** + * @return string + */ + public function getURI() + { + $index = $this->index; + + if (isset($index) === true ) { + return "/$index/_field_caps"; + } else { + return "/_field_caps"; + } + } + + /** + * @return string[] + */ + public function getParamWhitelist() + { + return array( + 'fields', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards' + ); + } + + /** + * @return string + */ + public function getMethod() + { + return 'GET'; + } +}