public abstract class SimpleQueryRewriter
extends Object
Traverses and rewrites simple Lucene queries. This includes boolean
and phrase queries, but not much else. Very useful for extracting and/or
changing the terms in a query. Usually you derive a class and then
override rewrite(Term)
to do what you need.
If you need to handle other types of queries, derive a class and
provide a rewriteQuery(Query)
method that dispatches to your
custom rewriting methods.
Constructor and Description |
---|
SimpleQueryRewriter() |
Modifier and Type | Method and Description |
---|---|
protected Query |
rewrite(BooleanQuery bq)
Rewrite a BooleanQuery.
|
protected Query |
rewrite(PhraseQuery pq)
Rewrite a phrase query.
|
protected Term |
rewrite(Term t)
Rewrite a term (e.g. part of a TermQuery or PhraseQuery).
|
protected Query |
rewrite(TermQuery q)
Rewrite a term query.
|
Query |
rewriteQuery(Query q)
Rewrite a query of any supported type.
|
public Query rewriteQuery(Query q)
q
- Query to rewriteprotected Query rewrite(BooleanQuery bq)
bq
- The query to rewriteprotected Query rewrite(PhraseQuery pq)
pq
- The query to rewriteprotected Query rewrite(TermQuery q)
q
- The query to rewriteprotected Term rewrite(Term t)
t
- The term to rewrite