Skip to content
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

Fix #352: Add support for query parameter search_after to paginate over large datasets #353

Merged
merged 2 commits into from
Oct 27, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Yii Framework 2 Elasticsearch extension Change Log

- Bug #344: Disabled JSON pretty print for ElasticSearch bulk API (rhertogh)
- Bug #350: Remove deprecated code, set $pagination->totalCount (lav45)
- Bug #352: Add support for query parameter `search_after` to paginate over large datasets (lubosdz)


2.1.4 May 22, 2023
Expand Down
6 changes: 6 additions & 0 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ class Query extends Component implements QueryInterface
* @since 2.0.5
*/
public $explain;
/**
* @var array Allows pagination of large datasets.
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after
* @since 2.1.5
*/
public $search_after = [];


/**
Expand Down
3 changes: 3 additions & 0 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public function build($query)
if (!empty($query->collapse)) {
$parts['collapse'] = $query->collapse;
}
if ($query->search_after) {
$parts['search_after'] = $query->search_after;
}

$sort = $this->buildOrderBy($query->orderBy);
if (!empty($sort)) {
Expand Down
Loading