TestBooleanOrpublic class TestBooleanOr extends TestCase Created on 2005. 2. 9.
Adapted to Lucene testcase by Paul Elschot. |
Fields Summary |
---|
private static String | FIELD_T | private static String | FIELD_C | private TermQuery | t1 | private TermQuery | t2 | private TermQuery | c1 | private TermQuery | c2 | private IndexSearcher | searcher |
Methods Summary |
---|
private int | search(org.apache.lucene.search.Query q)
QueryUtils.check(q,searcher);
return searcher.search(q).length();
| protected void | setUp()
super.setUp();
//
RAMDirectory rd = new RAMDirectory();
//
IndexWriter writer = new IndexWriter(rd, new StandardAnalyzer(), true);
//
Document d = new Document();
d.add(new Field(
FIELD_T,
"Optimize not deleting all files",
Field.Store.YES,
Field.Index.TOKENIZED));
d.add(new Field(
FIELD_C,
"Deleted When I run an optimize in our production environment.",
Field.Store.YES,
Field.Index.TOKENIZED));
//
writer.addDocument(d);
writer.close();
//
searcher = new IndexSearcher(rd);
| public void | testElements()
assertEquals(1, search(t1));
assertEquals(1, search(t2));
assertEquals(1, search(c1));
assertEquals(1, search(c2));
| public void | testFlat()T:files T:deleting C:production C:optimize
it works.
BooleanQuery q = new BooleanQuery();
q.add(new BooleanClause(t1, BooleanClause.Occur.SHOULD));
q.add(new BooleanClause(t2, BooleanClause.Occur.SHOULD));
q.add(new BooleanClause(c1, BooleanClause.Occur.SHOULD));
q.add(new BooleanClause(c2, BooleanClause.Occur.SHOULD));
assertEquals(1, search(q));
| public void | testParenthesisMust()(T:files T:deleting) (+C:production +C:optimize)
it works.
BooleanQuery q3 = new BooleanQuery();
q3.add(new BooleanClause(t1, BooleanClause.Occur.SHOULD));
q3.add(new BooleanClause(t2, BooleanClause.Occur.SHOULD));
BooleanQuery q4 = new BooleanQuery();
q4.add(new BooleanClause(c1, BooleanClause.Occur.MUST));
q4.add(new BooleanClause(c2, BooleanClause.Occur.MUST));
BooleanQuery q2 = new BooleanQuery();
q2.add(q3, BooleanClause.Occur.SHOULD);
q2.add(q4, BooleanClause.Occur.SHOULD);
assertEquals(1, search(q2));
| public void | testParenthesisMust2()(T:files T:deleting) +(C:production C:optimize)
not working. results NO HIT.
BooleanQuery q3 = new BooleanQuery();
q3.add(new BooleanClause(t1, BooleanClause.Occur.SHOULD));
q3.add(new BooleanClause(t2, BooleanClause.Occur.SHOULD));
BooleanQuery q4 = new BooleanQuery();
q4.add(new BooleanClause(c1, BooleanClause.Occur.SHOULD));
q4.add(new BooleanClause(c2, BooleanClause.Occur.SHOULD));
BooleanQuery q2 = new BooleanQuery();
q2.add(q3, BooleanClause.Occur.SHOULD);
q2.add(q4, BooleanClause.Occur.MUST);
assertEquals(1, search(q2));
| public void | testParenthesisShould()(T:files T:deleting) (C:production C:optimize)
not working. results NO HIT.
BooleanQuery q3 = new BooleanQuery();
q3.add(new BooleanClause(t1, BooleanClause.Occur.SHOULD));
q3.add(new BooleanClause(t2, BooleanClause.Occur.SHOULD));
BooleanQuery q4 = new BooleanQuery();
q4.add(new BooleanClause(c1, BooleanClause.Occur.SHOULD));
q4.add(new BooleanClause(c2, BooleanClause.Occur.SHOULD));
BooleanQuery q2 = new BooleanQuery();
q2.add(q3, BooleanClause.Occur.SHOULD);
q2.add(q4, BooleanClause.Occur.SHOULD);
assertEquals(1, search(q2));
|
|