Package org.apache.lucene.expressions
Class SimpleBindings
java.lang.Object
org.apache.lucene.expressions.Bindings
org.apache.lucene.expressions.SimpleBindings
Simple class that binds expression variable names to
DoubleValuesSources or other Expressions.
Example usage:
SimpleBindings bindings = new SimpleBindings();
// document's text relevance score
bindings.add("_score", DoubleValuesSource.SCORES);
// integer NumericDocValues field
bindings.add("popularity", DoubleValuesSource.fromIntField("popularity"));
// another expression
bindings.add("recency", myRecencyExpression);
// create a sort field in reverse order
Sort sort = new Sort(expr.getSortField(bindings, true));
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(String name, Expression expression) Adds an Expression to the bindings.voidadd(String name, DoubleValuesSource source) Bind aDoubleValuesSourcedirectly to the given name.getDoubleValuesSource(String name) Returns a DoubleValuesSource bound to the variable namevoidvalidate()Traverses the graph of bindings, checking there are no cycles or missing references
-
Constructor Details
-
SimpleBindings
public SimpleBindings()Creates a new empty Bindings
-
-
Method Details
-
add
Bind aDoubleValuesSourcedirectly to the given name. -
add
Adds an Expression to the bindings.This can be used to reference expressions from other expressions.
-
getDoubleValuesSource
Description copied from class:BindingsReturns a DoubleValuesSource bound to the variable name- Specified by:
getDoubleValuesSourcein classBindings
-
validate
public void validate()Traverses the graph of bindings, checking there are no cycles or missing references- Throws:
IllegalArgumentException- if the bindings is inconsistent
-