Skip to content

Commit

Permalink
Support multi match type 'bool_prefix' (#2220)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfsblu authored Jul 18, 2024
1 parent 8b1826d commit 13b22af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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

0 comments on commit 13b22af

Please sign in to comment.