public class TermAutomatonQuery extends Query
PhraseQuery
, MultiPhraseQuery
and SpanNearQuery
. It is likely
slow, since it visits any document having any of the terms (i.e. it
acts like a disjunction, not a conjunction like PhraseQuery
), 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)
and addAnyTransition(int, int)
to
build up the automaton. Once you are done, call finish()
and
then execute the query.
This code is very new and likely has exciting bugs!
Constructor and Description |
---|
TermAutomatonQuery(String field) |
Modifier and Type | Method and Description |
---|---|
void |
addAnyTransition(int source,
int dest)
Adds a transition matching any term.
|
void |
addTransition(int source,
int dest,
BytesRef term)
Adds a transition to the automaton.
|
void |
addTransition(int source,
int dest,
String term)
Adds a transition to the automaton.
|
int |
createState()
Returns a new state; state 0 is always the initial state.
|
Weight |
createWeight(IndexSearcher searcher) |
boolean |
equals(Object o)
Returns true iff
o is equal to this. |
void |
extractTerms(Set<Term> terms) |
void |
finish()
Call this once you are done adding states/transitions.
|
int |
hashCode()
Returns a hash code value for this object.
|
void |
setAccept(int state,
boolean accept)
Marks the specified state as accept or not.
|
String |
toDot()
Returns the dot (graphviz) representation of this automaton.
|
String |
toString(String field) |
public TermAutomatonQuery(String field)
public int createState()
public void setAccept(int state, boolean accept)
public void addTransition(int source, int dest, String term)
public void addTransition(int source, int dest, BytesRef term)
public void addAnyTransition(int source, int dest)
public void finish()
public Weight createWeight(IndexSearcher searcher) throws IOException
createWeight
in class Query
IOException
public void extractTerms(Set<Term> terms)
extractTerms
in class Query
public boolean equals(Object o)
o
is equal to this.public int hashCode()
public String toDot()
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.