org.apache.lucene.expressions
Class SimpleBindings

java.lang.Object
  extended by org.apache.lucene.expressions.Bindings
      extended by org.apache.lucene.expressions.SimpleBindings

public final class SimpleBindings
extends Bindings

Simple class that binds expression variable names to SortFields or other Expressions.

Example usage:

   SimpleBindings bindings = new SimpleBindings();
   // document's text relevance score
   bindings.add(new SortField("_score", SortField.Type.SCORE));
   // integer NumericDocValues field (or from FieldCache) 
   bindings.add(new SortField("popularity", SortField.Type.INT));
   // 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
SimpleBindings()
          Creates a new empty Bindings
 
Method Summary
 void add(SortField sortField)
          Adds a SortField to the bindings.
 void add(String name, Expression expression)
          Adds an Expression to the bindings.
 ValueSource getValueSource(String name)
          Returns a ValueSource bound to the variable name.
 void validate()
          Traverses the graph of bindings, checking there are no cycles or missing references
 
Methods inherited from class org.apache.lucene.expressions.Bindings
getScoreValueSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleBindings

public SimpleBindings()
Creates a new empty Bindings

Method Detail

add

public void add(SortField sortField)
Adds a SortField to the bindings.

This can be used to reference a DocValuesField, a field from FieldCache, the document's score, etc.


add

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

This can be used to reference expressions from other expressions.


getValueSource

public ValueSource getValueSource(String name)
Description copied from class: Bindings
Returns a ValueSource bound to the variable name.

Specified by:
getValueSource 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


Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.