FileDocCategorySizeDatePackage
TermQuery.javaAPI DocApache Lucene 2.1.05853Wed Feb 14 10:46:40 GMT 2007org.apache.lucene.search

TermQuery

public class TermQuery extends Query
A Query that matches documents containing a term. This may be combined with other terms with a {@link BooleanQuery}.

Fields Summary
private Term
term
Constructors Summary
public TermQuery(Term t)
Constructs a query for the term t.

    term = t;
  
Methods Summary
protected org.apache.lucene.search.WeightcreateWeight(org.apache.lucene.search.Searcher searcher)

    return new TermWeight(searcher);
  
public booleanequals(java.lang.Object o)
Returns true iff o is equal to this.

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

    terms.add(getTerm());
  
public org.apache.lucene.index.TermgetTerm()
Returns the term of this query.

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

    return Float.floatToIntBits(getBoost()) ^ term.hashCode();
  
public java.lang.StringtoString(java.lang.String field)
Prints a user-readable version of this query.

    StringBuffer buffer = new StringBuffer();
    if (!term.field().equals(field)) {
      buffer.append(term.field());
      buffer.append(":");
    }
    buffer.append(term.text());
    buffer.append(ToStringUtils.boost(getBoost()));
    return buffer.toString();