Skip to content

Conversation

@guram-vashakidze
Copy link
Contributor

#13

@pdphilip
Copy link
Owner

pdphilip commented Mar 2, 2025

Thanks, @guram-vashakidze, I haven't brought over the unit tests from the parent ES version of the package, and internally I run tests based off: https://github.com/pdphilip/laravel-elasticsearch-tests

For the sake of documentation and for me to append internal tests until I upgrade to GitHub actions, could you share detailed code snippets of the implementation of this?

@guram-vashakidze
Copy link
Contributor Author

@pdphilip, As I understood you correct - you asked example of code for usage this new feature:

$index = new OpenSearchModel();
$firstPage = $index
    ->where('foo', 'bar')
    ->orderBy('@timestamp')
    ->orderBy('_id')
    ->limit(10)
    ->get();
$lastSort = $firstPage
    ->last()
    ->getMeta()
    ->sort;
$nextPage = $index
    ->where('foo', 'bar')
    ->orderBy('@timestamp')
    ->orderBy('_id')
    ->searchAfter($lastSort)
    ->limit(10)
    ->get();

In Model's meta i added sort parameter (if it exists in response). The last sort parameter you can use for getting next page by ->searchAfter($lastSort)

@pdphilip
Copy link
Owner

pdphilip commented Mar 3, 2025

Thanks @guram-vashakidze, will review and let you know

@pdphilip pdphilip merged commit 32dbefe into pdphilip:main Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants