mirror of https://github.com/apache/lucene.git
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:
parent
9ed56d3d04
commit
6809069823
|
@ -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. */
|
/** Prints a user-readable version of this query. */
|
||||||
public String toString (String s) {
|
public String toString (String s) {
|
||||||
return "filtered("+query.toString(s)+")->"+filter;
|
return "filtered("+query.toString(s)+")->"+filter;
|
||||||
|
@ -118,4 +130,4 @@ extends Query {
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return query.hashCode() ^ filter.hashCode();
|
return query.hashCode() ^ filter.hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue