diff --git a/CHANGELOG.md b/CHANGELOG.md index cbfb41567..cff9a7fdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,27 +4,28 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased](https://github.com/ruflin/Elastica/compare/8.0.0...8.x) +## [Unreleased](https://github.com/ruflin/Elastica/compare/8.1.0...8.x) ### Backward Compatibility Breaks +### Added +### Changed +### Deprecated +### Removed +### Fixed +* `Elastica\Query\BoolQuery::toArray` no longer changes `$this->_params` to \stdClass when empty [#2241](https://github.com/ruflin/Elastica/pull/2241) +### Security + +## [8.1.0](https://github.com/ruflin/Elastica/compare/8.0.0...8.1.0) ### Added * Added support for the multi-match query type `bool_prefix` [#2220](https://github.com/ruflin/Elastica/pull/2220) -* Supported PHP 8.4 [#2221](https://github.com/ruflin/Elastica/pull/2221) +* Added support for PHP 8.4 [#2221](https://github.com/ruflin/Elastica/pull/2221) * Added support for custom key to IpRange and GeoDistance `addRange` using a common trait [#2227](https://github.com/ruflin/Elastica/pull/2227) * Added bucket sort aggregation [#2229](https://github.com/ruflin/Elastica/pull/2229) -### Changed - -### Deprecated - -### Removed - ### Fixed * Fixed Pipeline Processor handling to allow for multiple processors of the same type [#2218](https://github.com/ruflin/Elastica/pull/2218) -### Security - ## [8.0.0](https://github.com/ruflin/Elastica/compare/8.0.0-alpha1...8.0.0) This a major release with breaking changes. diff --git a/README.md b/README.md index 35ce4ed3d..fdfb76349 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,43 @@ -Elastica: elasticsearch PHP Client -================================== - -[![Latest Stable Version](https://poser.pugx.org/ruflin/Elastica/v/stable.png)](https://packagist.org/packages/ruflin/elastica) -[![Build Status](https://github.com/ruflin/elastica/workflows/Continuous%20integration/badge.svg?branch=master)](https://github.com/ruflin/Elastica/actions?query=workflow%3A%22Continuous%20integration%22%20branch%3Amaster) -[![codecov.io](http://codecov.io/github/ruflin/Elastica/coverage.svg?branch=master)](http://codecov.io/github/ruflin/Elastica?branch=master) -[![Dependency Status](https://www.versioneye.com/php/ruflin:elastica/dev-master/badge.svg)](https://www.versioneye.com/php/ruflin:elastica/dev-master) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ruflin/Elastica/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ruflin/Elastica/?branch=master) -[![Total Downloads](https://poser.pugx.org/ruflin/Elastica/downloads.png)](https://packagist.org/packages/ruflin/elastica) +# Elastica: elasticsearch PHP Client + +[![Latest Stable Version](https://poser.pugx.org/ruflin/Elastica/v/stable)](https://packagist.org/packages/ruflin/elastica) +[![Build Status](https://github.com/ruflin/elastica/actions/workflows/continuous-integration.yaml/badge.svg?branch=8.x)](https://github.com/ruflin/Elastica/actions/workflows/continuous-integration.yaml?query=branch%3A8.x) +[![codecov.io](https://codecov.io/gh/ruflin/Elastica/branch/8.x/graph/badge.svg)](https://app.codecov.io/github/ruflin/Elastica/tree/8.x) +[![Total Downloads](https://poser.pugx.org/ruflin/Elastica/downloads)](https://packagist.org/packages/ruflin/elastica) [![Join the chat at https://gitter.im/ruflin/Elastica](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ruflin/Elastica?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) All documentation for Elastica can be found under [Elastica.io](http://Elastica.io/). -If you have questions, don't hesitate to ask them on [Stack Overflow](http://stackoverflow.com/questions/tagged/elastica) and add the Tag "Elastica" or -in our [Gitter](https://gitter.im/ruflin/Elastica) channel. +If you have questions, don't hesitate to ask them on [Stack Overflow](http://stackoverflow.com/questions/tagged/elastica) +and add the Tag "Elastica" or in our [Gitter](https://gitter.im/ruflin/Elastica) channel. + All library issues should go to the [issue tracker from GitHub](https://github.com/ruflin/Elastica/issues). +## Compatibility -Compatibility -------------- This release is compatible with all Elasticsearch 8.0 releases and onwards. The testsuite is run against the most recent minor version of Elasticsearch, currently 8.8.0 and 8.9.0-SNAPSHOT +## Contributing -Contributing ------------- Contributions are always welcome. For details on how to contribute, check the [CONTRIBUTING](https://github.com/ruflin/Elastica/blob/master/CONTRIBUTING.md) file. +## Versions & Dependencies -Versions & Dependencies ------------- This project tries to follow Elasticsearch in terms of [End of Life](https://www.elastic.co/support/eol) and maintenance since 5.x. It is generally recommended to use the latest point release of the relevant branch. -| Elastica branch | ElasticSearch | elasticsearch-php | PHP | -| ----------------------------------------------------- | ------------- | ----------------- | -------------- | -| [8.x](https://github.com/ruflin/Elastica/tree/8.x) | 8.x | ^8.4 | >=8.0 <8.4 -| [7.x](https://github.com/ruflin/Elastica/tree/7.x) | 7.x | ^7.0 | ^7.2 \|\| ^8.0 | -| [6.x](https://github.com/ruflin/Elastica/tree/6.x) | 6.x | ^6.0 | ^7.0 \|\| ^8.0 | +| Elastica branch | ElasticSearch | elasticsearch-php | PHP | +|----------------------------------------------------|---------------|-------------------|----------------| +| [8.x](https://github.com/ruflin/Elastica/tree/8.x) | 8.x | ^8.4 | >=8.0 <8.4 | +| [7.x](https://github.com/ruflin/Elastica/tree/7.x) | 7.x | ^7.0 | ^7.2 \|\| ^8.0 | +| [6.x](https://github.com/ruflin/Elastica/tree/6.x) | 6.x | ^6.0 | ^7.0 \|\| ^8.0 | Unmaintained versions: -| Elastica version | ElasticSearch | elasticsearch-php | PHP | -| ----------------------------------------------------- | ------------- | ----------------- | -------------- | -| [5.x](https://github.com/ruflin/Elastica/tree/5.x) | 5.x | ^5.0 | \>=5.6 | -| [3.x](https://github.com/ruflin/Elastica/tree/3.x) | 2.4.0 | no | \>=5.4 | -| [2.x](https://github.com/ruflin/Elastica/tree/2.x) | 1.7.2 | no | \>=5.3.3 | ------------- +| Elastica version | ElasticSearch | elasticsearch-php | PHP | +|----------------------------------------------------|---------------|-------------------|----------| +| [5.x](https://github.com/ruflin/Elastica/tree/5.x) | 5.x | ^5.0 | \>=5.6 | +| [3.x](https://github.com/ruflin/Elastica/tree/3.x) | 2.4.0 | no | \>=5.4 | +| [2.x](https://github.com/ruflin/Elastica/tree/2.x) | 1.7.2 | no | \>=5.3.3 | diff --git a/src/Query/BoolQuery.php b/src/Query/BoolQuery.php index 89a8325f8..68d0074bf 100644 --- a/src/Query/BoolQuery.php +++ b/src/Query/BoolQuery.php @@ -87,11 +87,15 @@ public function setMinimumShouldMatch($minimum): self public function toArray(): array { - if (!$this->_params) { - $this->_params = new \stdClass(); + $data = parent::toArray(); + + // When the query has no params, ensure that the query + // serializes into a JSON object instead of an empty array. + if (!$data[$this->_getBaseName()]) { + $data[$this->_getBaseName()] = new \stdClass(); } - return parent::toArray(); + return $data; } /** diff --git a/tests/IndexTest.php b/tests/IndexTest.php index 11c0f8bf5..ee68bd0e1 100644 --- a/tests/IndexTest.php +++ b/tests/IndexTest.php @@ -569,7 +569,14 @@ public function testAddDocumentAcrossIndices(): void $index1Doc = $index1->getDocument(1); - $index2->addDocument($index1Doc); + // Since if_primary_term and if_seq_no are automatically set in getDocument, + // it is an error to add them to another Index as is. + // Therefore, convert the acquired document to an Array before calling + $doc = new Document('1'); + $arr = $index1Doc->toArray(); + $doc->setData($arr['_source']); + + $index2->addDocument($doc); $index2Doc = $index1->getDocument(1); $this->assertEquals('Hello world', $index2Doc->get('title'));