Skip to content

Fix exact match not used inside text facet #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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