- java.lang.Object
-
- org.apache.lucene.expressions.Bindings
-
- org.apache.lucene.expressions.SimpleBindings
-
public final class SimpleBindings extends Bindings
Simple class that binds expression variable names toDoubleValuesSource
s or otherExpression
s.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));
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
SimpleBindings.CycleDetectionBindings
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,java.util.function.Function<Bindings,DoubleValuesSource>>
map
-
Constructor Summary
Constructors Constructor Description SimpleBindings()
Creates a new empty Bindings
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.String name, Expression expression)
Adds an Expression to the bindings.void
add(java.lang.String name, DoubleValuesSource source)
Bind aDoubleValuesSource
directly to the given name.DoubleValuesSource
getDoubleValuesSource(java.lang.String name)
Returns a DoubleValuesSource bound to the variable namevoid
validate()
Traverses the graph of bindings, checking there are no cycles or missing references
-
-
-
Field Detail
-
map
private final java.util.Map<java.lang.String,java.util.function.Function<Bindings,DoubleValuesSource>> map
-
-
Method Detail
-
add
public void add(java.lang.String name, DoubleValuesSource source)
Bind aDoubleValuesSource
directly to the given name.
-
add
public void add(java.lang.String name, Expression expression)
Adds an Expression to the bindings.This can be used to reference expressions from other expressions.
-
getDoubleValuesSource
public DoubleValuesSource getDoubleValuesSource(java.lang.String name)
Description copied from class:Bindings
Returns a DoubleValuesSource bound to the variable name- Specified by:
getDoubleValuesSource
in classBindings
-
validate
public void validate()
Traverses the graph of bindings, checking there are no cycles or missing references- Throws:
java.lang.IllegalArgumentException
- if the bindings is inconsistent
-
-