Class SimpleBindings

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 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
    Constructor
    Description
    Creates a new empty Bindings
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String name, Expression expression)
    Adds an Expression to the bindings.
    void
    add(String name, org.apache.lucene.search.DoubleValuesSource source)
    Bind a DoubleValuesSource directly to the given name.
    org.apache.lucene.search.DoubleValuesSource
    Returns a DoubleValuesSource bound to the variable name
    void
    Traverses the graph of bindings, checking there are no cycles or missing references

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SimpleBindings

      public SimpleBindings()
      Creates a new empty Bindings
  • Method Details

    • add

      public void add(String name, org.apache.lucene.search.DoubleValuesSource source)
      Bind a DoubleValuesSource directly to the given name.
    • add

      public void add(String name, Expression expression)
      Adds an Expression to the bindings.

      This can be used to reference expressions from other expressions.

    • getDoubleValuesSource

      public org.apache.lucene.search.DoubleValuesSource getDoubleValuesSource(String name)
      Description copied from class: Bindings
      Returns a DoubleValuesSource bound to the variable name
      Specified by:
      getDoubleValuesSource in class Bindings
    • validate

      public void validate()
      Traverses the graph of bindings, checking there are no cycles or missing references
      Throws:
      IllegalArgumentException - if the bindings is inconsistent