Class Expression
Base class that computes the value of an expression for a document.
Inheritance
System.Object
Expression
Assembly: Lucene.Net.Expressions.dll
Syntax
public abstract class Expression : object
Remarks
Base class that computes the value of an expression for a document.
Example usage:
// compile an expression:
Expression expr = JavascriptCompiler.Compile("sqrt(_score) + ln(popularity)");
// SimpleBindings just maps variables to SortField instances
SimpleBindings bindings = new SimpleBindings();
bindings.Add(new SortField("_score", SortFieldType.SCORE));
bindings.Add(new SortField("popularity", SortFieldType.INT));
// create a sort field and sort by it (reverse order)
Sort sort = new Sort(expr.GetSortField(bindings, true));
Query query = new TermQuery(new Term("body", "contents"));
searcher.Search(query, null, 10, sort);
@lucene.experimental
Constructors
Name | Description |
---|---|
Expression(String, String[]) | Creates a new Expression. |
Properties
Name | Description |
---|---|
SourceText | The original source text |
Variables | Named variables referred to by this expression |
Methods
Name | Description |
---|---|
Evaluate(Int32, FunctionValues[]) | Evaluates the expression for the given document. |
GetRescorer(Bindings) | Get a |
GetSortField(Bindings, Boolean) | Get a sort field which can be used to rank documents by this expression. |
GetValueSource(Bindings) | Get a value source which can compute the value of this expression in the context of the given bindings. |