diff --git a/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php b/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php index 5ec55f7f9..06c86000d 100644 --- a/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php +++ b/tests/Predis/Command/Redis/Search/FTSEARCH_Test.php @@ -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', 'adriano@acme.com.ie', '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', 'adriano@acme.com.ie']); + $ftSearchArguments->dialect(4); + + $actualResponse = $redis->ftsearch( + 'idx_hash', '@uuid:{$uuid}', $ftSearchArguments + ); + + $this->assertSame([ + 1, 'test:1', + ['uuid', '3d3586fe-0416-4572-8ce', 'email', 'adriano@acme.com.ie', 'num', '5']], $actualResponse + ); + + $actualResponse = $redis->ftsearch( + 'idx_hash', '@email:{$email}', $ftSearchArguments + ); + + $this->assertSame([ + 1, 'test:1', + ['uuid', '3d3586fe-0416-4572-8ce', 'email', 'adriano@acme.com.ie', 'num', '5']], $actualResponse + ); + + $actualResponse = $redis->ftsearch( + 'idx_hash', '@num:[5]', $ftSearchArguments + ); + + $this->assertSame([ + 1, 'test:1', + ['uuid', '3d3586fe-0416-4572-8ce', 'email', 'adriano@acme.com.ie', 'num', '5']], $actualResponse + ); + } + /** * @group connected * @group relay-resp3