Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for 6.1.0 release #1547

Merged
merged 3 commits into from Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .php_cs
Expand Up @@ -25,7 +25,7 @@ $config = Symfony\CS\Config\Config::create()
'no_useless_else',
// [contrib] Use dedicated PHPUnit assertions for better error messages.
'@PHPUnit60Migration:risky' => true,
'php_unit_dedicate_assert' => ['target' => 'newest'],
//'php_unit_dedicate_assert' => ['target' => 'newest'],
])
->finder($finder);

Expand Down
61 changes: 34 additions & 27 deletions CHANGELOG.md
@@ -1,51 +1,58 @@
# Change Log
All notable changes to this project will be documented in this file based on the [Keep a Changelog](http://keepachangelog.com/) Standard. This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased](https://github.com/ruflin/Elastica/compare/6.0.2...master)
## [Unreleased](https://github.com/ruflin/Elastica/compare/6.1.0...master)

### Backward Compatibility Breaks

* Made result sets adhere to `\Iterator` interface definition that they implement. Specifically, you need to call `valid()` on the result set before calling `current()`. When using `foreach` this is done by PHP automatically. When `valid` returns false, the return value of `current` is undefined instead of false.
### Bugfixes

### Added

### Improvements

### Deprecated

## [6.1.0](https://github.com/ruflin/Elastica/compare/6.0.2...6.1.0)

### Backward Compatibility Breaks

* Made result sets adhere to `\Iterator` interface definition that they implement. Specifically, you need to call `valid()` on the result set before calling `current()`. When using `foreach` this is done by PHP automatically. When `valid` returns false, the return value of `current` is undefined instead of false. [#1506](https://github.com/ruflin/Elastica/pull/1506)
p365labs marked this conversation as resolved.
Show resolved Hide resolved
* `\Elastica\ResultSet::next` returns `void` instead of `\Elastica\Result|false`
* `\Elastica\Bulk\ResponseSet::current` returns `\Elastica\Bulk\Response` instead of `\Elastica\Bulk\Response|false`
* `\Elastica\Multi\ResultSet::current` returns `\Elastica\ResultSet` instead of `\Elastica\ResultSet|false`

### Added

* Added a transport class for mocking a HTTP 403 error codes, useful for testing response failures in inheriting clients
* [Field](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-random) param for `Elastica\Query\FunctionScore::addRandomScoreFunction` [#1529](https://github.com/ruflin/Elastica/pull/1529)
* [Index Recovery](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html) : the indices recovery API provides insight into on-going index shard recoveries. It was never been implemented into Elastica. [#1537](https://github.com/ruflin/Elastica/pull/1537)
* add parent_id (reference [#1518](https://github.com/ruflin/Elastica/issues/1518)) in QueryBuilder. [#1533]([#1518](https://github.com/ruflin/Elastica/issues/1533))
* implemented ```string_distance``` option in Term Suggestion [#1543](https://github.com/ruflin/Elastica/pull/1543)

### Improvements

* Using `Elastica\Query\FunctionScore::addRandomScoreFunction` without `$field` parameter is deprecated since ES 6.0 and will fail since ES 7.0 [#1522](https://github.com/ruflin/Elastica/pull/1522)
* `Aggreation\Percentiles` updated to a newer version of the Algorithm (T-Digest 3.2) and Percentiles results changed a bit Have a [look at here](https://github.com/elastic/elasticsearch/pull/28305), so updated tests in order not to fail. [#1531]([#1352](https://github.com/ruflin/Elastica/pull/1531))
* `Aggregation\Percentiles` have been updated since [Elasticsearch 2.3](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/search-aggregations-metrics-percentile-aggregation.html). In this version `compression, HDR histogram` changed their implementations. The `missing` field has never been implemented. [#1532](https://github.com/ruflin/Elastica/pull/1532)
p365labs marked this conversation as resolved.
Show resolved Hide resolved
Before

Before
```json
"compression" : 200,
"method" : "hdr",
"method" : "hdr",
"number_of_significant_value_digits" : 3
```

Now
Now
```json
"tdigest": {
"compression" : 200
"compression" : 200
},
"hdr": {
"number_of_significant_value_digits" : 3
"hdr": {
"number_of_significant_value_digits" : 3
}
```
* Never implemented the method *Missing* on [`Aggregation\Percentiles`](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/search-aggregations-metrics-percentile-aggregation.html)

### Bugfixes

### Added

* Added a transport class for mocking a HTTP 403 error codes, useful for testing response failures in inheriting clients
* [Field](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-random) param for `Elastica\Query\FunctionScore::addRandomScoreFunction`
* [Index Recovery](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html) : the indices recovery API provides insight into on-going index shard recoveries. It was never been implemented into Elastica. [#1537](https://github.com/ruflin/Elastica/pull/1537)
* add parent_id (reference [#1518](https://github.com/ruflin/Elastica/issues/1518)) in QueryBuilder. [#1533]([#1518](https://github.com/ruflin/Elastica/issues/1533))
* implemented ```string_distance``` option in Term Suggestion [#1543](https://github.com/ruflin/Elastica/pull/1543)

### Improvements

* Using `Elastica\Query\FunctionScore::addRandomScoreFunction` without `$field` parameter is deprecated since ES 6.0 and will fail since ES 7.0

### Deprecated

* Never implemented the method *Missing* on [`Aggregation\Percentiles`](https://www.elastic.co/guide/en/elasticsearch/reference/6.4/search-aggregations-metrics-percentile-aggregation.html) [#1532](https://github.com/ruflin/Elastica/pull/1532)

## [6.0.2](https://github.com/ruflin/Elastica/compare/6.0.1...6.0.2)

Expand Down
6 changes: 3 additions & 3 deletions lib/Elastica/Aggregation/Histogram.php
Expand Up @@ -9,9 +9,9 @@
class Histogram extends AbstractSimpleAggregation
{
/**
* @param string $name the name of this aggregation
* @param string $field the name of the field on which to perform the aggregation
* @param int|string $interval the interval by which documents will be bucketed
* @param string $name the name of this aggregation
* @param string $field the name of the field on which to perform the aggregation
* @param int|string $interval the interval by which documents will be bucketed
*/
public function __construct($name, $field, $interval)
{
Expand Down
12 changes: 7 additions & 5 deletions lib/Elastica/Aggregation/Percentiles.php
Expand Up @@ -30,28 +30,30 @@ public function __construct($name, $field = null)
*/
public function setCompression(float $value): Percentiles
{
$compression = array('compression' => $value);
$compression = ['compression' => $value];

return $this->setParam('tdigest', $compression);
}

/**
* Set hdr parameter.
*
* @param string $key
* @param float $value
* @param float $value
*
* @return Percentiles $this
*/
public function setHdr(string $key, float $value): Percentiles
{
$compression = array($key => $value);
$compression = [$key => $value];

return $this->setParam('hdr', $compression);
}

/**
* the keyed flag is set to true which associates a unique string
* key with each bucket and returns the ranges as a hash
* rather than an array
* rather than an array.
*
* @param bool $keyed
*
Expand Down Expand Up @@ -88,7 +90,7 @@ public function addPercent(float $percent): Percentiles

/**
* Defines how documents that are missing a value should
* be treated
* be treated.
*
* @param float $missing
*
Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Index.php
Expand Up @@ -3,9 +3,9 @@

use Elastica\Exception\InvalidException;
use Elastica\Exception\ResponseException;
use Elastica\Index\Recovery as IndexRecovery;
use Elastica\Index\Settings as IndexSettings;
use Elastica\Index\Stats as IndexStats;
use Elastica\Index\Recovery as IndexRecovery;
use Elastica\ResultSet\BuilderInterface;
use Elastica\Script\AbstractScript;
use Elasticsearch\Endpoints\AbstractEndpoint;
Expand Down
4 changes: 2 additions & 2 deletions lib/Elastica/Index/Recovery.php
Expand Up @@ -87,7 +87,7 @@ protected function getRecoveryData()
}

/**
* Retrieve the Recovery data
* Retrieve the Recovery data.
*
* @return $this
*/
Expand All @@ -97,4 +97,4 @@ public function refresh()

return $this;
}
}
}
2 changes: 1 addition & 1 deletion lib/Elastica/Suggest/Term.php
Expand Up @@ -129,7 +129,7 @@ public function setMaxTermFrequency($max)

/**
* Which string distance implementation to use for comparing how similar suggested terms are.
* Five possible values can be specified:
* Five possible values can be specified:.
*
* - internal
* - damerau_levenshtein
Expand Down
12 changes: 7 additions & 5 deletions lib/Elastica/Transport/NullTransport.php
Expand Up @@ -17,14 +17,14 @@
class NullTransport extends AbstractTransport
{
/**
* Response you want to get from the transport
* Response you want to get from the transport.
*
* @var Response Response
*/
protected $_response = null;

/**
* Set response object the transport returns
* Set response object the transport returns.
*
* @param \Elastica\Response $response
*
Expand All @@ -36,7 +36,7 @@ public function getResponse()
}

/**
* Set response object the transport returns
* Set response object the transport returns.
*
* @param \Elastica\Response $response
*
Expand All @@ -45,13 +45,14 @@ public function getResponse()
public function setResponse(Response $response)
{
$this->_response = $response;

return $this->_response;
}

/**
* Generate an example response object
* Generate an example response object.
*
* @param array $params Hostname, port, path, ...
* @param array $params Hostname, port, path, ...
*
* @return \Elastica\Response $response
*/
Expand All @@ -72,6 +73,7 @@ public function generateDefaultResponse(array $params)
],
'params' => $params,
];

return new Response(JSON::stringify($response));
}

Expand Down
38 changes: 19 additions & 19 deletions test/Elastica/Aggregation/PercentilesTest.php
Expand Up @@ -41,9 +41,9 @@ public function testCompression()
'field' => 'price',
'keyed' => false,
'tdigest' => [
'compression' => 100
]
]
'compression' => 100,
],
],

];
$aggr = new Percentiles('price_percentile');
Expand All @@ -64,9 +64,9 @@ public function testHdr()
'field' => 'price',
'keyed' => false,
'hdr' => [
'number_of_significant_value_digits' => 2.0
]
]
'number_of_significant_value_digits' => 2.0,
],
],

];
$aggr = new Percentiles('price_percentile');
Expand All @@ -76,7 +76,7 @@ public function testHdr()

$this->assertEquals($expected, $aggr->toArray());
}

/**
* @group functional
*/
Expand Down Expand Up @@ -166,33 +166,33 @@ public function testKeyed()
'values' => [
[
'key' => 1,
'value' => 100
'value' => 100,
],
[
'key' => 5,
'value' => 100
'value' => 100,
],
[
'key' => 25,
'value' => 300
'value' => 300,
],
[
'key' => 50,
'value' => 550
'value' => 550,
],
[
'key' => 75,
'value' => 800
'value' => 800,
],
[
'key' => 95,
'value' => 1000
'value' => 1000,
],
[
'key' => 99,
'value' => 1000
]
]
'value' => 1000,
],
],
];

// prepare
Expand Down Expand Up @@ -236,10 +236,10 @@ public function testMissing()
'field' => 'price',
'keyed' => false,
'hdr' => [
'number_of_significant_value_digits' => 2.0
'number_of_significant_value_digits' => 2.0,
],
'missing' => 10
]
'missing' => 10,
],

];
$aggr = new Percentiles('price_percentile');
Expand Down
1 change: 0 additions & 1 deletion test/Elastica/Query/CommonTest.php
Expand Up @@ -87,7 +87,6 @@ public function testSetBoost()

/**
* @group unit

*/
public function testSetAnalyzer()
{
Expand Down
2 changes: 0 additions & 2 deletions test/Elastica/Query/ParentIdTest.php
Expand Up @@ -213,12 +213,10 @@ public function testQueryBuilderParentId()
$data = $result->getData();
$this->assertEquals($data['text'], 'this is an answer, the 1st');


$parentId = $queryDSL->parent_id('answer', 2, true);
$search = new Search($index->getClient());
$results = $search->search($parentId);

$this->assertEquals(2, $results->count());

}
}
12 changes: 5 additions & 7 deletions test/Elastica/Suggest/CompletionTest.php
Expand Up @@ -136,7 +136,6 @@ public function testCompletion()
$suggest2 = new Completion('suggestName2', 'fieldName2');
$suggest2->setPrefix('Neverdint');


$sug = new Suggest();
$sug->addSuggestion($suggest);
$sug->addSuggestion($suggest2);
Expand All @@ -149,20 +148,19 @@ public function testCompletion()
'text' => 'Neavermint',
'offset' => 0,
'length' => 10,
'options' => []
]
'options' => [],
],
],
'suggestName2' => [
0 => [
'text' => 'Neverdint',
'offset' => 0,
'length' => 9,
'options' => []
]
]
'options' => [],
],
],
];


$resultSet = $index->search($query);

$this->assertTrue($resultSet->hasSuggests());
Expand Down