From 548ddcef3265dc4ac405471db65ad4f3074b93ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20de=20Guillebon?= Date: Fri, 3 Dec 2021 09:57:57 +0100 Subject: [PATCH 1/3] Add terms boost param --- src/Query/Terms.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Query/Terms.php b/src/Query/Terms.php index c0af77d6ef..80476629b3 100644 --- a/src/Query/Terms.php +++ b/src/Query/Terms.php @@ -70,4 +70,9 @@ public function setTermsLookup(string $index, string $id, string $path): self 'path' => $path, ]); } + + public function setBoost(float $boost): self + { + return $this->setParam('boost', $boost); + } } From bf81a68bc33930f41082f0b4a950ac5da7c6a882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20de=20Guillebon?= Date: Fri, 3 Dec 2021 10:01:02 +0100 Subject: [PATCH 2/3] Add test --- tests/Query/TermsTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/Query/TermsTest.php b/tests/Query/TermsTest.php index 4f0bf1e5b9..4b4467e3ed 100644 --- a/tests/Query/TermsTest.php +++ b/tests/Query/TermsTest.php @@ -34,6 +34,25 @@ public function testSetTermsLookup(): void $this->assertSame($expected, $query->toArray()); } + /** + * @group unit + */ + public function testSetBoost(): void + { + $expected = [ + 'terms' => [ + 'name' => ['foo', 'bar'], + 'boost' => 2.0, + ], + ]; + + $query = (new Terms('name', ['foo', 'bar'])) + ->setBoost(2.0) + ; + + $this->assertSame($expected, $query->toArray()); + } + /** * @group unit */ From 02d4b1608d51bef08774850d24360cad3bd1cf1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20de=20Guillebon?= Date: Fri, 3 Dec 2021 10:02:36 +0100 Subject: [PATCH 3/3] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a369bef421..7638fe1cc2 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added `allow_duplicates` option to `append` processor [#2004](https://github.com/ruflin/Elastica/pull/2004) * Added `bytes` processor [#2008](https://github.com/ruflin/Elastica/pull/2008) * Added `indices_boost` option to `Elastica\Query` [#2018](https://github.com/ruflin/Elastica/pull/2018) +* Added `Elastica\Query\Terms::setBoost()` method to configure boost [#2035](https://github.com/ruflin/Elastica/pull/2035) ### Changed * Triggered deprecation in `Elastica\Result::getType()` method [#2016](https://github.com/ruflin/Elastica/pull/2016) * Updated `php-cs-fixer` to `3.3.2` [#2022](https://github.com/ruflin/Elastica/pull/2022)