Skip to content

Commit

Permalink
Prepare 6.0.1 release (#1465)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruflin authored Feb 18, 2018
1 parent 95ce388 commit 0bd1898
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 36 deletions.
15 changes: 11 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ All notable changes to this project will be documented in this file based on the

### Backward Compatibility Breaks

### Bugfixes

### Added

### Improvements

### Deprecated


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

### Bugfixes
- Characters "<" and ">" will be removed when a query term is passed to [`Util::escapeTerm`](https://github.com/ruflin/Elastica/pull/1415/files). Since v5.1 the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-query-string-query.html#_reserved_characters) states that these symbols cannot be escaped ever.
- Remove [`each()`](http://www.php.net/each) usage to fix PHP 7.2 compatibility
Expand All @@ -19,10 +30,6 @@ All notable changes to this project will be documented in this file based on the
* Added avg_bucket() and sum_bucket() in aggregations [PR#1443](https://github.com/ruflin/Elastica/pull/1443) - (https://github.com/ruflin/Elastica/issues/1279)
* Added support for [terms lookup mechanism](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html#query-dsl-terms-lookup) on terms query [#1452](https://github.com/ruflin/Elastica/pull/1452)

### Improvements

### Deprecated


## [6.0.0](https://github.com/ruflin/Elastica/compare/6.0.0-beta1...6.0.0)

Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Aggregation/AvgBucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AvgBucket extends AbstractAggregation
{
/**
* @param string $name
* @param string|null $bucketsPath
* @param string|null $bucketsPath
*/
public function __construct($name, $bucketsPath = null)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Aggregation/SumBucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SumBucket extends AbstractAggregation
{
/**
* @param string $name
* @param string|null $bucketsPath
* @param string|null $bucketsPath
*/
public function __construct($name, $bucketsPath = null)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Bulk/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function toString()
$string .= $source;
} elseif (is_array($source) && array_key_exists('doc', $source) && is_string($source['doc'])) {
if (isset($source['doc_as_upsert'])) {
$docAsUpsert = ', "doc_as_upsert": ' . ($source['doc_as_upsert'] ? 'true' : 'false' );
$docAsUpsert = ', "doc_as_upsert": '.($source['doc_as_upsert'] ? 'true' : 'false');
} else {
$docAsUpsert = '';
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Elastica/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function getSettings()
/**
* Uses _bulk to send documents to the server.
*
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array $options Array of query params to use for query. For possible options check es api
*
* @return \Elastica\Bulk\ResponseSet
Expand All @@ -137,7 +137,7 @@ public function updateDocuments(array $docs, array $options = [])
/**
* Uses _bulk to send documents to the server.
*
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array $options Array of query params to use for query. For possible options check es api
*
* @return \Elastica\Bulk\ResponseSet
Expand Down
10 changes: 5 additions & 5 deletions lib/Elastica/QueryBuilder/DSL/Aggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public function sum($name)
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-sum-bucket-aggregation.html
*
* @param string $name
* @param string|null $bucketsPath
* @param string $name
* @param string|null $bucketsPath
*
* @return SumBucket
*/
Expand All @@ -125,13 +125,13 @@ public function avg($name)
return new Avg($name);
}

/**
/**
* avg bucket aggregation.
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html
*
* @param string $name
* @param string|null $bucketsPath
* @param string $name
* @param string|null $bucketsPath
*
* @return AvgBucket
*/
Expand Down
8 changes: 5 additions & 3 deletions lib/Elastica/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function updateDocument($data, array $options = [])
/**
* Uses _bulk to send documents to the server.
*
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array $options Array of query params to use for query. For possible options check es api
*
* @return \Elastica\Bulk\ResponseSet
Expand All @@ -185,8 +185,9 @@ public function updateDocuments(array $docs, array $options = [])
/**
* Uses _bulk to send documents to the server.
*
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @param array $options Array of query params to use for query. For possible options check es api
*
* @return \Elastica\Bulk\ResponseSet
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
Expand All @@ -204,9 +205,10 @@ public function addDocuments(array $docs, array $options = [])
* Uses _bulk to send documents to the server.
*
* @param object[] $objects
* @param array $options Array of query params to use for query. For possible options check es api
* @param array $options Array of query params to use for query. For possible options check es api
*
* @return Bulk\ResponseSet
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function addObjects(array $objects, array $options = [])
Expand Down
4 changes: 2 additions & 2 deletions lib/Elastica/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function escapeDateMath($requestUri)
/**
* Replace known reserved words (e.g. AND OR NOT)
* and
* escape known special characters (e.g. + - && || ! ( ) { } [ ] ^ " ~ * ? : etc.)
* escape known special characters (e.g. + - && || ! ( ) { } [ ] ^ " ~ * ? : etc.).
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-query-string-query.html#_boolean_operators
* @link https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-query-string-query.html#_reserved_characters
Expand Down Expand Up @@ -111,7 +111,7 @@ public static function escapeTerm($term)
foreach ($escapableChars as $char) {
$result = str_replace($char, '\\'.$char, $result);
}

// < and > cannot be escaped, so they should be removed
// @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
$nonEscapableChars = ['<', '>'];
Expand Down
3 changes: 1 addition & 2 deletions test/Elastica/Aggregation/AvgBucketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public function testAvgBucketAggregation()
->addAggregation(
(new AvgBucket('avg_likes_by_page'))
->setBucketsPath('pages>avg_likes')
)
;
);

$results = $this->_getIndexForTest()->search($query)->getAggregations();

Expand Down
3 changes: 1 addition & 2 deletions test/Elastica/Aggregation/SumBucketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public function testSumBucketAggregation()
->addAggregation(
(new SumBucket('sum_likes_by_page'))
->setBucketsPath('pages>sum_likes')
)
;
);

$results = $this->_getIndexForTest()->search($query)->getAggregations();

Expand Down
9 changes: 4 additions & 5 deletions test/Elastica/Bulk/Action/UpdateDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
namespace Elastica\Test\BulkAction;

use Elastica\Bulk\Action\UpdateDocument;
use Elastica\Document;
use Elastica\Index;
use Elastica\Test\Base as BaseTest;
use Elastica\Type;
use Elastica\Document;

class ActionTest extends BaseTest
class UpdateDocumentTest extends BaseTest
{
/**
* @group unit
Expand Down Expand Up @@ -61,7 +61,6 @@ public function testUpdateDocument()
$expected = '{"update":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}'."\n";
$expected .= $docExpected;
$this->assertEquals($expected, $action->toString());

}

/**
Expand All @@ -77,7 +76,7 @@ public function testUpdateDocumentAsUpsert()
$this->assertTrue($action->hasSource());

$expected = '{"update":{"_index":"index","_type":"type","_id":1}}'."\n"
. '{"doc":{"foo":"bar"},"doc_as_upsert":true}'."\n";
.'{"doc":{"foo":"bar"},"doc_as_upsert":true}'."\n";
$this->assertEquals($expected, $action->toString());

$document->setDocAsUpsert(1);
Expand All @@ -87,7 +86,7 @@ public function testUpdateDocumentAsUpsert()
$document->setDocAsUpsert(false);
$action->setDocument($document);
$expected = '{"update":{"_index":"index","_type":"type","_id":1}}'."\n"
. '{"doc":{"foo":"bar"}}'."\n";
.'{"doc":{"foo":"bar"}}'."\n";
$this->assertEquals($expected, $action->toString());

$document->setDocAsUpsert(0);
Expand Down
4 changes: 3 additions & 1 deletion test/Elastica/BulkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,9 @@ public function testUpsert()
$doc2 = $type->createDocument(2, ['name' => 'Beckenbauer']);
$doc3 = $type->createDocument(3, ['name' => 'Baggio']);
$doc4 = $type->createDocument(4, ['name' => 'Cruyff']);
$documents = array_map(function($d){ $d->setDocAsUpsert(true); return $d;}, [$doc1, $doc2, $doc3, $doc4]);
$documents = array_map(function ($d) { $d->setDocAsUpsert(true);

return $d;}, [$doc1, $doc2, $doc3, $doc4]);

//index some documents
$bulk = new Bulk($client);
Expand Down
9 changes: 4 additions & 5 deletions test/Elastica/Query/TermsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testFilteredSearchWithLookup()
$lookupType = $lookupIndex->getType('user');

$lookupType->addDocuments([
new Document(1, ['terms' => ['ruflin', 'nicolas']])
new Document(1, ['terms' => ['ruflin', 'nicolas']]),
]);

$type->addDocuments([
Expand All @@ -63,7 +63,7 @@ public function testFilteredSearchWithLookup()
'index' => $lookupIndex->getName(),
'type' => $lookupType->getName(),
'id' => '1',
'path' => 'terms'
'path' => 'terms',
]);
$index->refresh();
$lookupIndex->refresh();
Expand Down Expand Up @@ -113,7 +113,6 @@ public function testSetMinimum($minimum)
$this->assertEquals($minimum, $data['terms']['minimum_match']);
}


/**
* @group unit
*/
Expand All @@ -124,10 +123,10 @@ public function testSetTermsLookup()
'index' => 'index_name',
'type' => 'type_name',
'id' => '1',
'path' => 'terms'
'path' => 'terms',
];

$query = new Terms;
$query = new Terms();
$query->setTermsLookup($key, $terms);
$data = $query->toArray();
$this->assertEquals($terms, $data['terms'][$key]);
Expand Down
3 changes: 1 addition & 2 deletions test/Elastica/Transport/AwsAuthV4Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ public function testSetHttpsIfItIsRequired()
'aws_secret_access_key' => 'bar',
'aws_session_token' => 'baz',
'aws_region' => 'us-east-1',
'ssl' => true
'ssl' => true,
];
$client = $this->_getClient($config);

try {
$client->request('_status', 'GET');

} catch (GuzzleException $e) {
$guzzleException = $e->getGuzzleException();
if ($guzzleException instanceof RequestException) {
Expand Down

0 comments on commit 0bd1898

Please sign in to comment.