com.sun.labs.minion.query
Class Element

java.lang.Object
  extended by com.sun.labs.minion.query.Element
Direct Known Subclasses:
Operator, Range, Relation, Term

public abstract class Element
extends java.lang.Object

An abstract class for an element in a query: the elements of a query are terms, operators, relations and ranges.


Field Summary
protected  java.util.Set<java.lang.String> fields
          The fields to which this element should be restricted during search.
protected  boolean strict
          Whether this element should be interpreted in a strict boolean fashion.
 
Constructor Summary
Element()
           
 
Method Summary
 void addField(java.lang.String field)
          Adds a field restriction to this element.
 java.util.Set<java.lang.String> getFields()
           
abstract  QueryElement getQueryElement()
          Transduces this query element into a "real" query element, one that can be evaluated by the search engine.
 boolean getStrict()
          Gets the strictness of this element.
 void setFields(java.util.Collection<java.lang.String> fields)
          Adds a number of field restrictions to the element.
 void setStrict(boolean strict)
          Indicates whether this element should be evaluated in a strict boolean context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

strict

protected boolean strict
Whether this element should be interpreted in a strict boolean fashion.


fields

protected java.util.Set<java.lang.String> fields
The fields to which this element should be restricted during search.

Constructor Detail

Element

public Element()
Method Detail

setStrict

public void setStrict(boolean strict)
Indicates whether this element should be evaluated in a strict boolean context. If a particular element is evaluated in a strict boolean context, then documents in the result set generated by the evaluation will not have a score associated with them.

Additionally, combining the results of an element evaluated in a strict boolean context with the results of an element evaluted in a normal context will not result in any change of score for the other results.

In this way, an element evaluated in a strict boolean context can be used to restrict a search without affecting the scores assigned to documents.

Parameters:
strict - if true if this element should be evaluated in a strict bolean context

getStrict

public boolean getStrict()
Gets the strictness of this element.

Returns:
true if this element should be evaluated in a strict bolean context, false otherwise.

addField

public void addField(java.lang.String field)
Adds a field restriction to this element. An element that is restricted to a field will result in a set of documents where the given element occurs only in the given field or fields.

Multiple fields can be added as restrictions. In this case, the field restriction will be satisfied if the element can be satisfied in any of the fields.

For example, the query created using the following code:

 Term t = new Term("dog");
 t.addField("title");
 t.addField("body");
 
would return documents where the word dog occurs in the title of the document or the body (or both).

Parameters:
field - the field to which we wish to restrict the search.
See Also:
setFields(java.util.Collection)

setFields

public void setFields(java.util.Collection<java.lang.String> fields)
Adds a number of field restrictions to the element. An element that is restricted to a field will result in a set of documents where the given element occurs only in the given field or fields. The field restriction will be satisfied if the element can be satisfied in any of the fields.

For example, the query created using the following code:

 Term t = new Term("dog");
 Set s = new HashSet();
 s.add("title");
 s.add("dog");
 t.setFields(s);
 
would return documents where the word dog occurs in the title of the document or the body (or both). * @param fields


getFields

public java.util.Set<java.lang.String> getFields()

getQueryElement

public abstract QueryElement getQueryElement()
Transduces this query element into a "real" query element, one that can be evaluated by the search engine.

Returns:
an evaluatable query element.