Package org.apache.lucene.search
Class AutomatonQuery
- java.lang.Object
-
- org.apache.lucene.search.Query
-
- org.apache.lucene.search.MultiTermQuery
-
- org.apache.lucene.search.AutomatonQuery
-
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
RegexpQuery,WildcardQuery
public class AutomatonQuery extends MultiTermQuery
AQuerythat will match terms against a finite-state machine.This query will match documents that contain terms accepted by a given finite-state machine. The automaton can be constructed with the
org.apache.lucene.util.automatonAPI. Alternatively, it can be created from a regular expression withRegexpQueryor from the standard Lucene wildcard syntax withWildcardQuery.When the query is executed, it will create an equivalent DFA of the finite-state machine, and will enumerate the term dictionary in an intelligent way to reduce the number of comparisons. For example: the regular expression of
[dl]og?will make approximately four comparisons: do, dog, lo, and log.
-
-
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 Modifier and Type Field Description protected Automatonautomatonthe automaton to match index terms againstprotected CompiledAutomatoncompiledprotected Termtermterm containing the field, and possibly some pattern structure-
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
Constructors Constructor Description AutomatonQuery(Term term, Automaton automaton)Create a new AutomatonQuery from anAutomaton.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)AutomatongetAutomaton()Returns the automaton used to create this queryprotected TermsEnumgetTermsEnum(Terms terms, AttributeSource atts)Construct the enumeration to be used, expanding the pattern term.inthashCode()StringtoString(String field)Prints a query to a string, withfieldassumed to be the default field and omitted.-
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
-
-
-
-
Field Detail
-
automaton
protected final Automaton automaton
the automaton to match index terms against
-
compiled
protected final CompiledAutomaton compiled
-
term
protected final Term term
term containing the field, and possibly some pattern structure
-
-
Method Detail
-
getTermsEnum
protected TermsEnum getTermsEnum(Terms terms, AttributeSource atts) throws IOException
Description copied from class:MultiTermQueryConstruct 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 returnTermsEnum.EMPTYif no terms match). The TermsEnum must already be positioned to the first matching term. The givenAttributeSourceis passed by theMultiTermQuery.RewriteMethodto provide attributes, the rewrite method uses to inform about e.g. maximum competitive boosts. This is currently only used byTopTermsRewrite- Specified by:
getTermsEnumin classMultiTermQuery- Throws:
IOException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classMultiTermQuery
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classMultiTermQuery
-
toString
public String toString(String field)
Description copied from class:QueryPrints a query to a string, withfieldassumed to be the default field and omitted.
-
getAutomaton
public Automaton getAutomaton()
Returns the automaton used to create this query
-
-