Fix FilteredQuery to support rewritten queries.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150327 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doug Cutting 2004-05-11 17:52:24 +00:00
parent 9ed56d3d04
commit 6809069823
1 changed files with 13 additions and 1 deletions

View File

@ -100,6 +100,18 @@ extends Query {
};
}
/** Rewrites the wrapped query. */
public Query rewrite(IndexReader reader) throws IOException {
Query rewritten = query.rewrite(reader);
if (rewritten != query) {
FilteredQuery clone = (FilteredQuery)this.clone();
clone.query = rewritten;
return clone;
} else {
return this;
}
}
/** Prints a user-readable version of this query. */
public String toString (String s) {
return "filtered("+query.toString(s)+")->"+filter;
@ -118,4 +130,4 @@ extends Query {
public int hashCode() {
return query.hashCode() ^ filter.hashCode();
}
}
}