Class LogOddsFusionQuery
BayesianScoreQuery
wrapping a BM25 query, or KNN cosine similarity).
The combination formula resolves the shrinkage problem of naive probabilistic AND by:
- Converting each sub-score to log-odds: logit(p) = log(p / (1 - p))
- Computing the mean log-odds across all clauses (non-matching contribute 0 = neutral)
- Applying multiplicative confidence scaling: meanLogit * n^alpha
- Converting back to probability via sigmoid
The alpha parameter controls the confidence scaling exponent. The default alpha=0.5 implements the sqrt(n) scaling law from "From Bayesian Inference to Neural Computation".
Optional per-signal weights enable weighted Log-OP (Logarithmic Opinion Pooling) where each
signal's log-odds contribution is scaled by its reliability weight. Weights must be non-negative
and sum to 1. When weights are provided, the scoring formula becomes: sigmoid(n^alpha *
sum(w_i * softplus(logit(p_i)))) instead of the uniform mean.
- See Also:
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classWeight for LogOddsFusionQuery. -
Constructor Summary
ConstructorsConstructorDescriptionLogOddsFusionQuery(Collection<? extends Query> clauses) Creates a new LogOddsFusionQuery with default alpha=0.5, uniform weighting, and softplus gating.LogOddsFusionQuery(Collection<? extends Query> clauses, float alpha) Creates a new LogOddsFusionQuery with uniform weighting and softplus gating.LogOddsFusionQuery(Collection<? extends Query> clauses, float alpha, float[] weights) Creates a new LogOddsFusionQuery with per-signal weights (softplus gating, no normalization).LogOddsFusionQuery(Collection<? extends Query> clauses, float alpha, float[] weights, float[] logitMin, float[] logitMax) Creates a new LogOddsFusionQuery with per-signal weights and optional logit normalization. -
Method Summary
Modifier and TypeMethodDescriptioncreateWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) Expert: Constructs an appropriate Weight implementation for this query.booleanOverride and implement query instance equivalence properly in a subclass.floatgetAlpha()Returns the alpha (confidence scaling exponent).Returns the clauses.float[]Returns a copy of the per-signal weights, or null if uniform weighting is used.inthashCode()Override and implement query hash code properly in a subclass.iterator()rewrite(IndexSearcher indexSearcher) Expert: called to re-write queries into primitive queries.Prints a query to a string, withfieldassumed to be the default field and omitted.voidvisit(QueryVisitor visitor) Recurse through the query tree, visiting any child queries.Methods inherited from class org.apache.lucene.search.Query
classHash, sameClassAs, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
LogOddsFusionQuery
public LogOddsFusionQuery(Collection<? extends Query> clauses, float alpha, float[] weights, float[] logitMin, float[] logitMax) Creates a new LogOddsFusionQuery with per-signal weights and optional logit normalization.- Parameters:
clauses- the sub-queries to combinealpha- confidence scaling exponent (0.5 = sqrt(n) law)weights- per-signal weights (must be non-negative, finite, and sum to 1.0), or null for uniform weightinglogitMin- per-signal logit lower bounds for normalization, or null to use softplus gatinglogitMax- per-signal logit upper bounds for normalization, or null to use softplus gating- Throws:
IllegalArgumentException- if alpha is not in [0, 1], or weights/bounds are invalid
-
LogOddsFusionQuery
Creates a new LogOddsFusionQuery with per-signal weights (softplus gating, no normalization).- Parameters:
clauses- the sub-queries to combinealpha- confidence scaling exponent (0.5 = sqrt(n) law)weights- per-signal weights, or null for uniform weighting- Throws:
IllegalArgumentException- if alpha is not in [0, 1], or weights are invalid
-
LogOddsFusionQuery
Creates a new LogOddsFusionQuery with uniform weighting and softplus gating.- Parameters:
clauses- the sub-queries to combinealpha- confidence scaling exponent (0.5 = sqrt(n) law)- Throws:
IllegalArgumentException- if alpha is not in [0, 1]
-
LogOddsFusionQuery
Creates a new LogOddsFusionQuery with default alpha=0.5, uniform weighting, and softplus gating.- Parameters:
clauses- the sub-queries to combine
-
-
Method Details
-
iterator
-
getClauses
Returns the clauses. -
getAlpha
public float getAlpha()Returns the alpha (confidence scaling exponent). -
getWeights
public float[] getWeights()Returns a copy of the per-signal weights, or null if uniform weighting is used.When non-null, the i-th element is the weight for the i-th clause in the order returned by
getClauses(). -
createWeight
public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException Description copied from class:QueryExpert: Constructs an appropriate Weight implementation for this query.Only implemented by primitive queries, which re-write to themselves.
- Overrides:
createWeightin classQuery- Parameters:
scoreMode- How the produced scorers will be consumed.boost- The boost that is propagated by the parent queries.- Throws:
IOException
-
rewrite
Description copied from class:QueryExpert: called to re-write queries into primitive queries. For example, a PrefixQuery will be rewritten into a BooleanQuery that consists of TermQuerys.Callers are expected to call
rewritemultiple times if necessary, until the rewritten query is the same as the original query.The rewrite process may be able to make use of IndexSearcher's executor and be executed in parallel if the executor is provided.
- Overrides:
rewritein classQuery- Throws:
IOException- See Also:
-
visit
Description copied from class:QueryRecurse through the query tree, visiting any child queries. -
toString
Description copied from class:QueryPrints a query to a string, withfieldassumed to be the default field and omitted. -
equals
Description copied from class:QueryOverride and implement query instance equivalence properly in a subclass. This is required so thatQueryCacheworks properly.Typically a query will be equal to another only if it's an instance of the same class and its document-filtering properties are identical to those of the other instance. Utility methods are provided for certain repetitive code.
-
hashCode
public int hashCode()Description copied from class:QueryOverride and implement query hash code properly in a subclass. This is required so thatQueryCacheworks properly.
-