org.apache.lucene.search
Class PrefixQuery

java.lang.Object
  extended by org.apache.lucene.search.Query
      extended by org.apache.lucene.search.MultiTermQuery
          extended by org.apache.lucene.search.PrefixQuery
All Implemented Interfaces:
Cloneable

public class PrefixQuery
extends MultiTermQuery

A Query that matches documents containing terms with a specified prefix. A PrefixQuery is built by QueryParser for input like app*.

This query uses the MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT rewrite method.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.search.MultiTermQuery
MultiTermQuery.ConstantScoreAutoRewrite, MultiTermQuery.RewriteMethod, MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite, MultiTermQuery.TopTermsScoringBooleanQueryRewrite
 
Field Summary
 
Fields inherited from class org.apache.lucene.search.MultiTermQuery
CONSTANT_SCORE_AUTO_REWRITE_DEFAULT, CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE, CONSTANT_SCORE_FILTER_REWRITE, field, rewriteMethod, SCORING_BOOLEAN_QUERY_REWRITE
 
Constructor Summary
PrefixQuery(Term prefix)
          Constructs a query for terms starting with prefix.
 
Method Summary
 boolean equals(Object obj)
           
 Term getPrefix()
          Returns the prefix of this query.
protected  TermsEnum getTermsEnum(Terms terms, AttributeSource atts)
          Construct the enumeration to be used, expanding the pattern term.
 int hashCode()
           
 String toString(String field)
          Prints a user-readable version of this query.
 
Methods inherited from class org.apache.lucene.search.MultiTermQuery
getField, getRewriteMethod, getTermsEnum, rewrite, setRewriteMethod
 
Methods inherited from class org.apache.lucene.search.Query
clone, createWeight, extractTerms, getBoost, setBoost, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrefixQuery

public PrefixQuery(Term prefix)
Constructs a query for terms starting with prefix.

Method Detail

getPrefix

public Term getPrefix()
Returns the prefix of this query.


getTermsEnum

protected TermsEnum getTermsEnum(Terms terms,
                                 AttributeSource atts)
                          throws IOException
Description copied from class: MultiTermQuery
Construct the enumeration to be used, expanding the pattern term. This method should only be called if the field exists (ie, implementations can assume the field does exist). This method should not return null (should instead return TermsEnum.EMPTY if no terms match). The TermsEnum must already be positioned to the first matching term. The given AttributeSource is passed by the MultiTermQuery.RewriteMethod to provide attributes, the rewrite method uses to inform about e.g. maximum competitive boosts. This is currently only used by TopTermsRewrite

Specified by:
getTermsEnum in class MultiTermQuery
Throws:
IOException

toString

public String toString(String field)
Prints a user-readable version of this query.

Specified by:
toString in class Query

hashCode

public int hashCode()
Overrides:
hashCode in class MultiTermQuery

equals

public boolean equals(Object obj)
Overrides:
equals in class MultiTermQuery


Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.