Skip to content

Commit da872d5

Browse files
committed
Updated CHANGELOG + fixed CS issues
2 parents 3331fe5 + acbc76d commit da872d5

24 files changed

+301
-19
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Release 6.7.1
2+
3+
- Fix #846 choosing `GET` and `POST` in endpoints based on body [[acbc76d0]](https://github.com/elastic/elasticsearch-php/commit/acbc76d0)
4+
- Fix #843 adding `wait_for_active_shards` and `pipeline` in `UpdateByQuery` [[acbc76d0]](https://github.com/elastic/elasticsearch-php/commit/acbc76d0)
5+
- Fixed missing `ScriptsPainlessExecute` endpoint, since ES 6.3 [[acbc76d0]](https://github.com/elastic/elasticsearch-php/commit/acbc76d0)
6+
- Fixed missing `RankEval` endpoint, since ES 6.2 [[acbc76d0]](https://github.com/elastic/elasticsearch-php/commit/acbc76d0)
7+
- Added User-Agent header equal to `elasticsearch-php/6.7.1 (metadata-values)` [[acbc76d0]](https://github.com/elastic/elasticsearch-php/commit/acbc76d0)
8+
19
## Release 6.7.0
210

311
- Removed requirement of `{type}` part in `indices.put_mapping`, see new API specification [here](https://github.com/elastic/elasticsearch/blob/v6.7.0/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_mapping.json)
@@ -29,7 +37,7 @@
2937
- [DOCS] Update `community.asciidoc`, added `ElasticSearchQueryDSL` project [#749](https://github.com/elastic/elasticsearch-php/pull/749)
3038
- [DOCS] Proper return type array for get method for `IndicesNamespace` [#651](https://github.com/elastic/elasticsearch-php/pull/651)
3139
- [DOCS] Fix full docs link [#862](https://github.com/elastic/elasticsearch-php/pull/862)
32-
- [DOCS] Update breaking-changes.asciidoc, removal of ClientBuilder::defaultLogger() [879](https://github.com/elastic/elasticsearch-php/pull/879)
40+
- [DOCS] Update breaking-changes.asciidoc, removal of ClientBuilder::defaultLogger() [#879](https://github.com/elastic/elasticsearch-php/pull/879)
3341

3442
### Testing
3543

src/Elasticsearch/Client.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
*/
3535
class Client
3636
{
37+
const VERSION = '6.7.1';
38+
3739
/**
3840
* @var Transport
3941
*/
@@ -155,6 +157,39 @@ public function ping($params = [])
155157
return true;
156158
}
157159

160+
/**
161+
* $params['body'] = (string) The ranking evaluation search definition, including
162+
* search requests, document ratings and ranking metric definition (Required)
163+
* ['index'] = (list) A comma-separated list of index names to search; use `_all` or
164+
* empty string to perform the operation on all indices
165+
* ['ignore_unavailable'] = (boolean) Whether specified concrete indices should be
166+
* ignored when unavailable (missing or closed)
167+
* ['allow_no_indices'] = (boolean) Whether to ignore if a wildcard indices expression
168+
* resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
169+
* ['expand_wildcards'] = (enum) Whether to expand wildcard expression to concrete indices that are open,
170+
* closed or both.
171+
*
172+
* @return callable|array
173+
*/
174+
public function rankEval(array $params)
175+
{
176+
$body = $this->extractArgument($params, 'body');
177+
$index = $this->extractArgument($params, 'index');
178+
/**
179+
* @var callable $endpointBuilder
180+
*/
181+
$endpointBuilder = $this->endpoints;
182+
/**
183+
* @var \Elasticsearch\Endpoints\RankEval $endpoint
184+
*/
185+
$endpoint = $endpointBuilder('RankEval');
186+
$endpoint->setBody($body)
187+
->setIndex($index);
188+
$endpoint->setParams($params);
189+
190+
return $this->performRequest($endpoint);
191+
}
192+
158193
/**
159194
* $params['id'] = (string) The document ID (Required)
160195
* ['index'] = (string) The name of the index (Required)
@@ -1021,6 +1056,27 @@ public function scroll($params = array())
10211056
return $this->performRequest($endpoint);
10221057
}
10231058

1059+
/**
1060+
* $params['body'] = (string) The script to execute
1061+
*
1062+
* @return callable|array
1063+
*/
1064+
public function scriptsPainlessExecute(array $params = [])
1065+
{
1066+
$body = $this->extractArgument($params, 'body');
1067+
/**
1068+
* @var callable $endpointBuilder
1069+
*/
1070+
$endpointBuilder = $this->endpoints;
1071+
/**
1072+
* @var \Elasticsearch\Endpoints\ScriptsPainlessExecute $endpoint
1073+
*/
1074+
$endpoint = $endpointBuilder('ScriptsPainlessExecute');
1075+
$endpoint->setBody($body);
1076+
$endpoint->setParams($params);
1077+
return $this->performRequest($endpoint);
1078+
}
1079+
10241080
/**
10251081
* $params['scroll_id'] = (string) The scroll ID for scrolled search
10261082
* ['scroll'] = (duration) Specify how long a consistent view of the index should be maintained for scrolled search

src/Elasticsearch/Connections/Connection.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Elasticsearch\Connections;
66

7+
use Elasticsearch\Client;
78
use Elasticsearch\Common\Exceptions\AlreadyExpiredException;
89
use Elasticsearch\Common\Exceptions\BadRequest400Exception;
910
use Elasticsearch\Common\Exceptions\Conflict409Exception;
@@ -126,6 +127,15 @@ public function __construct(
126127
unset($connectionParams['client']['headers']);
127128
}
128129

130+
// Add the User-Agent using the format: <client-repo-name>/<client-version> (metadata-values)
131+
$this->headers['User-Agent'] = [sprintf(
132+
"elasticsearch-php/%s (%s %s, PHP %s)",
133+
Client::VERSION,
134+
php_uname("s"),
135+
php_uname("r"),
136+
phpversion()
137+
)];
138+
129139
$host = $hostDetails['host'].':'.$hostDetails['port'];
130140
$path = null;
131141
if (isset($hostDetails['path']) === true) {
@@ -179,6 +189,12 @@ public function performRequest($method, $uri, $params = null, $body = null, $opt
179189
return $future;
180190
}
181191

192+
/** @return array */
193+
public function getHeaders()
194+
{
195+
return $this->headers;
196+
}
197+
182198
/** @return string */
183199
public function getTransportSchema()
184200
{

src/Elasticsearch/Endpoints/Cluster/AllocationExplain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ public function getParamWhitelist()
5959
*/
6060
public function getMethod()
6161
{
62-
return 'GET';
62+
return isset($this->body) ? 'POST' : 'GET';
6363
}
6464
}

src/Elasticsearch/Endpoints/Count.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ public function getParamWhitelist()
8484
*/
8585
public function getMethod()
8686
{
87-
return 'GET';
87+
return isset($this->body) ? 'POST' : 'GET';
8888
}
8989
}

src/Elasticsearch/Endpoints/Explain.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,6 @@ public function getParamWhitelist()
9999
*/
100100
public function getMethod()
101101
{
102-
return 'GET';
102+
return isset($this->body) ? 'POST' : 'GET';
103103
}
104104
}

src/Elasticsearch/Endpoints/FieldCaps.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ public function getParamWhitelist()
6666
*/
6767
public function getMethod()
6868
{
69-
return 'GET';
69+
return isset($this->body) ? 'POST' : 'GET';
7070
}
7171
}

src/Elasticsearch/Endpoints/Indices/Analyze.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,6 @@ public function getParamWhitelist()
7676
*/
7777
public function getMethod()
7878
{
79-
return 'GET';
79+
return isset($this->body) ? 'POST' : 'GET';
8080
}
8181
}

src/Elasticsearch/Endpoints/Indices/ClearCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ public function getParamWhitelist()
5959
*/
6060
public function getMethod()
6161
{
62-
return 'GET';
62+
return isset($this->body) ? 'POST' : 'GET';
6363
}
6464
}

src/Elasticsearch/Endpoints/Indices/Flush.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ public function getParamWhitelist()
6363
*/
6464
public function getMethod()
6565
{
66-
return 'GET';
66+
return isset($this->body) ? 'POST' : 'GET';
6767
}
6868
}

0 commit comments

Comments
 (0)