Skip to content

Commit

Permalink
Add FieldCaps endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Jul 19, 2017
1 parent 82121d9 commit 0acccc6
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Elasticsearch/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
69 changes: 69 additions & 0 deletions src/Elasticsearch/Endpoints/FieldCaps.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Elasticsearch\Endpoints;

use Elasticsearch\Common\Exceptions\InvalidArgumentException;
use Elasticsearch\Common\Exceptions;

/**
* Class FieldCaps
*
* @category Elasticsearch
* @package Elasticsearch\Endpoints
* @author Zachary Tong <[email protected]>
* @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';
}
}

0 comments on commit 0acccc6

Please sign in to comment.