FileDocCategorySizeDatePackage
TermQuery.javaAPI DocApache Lucene 1.4.35457Tue Mar 30 00:48:04 BST 2004org.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 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());
    if (getBoost() != 1.0f) {
      buffer.append("^");
      buffer.append(Float.toString(getBoost()));
    }
    return buffer.toString();