Skip to content

Commit 92aceec

Browse files
committed
Update README.md
1 parent d89fffa commit 92aceec

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ $posts = Post::search('laravel')->get();
7777

7878
The driver converts Scout builders into OpenSearch search requests and uses the configured OpenSearch client connection to index, delete, flush, and search models.
7979

80+
### Cursor Pagination
81+
82+
For deep pagination, use `cursorPaginate` with an explicit, stable sort:
83+
84+
```php
85+
$posts = Post::search('laravel')
86+
->orderBy('published_at', 'desc')
87+
->orderBy('id', 'desc')
88+
->cursorPaginate(25);
89+
```
90+
91+
Cursor pagination uses OpenSearch `search_after` values internally and returns Laravel's standard `CursorPaginator` response shape, including `next_cursor` and `prev_cursor`.
92+
93+
OpenSearch only returns reusable `search_after` values for sorted searches, so cursor pagination requires at least one explicit sort. Prefer adding a unique indexed tie-breaker, such as an indexed model key, as the final sort.
94+
8095
## Credits
8196

8297
This package builds on a lot of the foundation and prior work from [Ivan Babenko](https://github.com/babenkoivan) and his Elasticsearch Laravel ecosystem packages.

0 commit comments

Comments
 (0)