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
}

src/Elasticsearch/Endpoints/Indices/ValidateQuery.php

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

src/Elasticsearch/Endpoints/Ingest/Simulate.php

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

src/Elasticsearch/Endpoints/MTermVectors.php

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

src/Elasticsearch/Endpoints/Msearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ public function getBody()
104104
*/
105105
public function getMethod()
106106
{
107-
return 'GET';
107+
return isset($this->body) ? 'POST' : 'GET';
108108
}
109109
}

src/Elasticsearch/Endpoints/MsearchTemplate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ public function getBody()
102102
*/
103103
public function getMethod()
104104
{
105-
return 'GET';
105+
return isset($this->body) ? 'POST' : 'GET';
106106
}
107107
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
declare(strict_types = 1);
3+
4+
namespace Elasticsearch\Endpoints;
5+
6+
/**
7+
* Class RankEval
8+
*
9+
* @category Elasticsearch
10+
* @package Elasticsearch\Endpoints
11+
* @author Enrico Zimuel <[email protected]>
12+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
13+
* @link http://elastic.co
14+
*/
15+
class RankEval extends AbstractEndpoint
16+
{
17+
/**
18+
* @return array
19+
*/
20+
public function getParamWhitelist()
21+
{
22+
return [
23+
'ignore_unavailable',
24+
'allow_no_indices',
25+
'expand_wildcards'
26+
];
27+
}
28+
29+
/**
30+
* @return string
31+
*/
32+
public function getURI()
33+
{
34+
$index = $this->index ?? null;
35+
if (isset($index)) {
36+
return "/$index/_rank_eval";
37+
}
38+
return '/_rank_eval';
39+
}
40+
41+
/**
42+
* @return string
43+
*/
44+
public function getMethod()
45+
{
46+
return 'POST';
47+
}
48+
49+
/**
50+
* @param array $body
51+
* @return $this
52+
*/
53+
public function setBody($body)
54+
{
55+
if (isset($body) !== true) {
56+
return $this;
57+
}
58+
$this->body = $body;
59+
return $this;
60+
}
61+
}

src/Elasticsearch/Endpoints/RenderSearchTemplate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ public function getBody()
7474
*/
7575
public function getMethod()
7676
{
77-
return 'GET';
77+
return isset($this->body) ? 'POST' : 'GET';
7878
}
7979
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
declare(strict_types = 1);
4+
5+
namespace Elasticsearch\Endpoints;
6+
7+
use Elasticsearch\Common\Exceptions\RuntimeException;
8+
9+
/**
10+
* Class Reindex
11+
*
12+
* @category Elasticsearch
13+
* @package Elasticsearch\Endpoints
14+
* @author Enrico Zimuel <[email protected]>
15+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
16+
* @link http://elastic.co
17+
*/
18+
class ScriptsPainlessExecute extends AbstractEndpoint
19+
{
20+
/**
21+
* @return array
22+
*/
23+
public function getParamWhitelist()
24+
{
25+
return [];
26+
}
27+
28+
/**
29+
* @return string
30+
*/
31+
public function getURI()
32+
{
33+
return "/_scripts/painless/_execute";
34+
}
35+
36+
/**
37+
* @return string
38+
*/
39+
public function getMethod()
40+
{
41+
return isset($this->body) ? 'POST' : 'GET';
42+
}
43+
44+
/**
45+
* @param array $body
46+
* @return $this
47+
*/
48+
public function setBody($body)
49+
{
50+
if (isset($body) !== true) {
51+
return $this;
52+
}
53+
54+
$this->body = $body;
55+
56+
return $this;
57+
}
58+
}

src/Elasticsearch/Endpoints/Scroll.php

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

src/Elasticsearch/Endpoints/Search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,6 @@ public function getParamWhitelist()
115115
*/
116116
public function getMethod()
117117
{
118-
return 'GET';
118+
return isset($this->body) ? 'POST' : 'GET';
119119
}
120120
}

src/Elasticsearch/Endpoints/SearchTemplate.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/TermVectors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,6 @@ public function getParamWhitelist()
9292
*/
9393
public function getMethod()
9494
{
95-
return 'POST';
95+
return isset($this->body) ? 'POST' : 'GET';
9696
}
9797
}

0 commit comments

Comments
 (0)