Skip to content

Commit bf556aa

Browse files
committed
RediSearch 2.4.3 compatibility
1 parent c7c25cf commit bf556aa

File tree

16 files changed

+67
-9
lines changed

16 files changed

+67
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- `LOAD ALL` option on Aggregate command (RediSearch `2.0.13`)
1515
- Profile command (RediSearch `2.2.0`) ([Issue#4])
1616
- Vector feature (RediSearch `2.4.0` / `2.4.2`)
17+
- Add `DIALECT` option (RediSearch `2.4.3`) ([Issue#35])
1718
- (dev) Add `make clean` to remove all generated files
1819
- (dev) Add code coverage to `\MacFJA\RediSearch\Index`
1920
- (dev) Add integration test for document insertion
@@ -234,6 +235,7 @@ First version
234235
[Issue#12]: https://github.com/MacFJA/php-redisearch/issues/12
235236
[Issue#16]: https://github.com/MacFJA/php-redisearch/issues/16
236237
[Issue#26]: https://github.com/MacFJA/php-redisearch/issues/26
238+
[Issue#35]: https://github.com/MacFJA/php-redisearch/issues/35
237239
[Issue#38]: https://github.com/MacFJA/php-redisearch/issues/38
238240
[Issue#39]: https://github.com/MacFJA/php-redisearch/issues/39
239241
[Issue#46]: https://github.com/MacFJA/php-redisearch/issues/46

src/Query/Builder/QueryElementVector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
use function array_key_exists;
2525
use function count;
2626
use function gettype;
27-
use InvalidArgumentException;
2827
use function is_int;
2928
use function is_string;
3029
use function strlen;
3130

31+
use InvalidArgumentException;
32+
3233
class QueryElementVector implements QueryElementDecorator
3334
{
3435
private const PARAMETERS = [

src/Redis/Command/AbstractCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*/
3434
abstract class AbstractCommand implements Command
3535
{
36-
public const MAX_IMPLEMENTED_VERSION = '2.4.0';
36+
public const MAX_IMPLEMENTED_VERSION = '2.4.3';
3737
public const MIN_IMPLEMENTED_VERSION = '2.0.0';
3838

3939
/**

src/Redis/Command/Aggregate.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VE
6666
'limit' => new LimitOption(),
6767
'filter' => [],
6868
'cursor' => new WithCursor(),
69+
'dialect' => CV::isNumeric(new NamedOption('DIALECT', null, '>=2.4.3')),
6970
], $rediSearchVersion);
7071
}
7172

@@ -168,6 +169,13 @@ public function setLoadAll(): self
168169
return $this;
169170
}
170171

172+
public function setDialect(int $version): self
173+
{
174+
$this->options['dialect']->setValue($version);
175+
176+
return $this;
177+
}
178+
171179
public function setWithCursor(?int $count = null, ?int $maxIdle = null): self
172180
{
173181
$this->options['cursor']

src/Redis/Command/ConfigSet.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VE
3333
'action' => new FlagOption('SET', true, '>=2.0.0'),
3434
'options' => [
3535
CustomValidatorOption::allowedValues(new NamelessOption(null, '>=2.0.0 <2.0.6'), ['NOGC', 'MAXEXPANSIONS', 'TIMEOUT', 'ON_TIMEOUT', 'MIN_PHONETIC_TERM_LEN']),
36-
CustomValidatorOption::allowedValues(new NamelessOption(null, '>=2.0.6'), ['NOGC', 'MINPREFIX', 'MAXEXPANSIONS', 'MAXFILTEREXPANSION', 'TIMEOUT', 'ON_TIMEOUT', 'MIN_PHONETIC_TERM_LEN']),
36+
CustomValidatorOption::allowedValues(new NamelessOption(null, '>=2.0.6 <2.4.3'), ['NOGC', 'MINPREFIX', 'MAXEXPANSIONS', 'MAXFILTEREXPANSION', 'TIMEOUT', 'ON_TIMEOUT', 'MIN_PHONETIC_TERM_LEN']),
37+
CustomValidatorOption::allowedValues(new NamelessOption(null, '>=2.4.3'), ['NOGC', 'MINPREFIX', 'MAXEXPANSIONS', 'TIMEOUT', 'ON_TIMEOUT', 'MIN_PHONETIC_TERM_LEN', 'DEFAULT_DIALECT']),
3738
],
3839
'value' => new NamelessOption(null, '>=2.0.0'),
3940
], $rediSearchVersion);

src/Redis/Command/CreateCommand/VectorFieldOption.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
namespace MacFJA\RediSearch\Redis\Command\CreateCommand;
2323

2424
use function in_array;
25-
use InvalidArgumentException;
2625
use function is_int;
26+
27+
use InvalidArgumentException;
2728
use MacFJA\RediSearch\Redis\Command\Option\CustomValidatorOption;
2829
use MacFJA\RediSearch\Redis\Command\Option\GroupedOption;
2930
use MacFJA\RediSearch\Redis\Command\Option\NamedOption;

src/Redis/Command/Explain.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
namespace MacFJA\RediSearch\Redis\Command;
2323

24+
use MacFJA\RediSearch\Redis\Command\Option\CustomValidatorOption as CV;
25+
use MacFJA\RediSearch\Redis\Command\Option\NamedOption;
2426
use MacFJA\RediSearch\Redis\Command\Option\NamelessOption;
2527

2628
/**
@@ -33,6 +35,7 @@ public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VE
3335
parent::__construct([
3436
'index' => new NamelessOption(null, '>=2.0.0'),
3537
'query' => new NamelessOption(null, '>=2.0.0'),
38+
'dialect' => CV::isNumeric(new NamedOption('DIALECT', null, '>=2.4.3')),
3639
], $rediSearchVersion);
3740
}
3841

@@ -50,6 +53,13 @@ public function setQuery(string $query): self
5053
return $this;
5154
}
5255

56+
public function setDialect(int $version): self
57+
{
58+
$this->options['dialect']->setValue($version);
59+
60+
return $this;
61+
}
62+
5363
public function getId(): string
5464
{
5565
return 'FT.EXPLAIN';

src/Redis/Command/ProfileCommand/QueryOption.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
namespace MacFJA\RediSearch\Redis\Command\ProfileCommand;
2323

2424
use function assert;
25+
2526
use MacFJA\RediSearch\Redis\Command\Aggregate;
2627
use MacFJA\RediSearch\Redis\Command\Option\AbstractCommandOption;
2728
use MacFJA\RediSearch\Redis\Command\Search;

src/Redis/Command/Search.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VE
7979
'params' => new NotEmptyOption(new NumberedOption('PARAMS', null, '>=2.4.0')),
8080
'sortby' => new SortByOption(),
8181
'limit' => new LimitOption(),
82+
'dialect' => CV::isNumeric(new NamedOption('DIALECT', null, '>=2.4.3')),
8283
],
8384
$rediSearchVersion
8485
);
@@ -323,6 +324,13 @@ public function getSize(): ?int
323324
return $limit->getSize();
324325
}
325326

327+
public function setDialect(int $version): self
328+
{
329+
$this->options['dialect']->setValue($version);
330+
331+
return $this;
332+
}
333+
326334
/**
327335
* @param mixed $data
328336
*

src/Redis/Command/SpellCheck.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
use MacFJA\RediSearch\Exception\UnexpectedServerResponseException;
2727
use MacFJA\RediSearch\Redis\Command\Option\CustomValidatorOption;
28+
use MacFJA\RediSearch\Redis\Command\Option\CustomValidatorOption as CV;
2829
use MacFJA\RediSearch\Redis\Command\Option\NamedOption;
2930
use MacFJA\RediSearch\Redis\Command\Option\NamelessOption;
3031
use MacFJA\RediSearch\Redis\Command\SpellCheckCommand\TermsOption;
@@ -42,6 +43,7 @@ public function __construct(string $rediSearchVersion = self::MIN_IMPLEMENTED_VE
4243
new NamedOption('DISTANCE', null, '>=2.0.0'),
4344
Validator::intVal()->between(1, 4)
4445
),
46+
'dialect' => CV::isNumeric(new NamedOption('DIALECT', null, '>=2.4.3')),
4547
'terms' => [],
4648
], $rediSearchVersion);
4749
}
@@ -67,6 +69,13 @@ public function setDistance(int $distance): self
6769
return $this;
6870
}
6971

72+
public function setDialect(int $version): self
73+
{
74+
$this->options['dialect']->setValue($version);
75+
76+
return $this;
77+
}
78+
7079
public function addTerms(string $dictionary, bool $isExcluding = false): self
7180
{
7281
$terms = new TermsOption();

0 commit comments

Comments
 (0)