## org.apache.lucene.search
Class PrefixQuery

    java.lang.Object
      org.apache.lucene.search.Query
          org.apache.lucene.search.MultiTermQuery
              org.apache.lucene.search.PrefixQuery

All Implemented Interfaces:
  java.io.Serializable, java.lang.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.

See Also:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.lucene.search.MultiTermQuery
`MultiTermQuery.ConstantScoreAutoRewrite, MultiTermQuery.RewriteMethod`

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, rewriteMethod, SCORING_BOOLEAN_QUERY_REWRITE, term`

Constructor Summary
`PrefixQuery(Term prefix)` Constructs a query for terms starting with `prefix`.

Method Summary
`boolean` `equals(java.lang.Object obj)`
`protected FilteredTermEnum` `getEnum(IndexReader reader)` Construct the enumeration to be used, expanding the pattern term.
`Term` `getPrefix()` Returns the prefix of this query.
`int` `hashCode()`
`java.lang.String` `toString(java.lang.String field)` Prints a user-readable version of this query.

Methods inherited from class org.apache.lucene.search.MultiTermQuery
`clearTotalNumberOfTerms, getRewriteMethod, getTerm, getTotalNumberOfTerms, incTotalNumberOfTerms, rewrite, setRewriteMethod`

Methods inherited from class org.apache.lucene.search.Query
`clone, combine, createWeight, extractTerms, getBoost, getSimilarity, mergeBooleanQueries, setBoost, toString, weight`

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.

### getEnum

    protected FilteredTermEnum getEnum(IndexReader reader)
                                throws java.io.IOException

  Description copied from class: `MultiTermQuery`
  Construct the enumeration to be used, expanding the pattern term.

  Specified by:
    `getEnum` in class `MultiTermQuery`
  Throws:
    `java.io.IOException`

### toString

    public java.lang.String toString(java.lang.String field)

  Prints a user-readable version of this query.

  Overrides:
    `toString` in class `MultiTermQuery`

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `MultiTermQuery`

### equals

    public boolean equals(java.lang.Object obj)

  Overrides:
    `equals` in class `MultiTermQuery`

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