Skip to content

Commit d417e7d

Browse files
authored
Merge pull request #8 from ghdi/slop
Added slop functionality
2 parents e3e66ca + 5d3f918 commit d417e7d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Diff for: CHANGELOG.md

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

77
## [Unreleased]
88

9+
### Added
10+
- Implementation of SLOP parameter
11+
912
## [1.3.0]
1013

1114
### Added

Diff for: src/Search.php

+15-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class Search implements Builder, Pipeable
109109
/** @var null|Highlight */
110110
private $highlight;
111111

112-
//slop
112+
/** @var null|int */
113+
private $slop = null;
113114

114115
/** @var bool */
115116
private $inOrder = false;
@@ -164,6 +165,7 @@ public function reset(): Builder
164165
$this->returns = [];
165166
$this->summarize = null;
166167
$this->highlight = null;
168+
$this->slop = null;
167169
$this->inOrder = false;
168170
$this->language = null;
169171
$this->expander = null;
@@ -318,6 +320,14 @@ public function withHighlight(array $fields = [], ?string $openTag = null, ?stri
318320
return $this;
319321
}
320322

323+
public function withSlop(int $slop = 0): Search
324+
{
325+
$this->slop = $slop;
326+
327+
return $this;
328+
}
329+
330+
321331
public function withInOrder(bool $inOrder = true): Search
322332
{
323333
$this->inOrder = $inOrder;
@@ -506,6 +516,10 @@ private function buildQuery(): array
506516
$query = RedisHelper::buildQueryPartial($query,
507517
array_merge($this->filters, [$this->geoFilter, $this->summarize, $this->highlight])
508518
);
519+
if (is_int($this->slop)) {
520+
$query[] = 'SLOP';
521+
$query[] = $this->slop;
522+
}
509523
if (is_string($this->sortBy)) {
510524
$query[] = 'SORTBY';
511525
$query[] = $this->sortBy;

0 commit comments

Comments
 (0)