FileDocCategorySizeDatePackage
ValueSourceQuery.javaAPI DocApache Lucene 2.2.06891Sat Jun 16 22:20:34 BST 2007org.apache.lucene.search.function

ValueSourceQuery

public class ValueSourceQuery extends Query
Expert: A Query that sets the scores of document to the values obtained from a {@link org.apache.lucene.search.function.ValueSource ValueSource}.

The value source can be based on a (cached) value of an indexd field, but it can also be based on an external source, e.g. values read from an external database.

Score is set as: Score(doc,query) = query.getBoost()2 * valueSource(doc).

WARNING: The status of the search.function package is experimental. The APIs introduced here might change in the future and will not be supported anymore in such a case.

author
yonik

Fields Summary
ValueSource
valSrc
Constructors Summary
public ValueSourceQuery(ValueSource valSrc)
Create a value source query

param
valSrc provides the values defines the function to be used for scoring

    this.valSrc=valSrc;
  
Methods Summary
protected org.apache.lucene.search.WeightcreateWeight(org.apache.lucene.search.Searcher searcher)

    return new ValueSourceQuery.ValueSourceWeight(searcher);
  
public booleanequals(java.lang.Object o)
Returns true if o is equal to this.

    if (getClass() != o.getClass()) {
      return false;
    }
    ValueSourceQuery other = (ValueSourceQuery)o;
    return this.getBoost() == other.getBoost()
           && this.valSrc.equals(other.valSrc);
  
public voidextractTerms(java.util.Set terms)

    // no terms involved here
  
public inthashCode()
Returns a hash code value for this object.

    return (getClass().hashCode() + valSrc.hashCode()) ^ Float.floatToIntBits(getBoost());
  
public org.apache.lucene.search.Queryrewrite(org.apache.lucene.index.IndexReader reader)

    return this;
  
public java.lang.StringtoString(java.lang.String field)

    return valSrc.toString() + ToStringUtils.boost(getBoost());