Package org.apache.lucene.search
Class WildcardQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.MultiTermQuery
org.apache.lucene.search.AutomatonQuery
org.apache.lucene.search.WildcardQuery
- All Implemented Interfaces:
Accountable
Implements the wildcard search query. Supported wildcards are
*, which matches any
character sequence (including the empty one), and ?, which matches any single
character. '\' is the escape 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 the wildcard *
This query uses the MultiTermQuery.CONSTANT_SCORE_BLENDED_REWRITE rewrite method.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.lucene.search.MultiTermQuery
MultiTermQuery.RewriteMethod, MultiTermQuery.TopTermsBlendedFreqScoringRewrite, MultiTermQuery.TopTermsBoostOnlyBooleanQueryRewrite, MultiTermQuery.TopTermsScoringBooleanQueryRewrite -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charChar equality with support for wildcardsstatic final charEscape characterstatic final charString equality with support for wildcardsFields inherited from class org.apache.lucene.search.AutomatonQuery
automaton, automatonIsBinary, compiled, termFields inherited from class org.apache.lucene.search.MultiTermQuery
CONSTANT_SCORE_BLENDED_REWRITE, CONSTANT_SCORE_BOOLEAN_REWRITE, CONSTANT_SCORE_REWRITE, DOC_VALUES_REWRITE, field, rewriteMethod, SCORING_BOOLEAN_REWRITEFields inherited from interface org.apache.lucene.util.Accountable
NULL_ACCOUNTABLE -
Constructor Summary
ConstructorsConstructorDescriptionWildcardQuery(Term term) Constructs a query for terms matchingterm.WildcardQuery(Term term, int determinizeWorkLimit) Constructs a query for terms matchingterm.WildcardQuery(Term term, int determinizeWorkLimit, MultiTermQuery.RewriteMethod rewriteMethod) Constructs a query for terms matchingterm. -
Method Summary
Methods inherited from class org.apache.lucene.search.AutomatonQuery
equals, getAutomaton, getCompiled, getTermsEnum, hashCode, isAutomatonBinary, ramBytesUsed, visitMethods inherited from class org.apache.lucene.search.MultiTermQuery
getField, getRewriteMethod, getTermsCount, getTermsEnum, rewriteMethods inherited from class org.apache.lucene.search.Query
classHash, createWeight, sameClassAs, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.lucene.util.Accountable
getChildResources
-
Field Details
-
WILDCARD_STRING
public static final char WILDCARD_STRINGString equality with support for wildcards- See Also:
-
WILDCARD_CHAR
public static final char WILDCARD_CHARChar equality with support for wildcards- See Also:
-
WILDCARD_ESCAPE
public static final char WILDCARD_ESCAPEEscape character- See Also:
-
-
Constructor Details
-
WildcardQuery
Constructs a query for terms matchingterm. -
WildcardQuery
Constructs a query for terms matchingterm.- Parameters:
determinizeWorkLimit- maximum effort to spend while compiling the automaton from this wildcard. Set higher to allow more complex queries and lower to prevent memory exhaustion. UseOperations.DEFAULT_DETERMINIZE_WORK_LIMITas a decent default if you don't otherwise know what to specify.
-
WildcardQuery
public WildcardQuery(Term term, int determinizeWorkLimit, MultiTermQuery.RewriteMethod rewriteMethod) Constructs a query for terms matchingterm.- Parameters:
determinizeWorkLimit- maximum effort to spend while compiling the automaton from this wildcard. Set higher to allow more complex queries and lower to prevent memory exhaustion. UseOperations.DEFAULT_DETERMINIZE_WORK_LIMITas a decent default if you don't otherwise know what to specify.rewriteMethod- the rewrite method to use when building the final query
-
-
Method Details
-
toAutomaton
Convert Lucene wildcard syntax into an automaton.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
getTerm
Returns the pattern term. -
toString
Prints a user-readable version of this query.- Overrides:
toStringin classAutomatonQuery
-