mirror of https://github.com/apache/lucene.git
expected, then actual :) also, uncovered a bug in FilteredQuery, a rewrite is needed somewhere
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150316 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d9cd661cde
commit
8271ebd473
|
@ -95,24 +95,36 @@ extends TestCase {
|
||||||
throws Exception {
|
throws Exception {
|
||||||
Query filteredquery = new FilteredQuery (query, filter);
|
Query filteredquery = new FilteredQuery (query, filter);
|
||||||
Hits hits = searcher.search (filteredquery);
|
Hits hits = searcher.search (filteredquery);
|
||||||
assertEquals (hits.length(), 1);
|
assertEquals (1, hits.length());
|
||||||
assertEquals (hits.id(0), 1);
|
assertEquals (1, hits.id(0));
|
||||||
|
|
||||||
hits = searcher.search (filteredquery, new Sort("sorter"));
|
hits = searcher.search (filteredquery, new Sort("sorter"));
|
||||||
assertEquals (hits.length(), 1);
|
assertEquals (1, hits.length());
|
||||||
assertEquals (hits.id(0), 1);
|
assertEquals (1, hits.id(0));
|
||||||
|
|
||||||
filteredquery = new FilteredQuery (new TermQuery (new Term ("field", "one")), filter);
|
filteredquery = new FilteredQuery (new TermQuery (new Term ("field", "one")), filter);
|
||||||
hits = searcher.search (filteredquery);
|
hits = searcher.search (filteredquery);
|
||||||
assertEquals (hits.length(), 2);
|
assertEquals (2, hits.length());
|
||||||
|
|
||||||
filteredquery = new FilteredQuery (new TermQuery (new Term ("field", "x")), filter);
|
filteredquery = new FilteredQuery (new TermQuery (new Term ("field", "x")), filter);
|
||||||
hits = searcher.search (filteredquery);
|
hits = searcher.search (filteredquery);
|
||||||
assertEquals (hits.length(), 1);
|
assertEquals (1, hits.length());
|
||||||
assertEquals (hits.id(0), 3);
|
assertEquals (3, hits.id(0));
|
||||||
|
|
||||||
filteredquery = new FilteredQuery (new TermQuery (new Term ("field", "y")), filter);
|
filteredquery = new FilteredQuery (new TermQuery (new Term ("field", "y")), filter);
|
||||||
hits = searcher.search (filteredquery);
|
hits = searcher.search (filteredquery);
|
||||||
assertEquals (hits.length(), 0);
|
assertEquals (0, hits.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testRangeQuery() throws Exception {
|
||||||
|
RangeQuery rq = new RangeQuery(
|
||||||
|
new Term("sorter", "b"), new Term("sorter", "d"), true);
|
||||||
|
|
||||||
|
// rq = rq.rewrite(searcher.reader) // makes the test pass
|
||||||
|
|
||||||
|
Query filteredquery = new FilteredQuery(rq, filter);
|
||||||
|
Hits hits = searcher.search(filteredquery);
|
||||||
|
assertEquals(2, hits.length());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue