FileDocCategorySizeDatePackage
ConstantScoreQuery.javaAPI DocApache Lucene 1.94475Mon Feb 20 09:20:04 GMT 2006org.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$

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 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());