-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add AnytimeRankingSearcher for SLA-Aware Early Termination with Bin-Based Score Boosting #14525
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
Open
atris
wants to merge
47
commits into
main
Choose a base branch
from
index_binning_changes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,195
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…riterion for graph building
@jpountz This PR is now ready for review. I will post luceneutil benchmarks tomorrow. Please let me know if anything else is needed from me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add AnytimeRankingSearcher for SLA-aware early termination with bin-based score boosting
This patch adds AnytimeRankingSearcher, a new low-latency search implementation that supports early termination under SLA constraints, combined with bin-aware score boosting.
Architecture
Index-time binning uses a configurable post-indexing pass to assign each document to one of bin.count bins. This pass is activated via field attributes (doBinning=true, bin.count=N, etc.) and is triggered after all standard postings are written. Binning uses a segment-local sparse similarity graph where each node is a document and edges represent cosine similarity between term frequency vectors.
The bin distribution is computed via recursive graph bisection. The graph is recursively split into halves using a seeded heuristic that assigns each document to the closer of two seed nodes based on edge weights. This ensures intra-bin similarity and minimizes cross-bin connectivity. A fixed number of bins is produced, and the assignment is saved to a .binmap file.
In approximate mode (graph.builder=approx), we avoid building explicit term vectors. Instead, token co-occurrence is tracked using per-term BitSets, and documents are grouped using lightweight overlap heuristics. This trades off precision for speed and scales better on large segments.
At search time, BinMapReader loads the bin assignments, and BinScoreReader makes them accessible to search collectors. BinBoostCalculator assigns a boost score to each bin based on estimated bin quality (e.g. average term frequency or rank share in a warmup run). This boost is applied additively during ranking, allowing the collector to prioritize high-quality bins earlier and exit faster under SLA pressure.
Binning Modes (Index Time)
This patch supports two modes of document binning during indexing:
• Absolute mode: computes exact bin assignments using full document similarity graphs.
• Approximate mode: enabled when document count exceeds a threshold; skips graph construction and uses faster heuristics to assign bins.
Bin assignment is handled by DocBinningGraphBuilder and switches to ApproximateDocGraphBuilder automatically when needed.
To enable binning, field attributes must be set:
Search-Time Integration
At search time, bin boosts are loaded using BinScoreReader. To enable anytime ranking:
Internally:
• Bin scores are applied per segment at query time.
• The collector monitors elapsed time and stops scoring once SLA is exhausted.
Test Coverage
Includes a full test (TestAnytimeRankingSearchQuality) that:
• Indexes 10k docs with periodic relevant content
• Runs baseline and anytime search
• Computes NDCG, precision, recall
• Asserts average and max position delta across result sets
• Verifies minimal degradation under SLA constraints
Performance
• AnytimeRankingSearcher provides ~2–3x speedup at low SLA targets
• Recall, precision, and NDCG remain within 95%+ of baseline
• Position delta of relevant docs remains bounded
Notes
• Readers are wrapped using BinScoreUtil.wrap(reader) to enable bin-aware scoring
• Compound readers are tracked and closed explicitly
• BinFilter skipping is not implemented yet — will be added in a follow-up patch
• Fallback to approximate binning ensures indexing remains scalable for large segments
Benchmarks