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

BREAKING: Add cancellation support to IndexSearcher, #922 #1080

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

paulirwin
Copy link
Contributor

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a change, please open an issue to discuss the change or find an existing issue.

Adds basic cancellation support to IndexSearcher.

Fixes #922

Description

This adds optional CancellationToken parameters to all IndexSearcher.Search and SearchAfter methods, which is a breaking change to the API.

If an executor is provided in the constructor for multithreaded search, then the provided CancellationToken is passed to the Task.Wait(CancellationToken) method. If an executor is not provided, then it will call ThrowIfCancellationRequested() in the synchronous case at the evaluation of each leaf reader context.

This will not help cancellation for i.e. single-leaf reader contexts that might take a while to complete (that would require a much larger and messier change to add CancellationToken support to Scorer and ICollector, and benchmarking to ensure we don't hurt performance by doing so), but should at least help with many scenarios that require cancellation.

I wanted to publish this draft PR for feedback; please let me know if you like this direction or have concerns.

@paulirwin paulirwin added the notes:breaking-change Has changes that will break backward compatibility label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notes:breaking-change Has changes that will break backward compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add cancellation support to IndexSearcher
1 participant