mirror of https://github.com/apache/lucene.git
LUCENE-6314: BooleanQuery toString() is wrong for FILTER clauses
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1663102 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f64e74c0c7
commit
b985737d1f
|
@ -261,11 +261,7 @@ public class BooleanQuery extends Query implements Iterable<BooleanClause> {
|
||||||
|
|
||||||
for (int i = 0 ; i < clauses.size(); i++) {
|
for (int i = 0 ; i < clauses.size(); i++) {
|
||||||
BooleanClause c = clauses.get(i);
|
BooleanClause c = clauses.get(i);
|
||||||
if (c.isProhibited()) {
|
buffer.append(c.getOccur().toString());
|
||||||
buffer.append("-");
|
|
||||||
} else if (c.isRequired()) {
|
|
||||||
buffer.append("+");
|
|
||||||
}
|
|
||||||
|
|
||||||
Query subQuery = c.getQuery();
|
Query subQuery = c.getQuery();
|
||||||
if (subQuery != null) {
|
if (subQuery != null) {
|
||||||
|
|
|
@ -741,4 +741,13 @@ public class TestBooleanQuery extends LuceneTestCase {
|
||||||
w.close();
|
w.close();
|
||||||
dir.close();
|
dir.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testToString() {
|
||||||
|
BooleanQuery bq = new BooleanQuery();
|
||||||
|
bq.add(new TermQuery(new Term("field", "a")), Occur.SHOULD);
|
||||||
|
bq.add(new TermQuery(new Term("field", "b")), Occur.MUST);
|
||||||
|
bq.add(new TermQuery(new Term("field", "c")), Occur.MUST_NOT);
|
||||||
|
bq.add(new TermQuery(new Term("field", "d")), Occur.FILTER);
|
||||||
|
assertEquals("a +b -c #d", bq.toString("field"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue