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

WildcardQuery

public class WildcardQuery extends MultiTermQuery
Implements the wildcard search query. Supported wildcards are *, which matches any character sequence (including the empty one), and ?, which matches any single character. Note this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow WildcardQueries, a Wildcard term should not start with one of the wildcards * or ?.
see
WildcardTermEnum

Fields Summary
private boolean
termContainsWildcard
Constructors Summary
public WildcardQuery(Term term)

    super(term);
    this.termContainsWildcard = (term.text().indexOf('*") != -1) || (term.text().indexOf('?") != -1);
  
Methods Summary
public booleanequals(java.lang.Object o)

    if (o instanceof WildcardQuery)
      return super.equals(o);

    return false;
  
protected org.apache.lucene.search.FilteredTermEnumgetEnum(org.apache.lucene.index.IndexReader reader)

    return new WildcardTermEnum(reader, getTerm());
  
public org.apache.lucene.search.Queryrewrite(org.apache.lucene.index.IndexReader reader)

      if (this.termContainsWildcard) {
          return super.rewrite(reader);
      }
      
      return new TermQuery(getTerm());