Skip to content

Commit 86ae611

Browse files
authored
Merge pull request #27 from MacFJA/always-on-option-issue-26
Fix Summary and Highlight always active [#26]
2 parents bad89b3 + 320589f commit 86ae611

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased v2.x]
88

9+
### Fixed
10+
11+
- Summarize Search option enabled by default (without possibility to disable it) ([Issue#26])
12+
- Highlight Search option enabled by default (without possibility to disable it) ([Issue#26])
13+
914
## [2.1.0]
1015

1116
### Added
@@ -181,6 +186,7 @@ First version
181186
[Issue#11]: https://github.com/MacFJA/php-redisearch/issues/11
182187
[Issue#12]: https://github.com/MacFJA/php-redisearch/issues/12
183188
[Issue#16]: https://github.com/MacFJA/php-redisearch/issues/16
189+
[Issue#26]: https://github.com/MacFJA/php-redisearch/issues/26
184190
[PR#1]: https://github.com/MacFJA/php-redisearch/pull/1
185191
[PR#3]: https://github.com/MacFJA/php-redisearch/pull/3
186192
[PR#8]: https://github.com/MacFJA/php-redisearch/pull/8

src/Redis/Command/Search.php

+2
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public function setWithSortKeys(bool $active = true): self
146146
public function setSummarize(?array $fields = null, ?int $fragmentCount = null, ?int $fragmentSize = null, ?string $separator = null): self
147147
{
148148
$this->options['summarize']
149+
->setDataOfOption('type', true)
149150
->setDataOfOption('fields', $fields)
150151
->setDataOfOption('frags', $fragmentCount)
151152
->setDataOfOption('len', $fragmentSize)
@@ -163,6 +164,7 @@ public function setSummarize(?array $fields = null, ?int $fragmentCount = null,
163164
public function setHighlight(?array $fields, ?string $openTag, ?string $closeTag): self
164165
{
165166
$this->options['highlight']
167+
->setDataOfOption('type', true)
166168
->setDataOfOption('fields', $fields)
167169
->setTags($openTag, $closeTag)
168170
;

src/Redis/Command/SearchCommand/HighlightOption.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ class HighlightOption extends GroupedOption
3232
public function __construct()
3333
{
3434
parent::__construct([
35-
'type' => new FlagOption('HIGHLIGHT', true, '>=2.0.0'),
35+
'type' => new FlagOption('HIGHLIGHT', false, '>=2.0.0'),
3636
'fields' => new NotEmptyOption(new NumberedOption('FIELDS', null, '>=2.0.0')),
3737
'tag' => new GroupedOption([
3838
'type' => new FlagOption('TAGS', true, '>=2.0.0'),
3939
'open' => new NamelessOption(null, '>=2.0.0'),
4040
'close' => new NamelessOption(null, '>=2.0.0'),
4141
], ['type', 'open', 'close'], ['type'], '>=2.0.0'),
42-
], ['type'], ['type'], '>=2.0.0');
42+
], ['type'], [], '>=2.0.0');
4343
}
4444

4545
public function setTags(?string $open, ?string $close): self

src/Redis/Command/SearchCommand/SummarizeOption.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ class SummarizeOption extends GroupedOption
3333
public function __construct()
3434
{
3535
parent::__construct([
36-
'type' => new FlagOption('SUMMARIZE', true, '>=2.0.0'),
36+
'type' => new FlagOption('SUMMARIZE', false, '>=2.0.0'),
3737
'fields' => new NotEmptyOption(new NumberedOption('FIELDS', null, '>=2.0.0')),
3838
'frags' => CV::isNumeric(new NamedOption('FRAGS', null, '>=2.0.0')),
3939
'len' => CV::isNumeric(new NamedOption('LEN', null, '>=2.0.0')),
4040
'separator' => new NamedOption('SEPARATOR', null, '>=2.0.0'),
41-
], ['type'], ['type'], '>=2.0.0');
41+
], ['type'], [], '>=2.0.0');
4242
}
4343
}

tests/Redis/Command/SearchTest.php

+16
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,20 @@ public function testFullOption(): void
126126
'LIMIT', 12, 10,
127127
], $command->getArguments());
128128
}
129+
130+
public function testNoSummarizeAndNoHighlight(): void
131+
{
132+
$command = new Search(AbstractCommand::MAX_IMPLEMENTED_VERSION);
133+
$command
134+
->setIndex('idx')
135+
->setQuery('@text1:"hello world"')
136+
->setLimit(12, 10)
137+
;
138+
139+
static::assertSame([
140+
'idx',
141+
'@text1:"hello world"',
142+
'LIMIT', 12, 10,
143+
], $command->getArguments());
144+
}
129145
}

0 commit comments

Comments
 (0)