Skip to content

Commit 0acccc6

Browse files
committed
Add FieldCaps endpoint
1 parent 82121d9 commit 0acccc6

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

src/Elasticsearch/Client.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,33 @@ public function fieldStats($params = array())
13441344
return $this->performRequest($endpoint);
13451345
}
13461346

1347+
/**
1348+
* $params['index'] = (list) A comma-separated list of indices to restrict the results
1349+
* ['ignore_unavailable'] = (bool) Whether specified concrete indices should be ignored when unavailable (missing or closed)
1350+
* ['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)
1351+
* ['expand_wildcards'] = (enum) Whether to expand wildcard expression to concrete indices that are open, closed or both.
1352+
*
1353+
* @param $params array Associative array of parameters
1354+
*
1355+
* @return array
1356+
*/
1357+
public function fieldCaps($params = array())
1358+
{
1359+
$index = $this->extractArgument($params, 'index');
1360+
$body = $this->extractArgument($params, 'body');
1361+
1362+
/** @var callback $endpointBuilder */
1363+
$endpointBuilder = $this->endpoints;
1364+
1365+
/** @var \Elasticsearch\Endpoints\FieldCaps $endpoint */
1366+
$endpoint = $endpointBuilder('FieldCaps');
1367+
$endpoint->setIndex($index)
1368+
->setBody($body)
1369+
->setParams($params);
1370+
1371+
return $this->performRequest($endpoint);
1372+
}
1373+
13471374
/**
13481375
* $params['id'] = (string) ID of the template to render
13491376
*
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Elasticsearch\Endpoints;
4+
5+
use Elasticsearch\Common\Exceptions\InvalidArgumentException;
6+
use Elasticsearch\Common\Exceptions;
7+
8+
/**
9+
* Class FieldCaps
10+
*
11+
* @category Elasticsearch
12+
* @package Elasticsearch\Endpoints
13+
* @author Zachary Tong <[email protected]>
14+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
15+
* @link http://elastic.co
16+
*/
17+
class FieldCaps extends AbstractEndpoint
18+
{
19+
/**
20+
* @param array $body
21+
*
22+
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
23+
* @return $this
24+
*/
25+
public function setBody($body)
26+
{
27+
if (isset($body) !== true) {
28+
return $this;
29+
}
30+
31+
$this->body = $body;
32+
return $this;
33+
}
34+
35+
/**
36+
* @return string
37+
*/
38+
public function getURI()
39+
{
40+
$index = $this->index;
41+
42+
if (isset($index) === true ) {
43+
return "/$index/_field_caps";
44+
} else {
45+
return "/_field_caps";
46+
}
47+
}
48+
49+
/**
50+
* @return string[]
51+
*/
52+
public function getParamWhitelist()
53+
{
54+
return array(
55+
'fields',
56+
'ignore_unavailable',
57+
'allow_no_indices',
58+
'expand_wildcards'
59+
);
60+
}
61+
62+
/**
63+
* @return string
64+
*/
65+
public function getMethod()
66+
{
67+
return 'GET';
68+
}
69+
}

0 commit comments

Comments
 (0)