Package org.apache.lucene.search
Class RegexpQuery
java.lang.Object
org.apache.lucene.search.Query
org.apache.lucene.search.MultiTermQuery
org.apache.lucene.search.AutomatonQuery
org.apache.lucene.search.RegexpQuery
- All Implemented Interfaces:
Cloneable
A fast regular expression query based on the
org.apache.lucene.util.automaton
package.
- Comparisons are fast
- The term dictionary is enumerated in an intelligent way, to avoid
comparisons. See
AutomatonQuery
for more details.
The supported syntax is documented in the RegExp
class.
Note this might be different than other regular expression implementations.
For some alternatives with different syntax, look under the sandbox.
Note this query can be slow, as it needs to iterate over many terms. In order
to prevent extremely slow RegexpQueries, a Regexp term should not start with
the expression .*
- See Also:
-
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.AutomatonQuery
automaton, compiled, term
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
ConstructorsConstructorDescriptionRegexpQuery
(Term term) Constructs a query for terms matchingterm
.RegexpQuery
(Term term, int flags) Constructs a query for terms matchingterm
.RegexpQuery
(Term term, int flags, AutomatonProvider provider) Constructs a query for terms matchingterm
. -
Method Summary
Methods inherited from class org.apache.lucene.search.AutomatonQuery
equals, getAutomaton, getTermsEnum, hashCode
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
-
Constructor Details
-
RegexpQuery
Constructs a query for terms matchingterm
.By default, all regular expression features are enabled.
- Parameters:
term
- regular expression.
-
RegexpQuery
Constructs a query for terms matchingterm
.- Parameters:
term
- regular expression.flags
- optional RegExp features fromRegExp
-
RegexpQuery
Constructs a query for terms matchingterm
.- Parameters:
term
- regular expression.flags
- optional RegExp features fromRegExp
provider
- custom AutomatonProvider for named automata
-
-
Method Details
-
toString
Prints a user-readable version of this query.- Overrides:
toString
in classAutomatonQuery
-