Package org.apache.lucene.search
Class TermAutomatonQuery
- java.lang.Object
- 
- org.apache.lucene.search.Query
- 
- org.apache.lucene.search.TermAutomatonQuery
 
 
- 
- All Implemented Interfaces:
- Accountable
 
 public class TermAutomatonQuery extends Query implements Accountable A proximity query that lets you express an automaton, whose transitions are terms, to match documents. This is a generalization of other proximity queries likePhraseQuery,MultiPhraseQueryandSpanNearQuery. It is likely slow, since it visits any document having any of the terms (i.e. it acts like a disjunction, not a conjunction likePhraseQuery), and then it must merge-sort all positions within each document to test whether/how many times the automaton matches.After creating the query, use createState(),setAccept(int, boolean),addTransition(int, int, java.lang.String)andaddAnyTransition(int, int)to build up the automaton. Once you are done, callfinish()and then execute the query.This code is very new and likely has exciting bugs! - WARNING: This API is experimental and might change in incompatible ways in the next release.
 
- 
- 
Constructor SummaryConstructors Constructor Description TermAutomatonQuery(String field)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnyTransition(int source, int dest)Adds a transition matching any term.voidaddTransition(int source, int dest, String term)Adds a transition to the automaton.voidaddTransition(int source, int dest, BytesRef term)Adds a transition to the automaton.intcreateState()Returns a new state; state 0 is always the initial state.WeightcreateWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost)booleanequals(Object other)Returns true iffois equal to this.voidfinish()Call this once you are done adding states/transitions.voidfinish(int maxDeterminizedStates)Call this once you are done adding states/transitions.inthashCode()longramBytesUsed()Queryrewrite(IndexReader reader)voidsetAccept(int state, boolean accept)Marks the specified state as accept or not.StringtoDot()Returns the dot (graphviz) representation of this automaton.StringtoString(String field)voidvisit(QueryVisitor visitor)- 
Methods inherited from class org.apache.lucene.search.QueryclassHash, sameClassAs, toString
 - 
Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface org.apache.lucene.util.AccountablegetChildResources
 
- 
 
- 
- 
- 
Constructor Detail- 
TermAutomatonQuerypublic TermAutomatonQuery(String field) 
 
- 
 - 
Method Detail- 
createStatepublic int createState() Returns a new state; state 0 is always the initial state.
 - 
setAcceptpublic void setAccept(int state, boolean accept)Marks the specified state as accept or not.
 - 
addTransitionpublic void addTransition(int source, int dest, String term)Adds a transition to the automaton.
 - 
addTransitionpublic void addTransition(int source, int dest, BytesRef term)Adds a transition to the automaton.
 - 
addAnyTransitionpublic void addAnyTransition(int source, int dest)Adds a transition matching any term.
 - 
finishpublic void finish() Call this once you are done adding states/transitions.
 - 
finishpublic void finish(int maxDeterminizedStates) Call this once you are done adding states/transitions.- Parameters:
- maxDeterminizedStates- Maximum number of states created when determinizing the automaton. Higher numbers allow this operation to consume more memory but allow more complex automatons.
 
 - 
createWeightpublic Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float boost) throws IOException - Overrides:
- createWeightin class- Query
- Throws:
- IOException
 
 - 
equalspublic boolean equals(Object other) Returns true iffois equal to this.
 - 
ramBytesUsedpublic long ramBytesUsed() - Specified by:
- ramBytesUsedin interface- Accountable
 
 - 
toDotpublic String toDot() Returns the dot (graphviz) representation of this automaton. This is extremely useful for visualizing the automaton.
 - 
rewritepublic Query rewrite(IndexReader reader) throws IOException - Overrides:
- rewritein class- Query
- Throws:
- IOException
 
 - 
visitpublic void visit(QueryVisitor visitor) 
 
- 
 
-