/// <summary> /// Uses the provided /// <see cref="Lucene.Net.Queries.Function.ValueSource">Lucene.Net.Queries.Function.ValueSource /// </see> /// to assign second /// pass scores. /// </summary> public ExpressionRescorer(Expression expression, Bindings bindings) : base(new Sort (expression.GetSortField(bindings, true))) { this.expression = expression; this.bindings = bindings; }
internal ExpressionValueSource(Bindings bindings, Expression expression) { if (bindings == null) { throw new ArgumentNullException(); } if (expression == null) { throw new ArgumentNullException(); } this.expression = expression; variables = new ValueSource[expression.variables.Length]; bool needsScores = false; for (int i = 0; i < variables.Length; i++) { ValueSource source = bindings.GetValueSource(expression.variables[i]); if (source is ScoreValueSource) { needsScores = true; } else { var valueSource = source as ExpressionValueSource; if (valueSource != null) { if (valueSource.NeedsScores()) { needsScores = true; } } else { if (source == null) { throw new SystemException("Internal error. Variable (" + expression.variables[i] + ") does not exist."); } } } variables[i] = source; } this.needsScores = needsScores; }
/// <summary>Get a sort field which can be used to rank documents by this expression. /// </summary> /// <remarks>Get a sort field which can be used to rank documents by this expression. /// </remarks> public virtual SortField GetSortField(Bindings bindings, bool reverse) { return GetValueSource(bindings).GetSortField(reverse); }
/// <summary> /// Get a /// <see cref="Lucene.Net.Search.Rescorer">Lucene.Net.Search.Rescorer</see> /// , to rescore first-pass hits /// using this expression. /// </summary> public virtual Rescorer GetRescorer(Bindings bindings) { return new ExpressionRescorer(this, bindings); }
/// <summary>Get a value source which can compute the value of this expression in the context of the given bindings. /// </summary> /// <remarks>Get a value source which can compute the value of this expression in the context of the given bindings. /// </remarks> /// <param name="bindings">Bindings to use for external values in this expression</param> /// <returns>A value source which will evaluate this expression when used</returns> public virtual ValueSource GetValueSource(Bindings bindings) { return new ExpressionValueSource(bindings, this); }