-
-
Notifications
You must be signed in to change notification settings - Fork 989
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test case for enhanced exact matching (#1466)
* Added test case for enhanced exact matching * Added version restriction for test * Updated test case to use Tag Field instead * Codestyle fix * Added edge to stack matrix * Updated test case to switch DIALECT * Updated version restriction
- Loading branch information
1 parent
1726db0
commit 52bdcf0
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
use Predis\Command\Argument\Search\SchemaFields\AbstractField; | ||
use Predis\Command\Argument\Search\SchemaFields\GeoShapeField; | ||
use Predis\Command\Argument\Search\SchemaFields\NumericField; | ||
use Predis\Command\Argument\Search\SchemaFields\TagField; | ||
use Predis\Command\Argument\Search\SchemaFields\TextField; | ||
use Predis\Command\Argument\Search\SearchArguments; | ||
use Predis\Command\Redis\PredisCommandTestCase; | ||
|
@@ -127,6 +128,65 @@ public function testSearchValuesByHashIndex(): void | |
$this->assertSame($expectedResponse, $actualResponse); | ||
} | ||
|
||
/** | ||
* @group connected | ||
* @group relay-resp3 | ||
* @return void | ||
* @requiresRediSearchVersion >= 2.09.00 | ||
*/ | ||
public function testSearchWithEnhancedMatchingCapabilities(): void | ||
{ | ||
$redis = $this->getClient(); | ||
|
||
$hashResponse = $redis->hmset( | ||
'test:1', 'uuid', '3d3586fe-0416-4572-8ce', 'email', '[email protected]', 'num', 5 | ||
); | ||
$this->assertEquals('OK', $hashResponse); | ||
|
||
$ftCreateArguments = new CreateArguments(); | ||
$ftCreateArguments->prefix(['test:']); | ||
|
||
$schema = [ | ||
new TagField('uuid'), | ||
new TagField('email'), | ||
new NumericField('num'), | ||
]; | ||
|
||
$ftCreateResponse = $redis->ftcreate('idx_hash', $schema, $ftCreateArguments); | ||
$this->assertEquals('OK', $ftCreateResponse); | ||
|
||
$ftSearchArguments = new SearchArguments(); | ||
$ftSearchArguments->params(['uuid', '3d3586fe-0416-4572-8ce', 'email', '[email protected]']); | ||
$ftSearchArguments->dialect(4); | ||
|
||
$actualResponse = $redis->ftsearch( | ||
'idx_hash', '@uuid:{$uuid}', $ftSearchArguments | ||
); | ||
|
||
$this->assertSame([ | ||
1, 'test:1', | ||
['uuid', '3d3586fe-0416-4572-8ce', 'email', '[email protected]', 'num', '5']], $actualResponse | ||
); | ||
|
||
$actualResponse = $redis->ftsearch( | ||
'idx_hash', '@email:{$email}', $ftSearchArguments | ||
); | ||
|
||
$this->assertSame([ | ||
1, 'test:1', | ||
['uuid', '3d3586fe-0416-4572-8ce', 'email', '[email protected]', 'num', '5']], $actualResponse | ||
); | ||
|
||
$actualResponse = $redis->ftsearch( | ||
'idx_hash', '@num:[5]', $ftSearchArguments | ||
); | ||
|
||
$this->assertSame([ | ||
1, 'test:1', | ||
['uuid', '3d3586fe-0416-4572-8ce', 'email', '[email protected]', 'num', '5']], $actualResponse | ||
); | ||
} | ||
|
||
/** | ||
* @group connected | ||
* @group relay-resp3 | ||
|