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

Support multi match type 'bool_prefix' #2220

Merged
merged 3 commits into from
Jul 18, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Backward Compatibility Breaks

### Added
* Added support for the multi-match query type `bool_prefix` [#2220](https://github.com/ruflin/Elastica/pull/2220)

### Changed

Expand Down
1 change: 1 addition & 0 deletions src/Query/MultiMatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class MultiMatch extends AbstractQuery
public const TYPE_CROSS_FIELDS = 'cross_fields';
public const TYPE_PHRASE = 'phrase';
public const TYPE_PHRASE_PREFIX = 'phrase_prefix';
public const TYPE_BOOL_PREFIX = 'bool_prefix';

public const OPERATOR_OR = 'or';
public const OPERATOR_AND = 'and';
Expand Down
16 changes: 15 additions & 1 deletion tests/Query/MultiMatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testAndOperator(): void
/**
* @group functional
*/
public function testType(): void
public function testTypePhrasePrefix(): void
{
$multiMatch = new MultiMatch();
$multiMatch->setQuery('Trist');
Expand All @@ -66,6 +66,20 @@ public function testType(): void
$this->assertEquals(1, $resultSet->count());
}

/**
* @group functional
*/
public function testTypeBoolPrefix(): void
{
$multiMatch = new MultiMatch();
$multiMatch->setQuery('Main');
$multiMatch->setFields(['full_name', 'name']);
$multiMatch->setType(MultiMatch::TYPE_BOOL_PREFIX);
$resultSet = $this->_getResults($multiMatch);

$this->assertEquals(2, $resultSet->count());
}

/**
* @group functional
*/
Expand Down
Loading