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

Support for efficient deep paging in lucene.net #320

Merged
merged 10 commits into from
Apr 14, 2023

Conversation

nzdev
Copy link
Contributor

@nzdev nzdev commented Dec 12, 2022

Support for efficient deep paging in lucene.net.
Uses SearchAfter instead of Search when the SearchAfterOptions are available.
This allows lucene to efficiently skip documents before the last document from the previous page fetched for a search.

Steps:

  1. Build and execute your query as normal.
  2. Cast the ISearchResults from IQueryExecutor.Execute to ILuceneSearchResults
  3. Store ILuceneSearchResults.SearchAfter (SearchAfterOptions) for the next page. It may be worth serializing this class and cryptographically hashing it to prevent tampering in a web application so that it can be made available to the next request for the next page.
  4. Create the same query as the previous request.
  5. When calling IQueryExecutor.Execute. Pass in new LuceneQueryOptions(skip,take, SearchAfterOptions); Skip will be ignored, the next take documents will be retrieved after the SearchAfterOptions document.
  6. Repeat Steps 2-5 for each page.

Added documentation.
Added tests.

Copy link
Owner

@Shazwazza Shazwazza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! and looks like it doesn't introduce breaking changes which is a winner. Have added some comments.

docs/sorting.md Outdated Show resolved Hide resolved
src/Examine.Core/EmptySearchResults.cs Outdated Show resolved Hide resolved
src/Examine.Test/Examine.Lucene/Search/FluentApiTests.cs Outdated Show resolved Hide resolved
@Shazwazza Shazwazza added this to the 3.2.0 milestone Apr 14, 2023
@Shazwazza Shazwazza merged commit b5d99ce into Shazwazza:release/3.0 Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants