Skip to content

Commit 463f3ee

Browse files
authored
Merge pull request #13 from MacFJA/issue-9-10-search-with-no-content-flag
Handle search result with NoContent flag.
2 parents d417e7d + 7351a04 commit 463f3ee

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

CHANGELOG.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88

99
### Added
10-
- Implementation of SLOP parameter
10+
11+
- Implementation of SLOP parameter ([PR#8])
12+
13+
### Fixed
14+
15+
- Correclty handle Search result with NoContent flag ([Issue#9], [Issue#10], [PR#13])
1116

1217
## [1.3.0]
1318

@@ -101,5 +106,9 @@ First version
101106
[1.0.0]: https://github.com/MacFJA/php-redisearch/releases/tag/1.0.0
102107

103108
[Issue#2]: https://github.com/MacFJA/php-redisearch/issues/2
109+
[Issue#9]: https://github.com/MacFJA/php-redisearch/issues/9
110+
[Issue#10]: https://github.com/MacFJA/php-redisearch/issues/10
104111
[PR#1]: https://github.com/MacFJA/php-redisearch/pull/1
105-
[PR#3]: https://github.com/MacFJA/php-redisearch/pull/3
112+
[PR#3]: https://github.com/MacFJA/php-redisearch/pull/3
113+
[PR#8]: https://github.com/MacFJA/php-redisearch/pull/8
114+
[PR#13]: https://github.com/MacFJA/php-redisearch/pull/13

src/Search.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -457,12 +457,15 @@ static function ($rawResult, array $context): PaginatedResult {
457457
$payload = ($context['payloads'] ?? false) ? array_shift($document) : null;
458458
$sortKey = ($context['sortKeys'] ?? false) ? array_shift($document) : null;
459459

460-
if (!(1 === count($document))) {
461-
throw new InvalidArgumentException();
460+
$fields = [];
461+
if (false === $context['noContent']) {
462+
if (!(1 === count($document))) {
463+
throw new InvalidArgumentException();
464+
}
465+
$rawData = reset($document);
466+
assert(is_array($rawData));
467+
$fields = RedisHelper::getPairs($rawData);
462468
}
463-
$rawData = reset($document);
464-
assert(is_array($rawData));
465-
$fields = RedisHelper::getPairs($rawData);
466469

467470
return new Result($hash, $fields, $score, $payload, $sortKey);
468471
}, $documents);
@@ -476,6 +479,7 @@ static function ($rawResult, array $context): PaginatedResult {
476479
'scores' => $this->withScores,
477480
'payloads' => $this->withPayloads,
478481
'sortKeys' => $this->withSortKeys,
482+
'noContent' => $this->noContent,
479483
]
480484
);
481485
} finally {

0 commit comments

Comments
 (0)