FileDocCategorySizeDatePackage
ConstantScoreQuery.javaAPI DocApache Lucene 2.1.04930Wed Feb 14 10:46:38 GMT 2007org.apache.lucene.search

ConstantScoreQuery

public class ConstantScoreQuery extends Query
A query that wraps a filter and simply returns a constant score equal to the query boost for every document in the filter.
author
yonik
version
$Id: ConstantScoreQuery.java 507374 2007-02-14 03:12:50Z yonik $

Fields Summary
protected final Filter
filter
Constructors Summary
public ConstantScoreQuery(Filter filter)

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

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

    if (this == o) return true;
    if (!(o instanceof ConstantScoreQuery)) return false;
    ConstantScoreQuery other = (ConstantScoreQuery)o;
    return this.getBoost()==other.getBoost() && filter.equals(other.filter);
  
public voidextractTerms(java.util.Set terms)

    // OK to not add any terms when used for MultiSearcher,
    // but may not be OK for highlighting
  
public org.apache.lucene.search.FiltergetFilter()
Returns the encapsulated filter

    return filter;
  
public inthashCode()
Returns a hash code value for this object.

    // Simple add is OK since no existing filter hashcode has a float component.
    return filter.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)
Prints a user-readable version of this query.

    return "ConstantScore(" + filter.toString()
      + (getBoost()==1.0 ? ")" : "^" + getBoost());