Skip to content

Commit

Permalink
Merge pull request #15 from MacFJA/issue-12-text-facet-exact-match
Browse files Browse the repository at this point in the history
Fix exact match not used inside text facet
  • Loading branch information
MacFJA authored Sep 6, 2021
2 parents c5b9484 + 2131ed9 commit 0837779
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

## [1.3.0]

Expand Down Expand Up @@ -110,8 +111,10 @@ First version
[Issue#9]: https://github.com/MacFJA/php-redisearch/issues/9
[Issue#10]: https://github.com/MacFJA/php-redisearch/issues/10
[Issue#11]: https://github.com/MacFJA/php-redisearch/issues/11
[Issue#12]: https://github.com/MacFJA/php-redisearch/issues/12
[PR#1]: https://github.com/MacFJA/php-redisearch/pull/1
[PR#3]: https://github.com/MacFJA/php-redisearch/pull/3
[PR#8]: https://github.com/MacFJA/php-redisearch/pull/8
[PR#13]: https://github.com/MacFJA/php-redisearch/pull/13
[PR#14]: https://github.com/MacFJA/php-redisearch/pull/14
[PR#14]: https://github.com/MacFJA/php-redisearch/pull/14
[PR#15]: https://github.com/MacFJA/php-redisearch/pull/15
5 changes: 5 additions & 0 deletions src/Search/QueryBuilder/ExactMatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use MacFJA\RediSearch\Helper\EscapeHelper;
use function sprintf;
use function strpos;

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

public function render(): string
{
if (false === strpos($this->match, ' ')) {
return EscapeHelper::escapeWord($this->match);
}

return sprintf('"%s"', EscapeHelper::escapeExactMatch($this->match));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Search/QueryBuilder/TextFacet.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function render(): string
{
if (count($this->orValues) > 1) {
$terms = OrGroup::renderNoParentheses(...array_map(function (string $orValue) {
return new Word($orValue);
return new ExactMatch($orValue);
}, $this->orValues));

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

0 comments on commit 0837779

Please sign in to comment.