Skip to content

Commit f7845ee

Browse files
committed
analyze removed support for request parameters. use json body parameters
1 parent 9efdbe5 commit f7845ee

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ All notable changes to this project will be documented in this file based on the
2626
- The geo_distance_range query, which was deprecated in 5.0, has been removed. [#1369](https://github.com/ruflin/Elastica/pull/1369)
2727
- The optimize_bbox parameter has been removed from geo_distance queries. [#1369](https://github.com/ruflin/Elastica/pull/1369)
2828
- The disable_coord parameter of the bool and common_terms queries has been removed. If provided, it will be ignored and issue a deprecation warning. [#1369](https://github.com/ruflin/Elastica/pull/1369)
29+
- [Unfiltered nested source](https://github.com/elastic/elasticsearch/pull/26102) should keep its full path [#1366](https://github.com/ruflin/Elastica/pull/1366)
30+
- [Analyze Explain](https://www.elastic.co/guide/en/elasticsearch/reference/6.0/_explain_analyze.html) no more support [request parameters](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/indices-analyze.html), use request body instead. [#1370](https://github.com/ruflin/Elastica/pull/1370)
31+
2932
### Bugfixes
3033
- Enforce [Content-Type requirement on the layer Rest](https://github.com/elastic/elasticsearch/pull/23146), a [PR on Elastica #1301](https://github.com/ruflin/Elastica/issues/1301) solved it (it has been implemented only in the HTTP Transport), but it was not implemented in the Guzzle Transport. [#1349](https://github.com/ruflin/Elastica/pull/1349)
3134
- Scroll no longer does an extra iteration both on an empty result and on searches where the last page has a significantly smaller number of results than the pages before it.

lib/Elastica/Index.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -548,24 +548,24 @@ public function requestEndpoint(AbstractEndpoint $endpoint)
548548
*
549549
* Detailed arguments can be found here in the link
550550
*
551-
* @param string $text String to be analyzed
551+
* @param array $body String to be analyzed
552552
* @param array $args OPTIONAL Additional arguments
553553
*
554554
* @return array Server response
555555
*
556556
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html
557557
*/
558-
public function analyze($text, $args = [])
558+
public function analyze(array $body, $args = [])
559559
{
560560
$endpoint = new Analyze();
561-
$endpoint->setBody(['text' => $text]);
561+
$endpoint->setBody($body);
562562
$endpoint->setParams($args);
563563

564564
$data = $this->requestEndpoint($endpoint)->getData();
565565

566566
// Support for "Explain" parameter, that returns a different response structure from Elastic
567567
// @see: https://www.elastic.co/guide/en/elasticsearch/reference/current/_explain_analyze.html
568-
if (isset($args['explain']) && $args['explain']) {
568+
if (isset($body['explain']) && $body['explain']) {
569569
return $data['detail'];
570570
}
571571

test/Elastica/IndexTest.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ public function testAnalyze()
928928
{
929929
$index = $this->_createIndex();
930930
$index->refresh();
931-
$returnedTokens = $index->analyze('foo');
931+
$returnedTokens = $index->analyze(['text' => 'foo']);
932932

933933
$tokens = [
934934
[
@@ -973,11 +973,9 @@ public function testRequestEndpoint()
973973
*/
974974
public function testAnalyzeExplain()
975975
{
976-
$this->markTestSkipped('ES6 update: request contains unrecognized parameter: [explain]');
977-
978976
$index = $this->_createIndex();
979977
$index->refresh();
980-
$data = $index->analyze('foo', ['explain' => true]);
978+
$data = $index->analyze(['text' => 'foo', 'explain' => true], []);
981979

982980
$this->assertArrayHasKey('custom_analyzer', $data);
983981
}

0 commit comments

Comments
 (0)