Optional cost reporter. When set, the reranker invokes it after each successful
Rerank call with the actual cents charged. The SearchEngine wires this from the
RerankerBudgetGuard to the scope-level spend tracker — see Phase 2D.6.
The DriverClass key used by @RegisterClass(BaseReRanker, 'DriverClassName') so
the SearchEngine can resolve this subclass via ClassFactory from the scope's
ScopeConfig.reRanker.driverClass value.
Human-friendly display name. Defaults to DriverClass so subclasses don't have to
override unless they want a different label in UI dropdowns / cost reports.
Reranker semantic version (independent of the package version). Bump this on a
subclass when the prompt, scoring formula, or upstream model identifier changes
in a way that invalidates cached scores. Defaults to '1'.
ProtectedbuildBuild the text representation of a SearchResultItem for the rerank model.
Default concatenates Title and Snippet separated by newline. Override to
customize (e.g. include tags or entity context).
Pre-call cost estimate. ~80 input tokens/doc + 50 system/query tokens, plus 8 output tokens/doc. Conservative — actual usage tends to be lower.
ProtectedgetReturn the underlying @memberjunction/ai BaseReranker instance to use.
Provider-specific subclasses (Cohere, BGE, Voyage) override this to return a
configured AI reranker. Returning null (the default) tells ReRank() to
skip the AI layer and fall back to a simple top-N slice — useful for Noop
and test implementations.
Provider-specific config from ScopeConfig.reRanker.config.
The calling user (for auth / tenant propagation).
Effective limit when the candidate list plus prompt fits in the model's input window. With gpt-4o-mini's 128k input context and ~80 tokens/doc, the practical cap is well above 1000. Returning 1000 to match the other rerankers; the SearchEngine will chunk above this when chunking is implemented.
ProtectedreportHelper for subclasses: report a cost AND record it on the optional callback. Always safe to call even when no callback is set.
Score and re-order candidates against the query.
Default implementation:
topN <= 0 or candidates is empty.getAIReranker(). If none, slices to topN.SearchResultItem[] to RerankDocument[] (preserving each original item
in metadata.__mjSearchItem).Rerank() — inherits validation, timing, error handling.RerankResult[] back to SearchResultItem[], replacing
Score with relevanceScore and augmenting ScoreBreakdown with a ReRank key.Subclasses that bypass the AI layer (e.g. NoopReRanker) may override this method.
The original query text.
The fused candidate list (post-RRF, pre-dedup).
Maximum number of candidates to return after re-ranking.
The calling user (for auth / tenant propagation).
Optionalconfig: Record<string, unknown>Optional provider-specific config from ScopeConfig.reRanker.config.
StaticGetEnumerate every reranker currently registered with ClassFactory under
BaseReRanker. Designed for the SearchScope form's reranker dropdown (P2D.7) —
the form populates the dropdown from this single call rather than hardcoding
a list, so any ClassFactory-registered reranker (including third-party ones
published as separate packages) shows up automatically.
Each entry includes the driver-class registration key, the friendly Name,
Version, and a HasCost flag (true when EstimateCostCents(1) > 0). Sorted
by Name for stable UI ordering.
Chat-completion-based "judge" reranker. Configure per scope via
SearchScope.ScopeConfig.reRanker.driverClass = 'OpenAIReRanker'.Override the model via
ScopeConfig.reRanker.config.model(default:gpt-4o-mini— change when a first-party OpenAI rerank endpoint launches).