Skip to content

Commit

Permalink
Add terms_set in query builder (#2036)
Browse files Browse the repository at this point in the history
* Add terms_set in query builder

* Add test

* Add changelog
  • Loading branch information
deguif authored Dec 6, 2021
1 parent 70deadd commit bb26470
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* 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)
* Added `Elastica\Query\TermsSet` query [#2020](https://github.com/ruflin/Elastica/pull/2020)
* Added `terms_set` in query builder [#2036](https://github.com/ruflin/Elastica/pull/2036)
* Added `Elastica\Aggregation\Traits\BucketsPathTrait` to configure `buckets_path` on aggregations [#2037](https://github.com/ruflin/Elastica/pull/2037)
* Allowed to configure a sub key when adding a param with `Elastica\Param::addParam()` [#2030](https://github.com/ruflin/Elastica/pull/2030)
### Changed
Expand Down
13 changes: 13 additions & 0 deletions src/QueryBuilder/DSL/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@
use Elastica\Query\SpanWithin;
use Elastica\Query\Term;
use Elastica\Query\Terms;
use Elastica\Query\TermsSet;
use Elastica\Query\Wildcard;
use Elastica\QueryBuilder\DSL;
use Elastica\Script\AbstractScript;

/**
* elasticsearch query DSL.
Expand Down Expand Up @@ -474,6 +476,17 @@ public function terms(string $field, array $terms = []): Terms
return new Terms($field, $terms);
}

/**
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-set-query.html
*
* @param array<bool|float|int|string> $terms
* @param AbstractScript|string $minimumShouldMatch
*/
public function terms_set(string $field, array $terms, $minimumShouldMatch): TermsSet
{
return new TermsSet($field, $terms, $minimumShouldMatch);
}

/**
* wildcard query.
*
Expand Down
1 change: 1 addition & 0 deletions src/QueryBuilder/Version/Version700.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class Version700 extends Version
'span_term',
'term',
'terms',
'terms_set',
'wildcard',
'exists',
'percolate',
Expand Down
1 change: 1 addition & 0 deletions tests/QueryBuilder/DSL/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function testInterface(): void
$this->_assertImplemented($queryDSL, 'simple_query_string', Query\SimpleQueryString::class, ['query']);
$this->_assertImplemented($queryDSL, 'term', Query\Term::class, []);
$this->_assertImplemented($queryDSL, 'terms', Query\Terms::class, ['field', []]);
$this->_assertImplemented($queryDSL, 'terms_set', Query\TermsSet::class, ['field', ['term'], 'match_field']);
$this->_assertImplemented($queryDSL, 'wildcard', Query\Wildcard::class, ['field', '']);
$this->_assertImplemented(
$queryDSL,
Expand Down

0 comments on commit bb26470

Please sign in to comment.