Skip to content
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
4 changes: 4 additions & 0 deletions src/DSL/Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,10 @@ private function _sanitizeSearchResponse($response, $params, $queryTag)
$datum['_meta']['highlights'] = $this->_sanitizeHighlights($hit['highlight']);
}

if (!empty($hit['sort']) && is_array($hit['sort'])) {
$datum['_meta']['sort'] = $hit['sort'];
}

$datum['_meta']['_index'] = $hit['_index'];
$datum['_meta']['_id'] = $hit['_id'];
if (!empty($hit['_score'])) {
Expand Down
3 changes: 3 additions & 0 deletions src/DSL/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ private function _buildOptions($options): array
}
}
break;
case 'search_after':
$return['body']['search_after'] = $value;
break;
case 'skip':
$return['from'] = $value;
break;
Expand Down
9 changes: 9 additions & 0 deletions src/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,15 @@ public function minScore(float $value)
return $this;
}

public function searchAfter(array $sort): self
{
if (empty($sort)) {
return $this;
}
$this->query->searchAfter($sort);
return $this;
}

/**
* @param string $field
* @param int|null $boostFactor
Expand Down
1 change: 1 addition & 0 deletions src/Eloquent/Docs/ModelDocs.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @method $this minScore(float $value)
* @method $this field(string $field, int $boostFactor = null)
* @method $this fields(array $fields)
* @method $this searchAfter(array $sort)
* @method sum(array|string $columns)
* @method min(array|string $columns)
* @method max(array|string $columns)
Expand Down
14 changes: 14 additions & 0 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Builder extends BaseBuilder

public $filters = [];

public $searchAfter = [];

/**
* Clause ops.
*
Expand Down Expand Up @@ -792,6 +794,15 @@ public function orWhereRegex($column, $expression)
return $this;
}

public function searchAfter($sort)
{
if (!is_array($sort) || !Arr::isList($sort)) {
throw new RuntimeException('Incorrect "searchAfter" value');
}
$this->searchAfter = $sort;
return $this;
}

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -857,6 +868,9 @@ protected function compileOptions()
if ($this->filters) {
$options['filters'] = $this->filters;
}
if (!empty($this->searchAfter)) {
$options['search_after'] = $this->searchAfter;
}

return $options;
}
Expand Down