Skip to content

Commit 2131ed9

Browse files
committed
Fix #12 - Fix exact match not used inside text facet
1 parent c5b9484 commit 2131ed9

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Diff for: CHANGELOG.md

+4-1
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

1515
- Correclty handle Search result with NoContent flag ([Issue#9], [Issue#10], [PR#13])
1616
- Don't double % in fuzzy search ([Issue#11], [PR#14])
17+
- Fix exact match not used inside text facet ([Issue#12], [PR#15])
1718

1819
## [1.3.0]
1920

@@ -110,8 +111,10 @@ First version
110111
[Issue#9]: https://github.com/MacFJA/php-redisearch/issues/9
111112
[Issue#10]: https://github.com/MacFJA/php-redisearch/issues/10
112113
[Issue#11]: https://github.com/MacFJA/php-redisearch/issues/11
114+
[Issue#12]: https://github.com/MacFJA/php-redisearch/issues/12
113115
[PR#1]: https://github.com/MacFJA/php-redisearch/pull/1
114116
[PR#3]: https://github.com/MacFJA/php-redisearch/pull/3
115117
[PR#8]: https://github.com/MacFJA/php-redisearch/pull/8
116118
[PR#13]: https://github.com/MacFJA/php-redisearch/pull/13
117-
[PR#14]: https://github.com/MacFJA/php-redisearch/pull/14
119+
[PR#14]: https://github.com/MacFJA/php-redisearch/pull/14
120+
[PR#15]: https://github.com/MacFJA/php-redisearch/pull/15

Diff for: src/Search/QueryBuilder/ExactMatch.php

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
use MacFJA\RediSearch\Helper\EscapeHelper;
2525
use function sprintf;
26+
use function strpos;
2627

2728
class ExactMatch implements PartialQuery
2829
{
@@ -36,6 +37,10 @@ public function __construct(string $match)
3637

3738
public function render(): string
3839
{
40+
if (false === strpos($this->match, ' ')) {
41+
return EscapeHelper::escapeWord($this->match);
42+
}
43+
3944
return sprintf('"%s"', EscapeHelper::escapeExactMatch($this->match));
4045
}
4146

Diff for: src/Search/QueryBuilder/TextFacet.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function render(): string
5353
{
5454
if (count($this->orValues) > 1) {
5555
$terms = OrGroup::renderNoParentheses(...array_map(function (string $orValue) {
56-
return new Word($orValue);
56+
return new ExactMatch($orValue);
5757
}, $this->orValues));
5858

5959
return sprintf(self::WITH_SPACE_PATTERN, EscapeHelper::escapeFieldName($this->field), $terms);

0 commit comments

Comments
 (0)