int count;
// 1.
bquery = new BooleanQuery();
bquery.add(new TermQuery(new Term("f1","aa")), BooleanClause.Occur.MUST);
bquery.add(new IntMetaDataQuery(intMetaTerm, new IntMetaDataQuery.SimpleValueValidator(100)), BooleanClause.Occur.MUST);
squery = new SectionSearchQuery(bquery);
scorer = squery.weight(searcher).scorer(reader, true, true);
count = 0;
while(scorer.nextDoc() != Scorer.NO_MORE_DOCS) count++;
assertEquals("section count mismatch", 1, count);
// 2.
bquery = new BooleanQuery();
bquery.add(new TermQuery(new Term("f1","aa")), BooleanClause.Occur.MUST);
bquery.add(new IntMetaDataQuery(intMetaTerm, new IntMetaDataQuery.SimpleValueValidator(200)), BooleanClause.Occur.MUST);
squery = new SectionSearchQuery(bquery);
scorer = squery.weight(searcher).scorer(reader, true, true);
count = 0;
while(scorer.nextDoc() != Scorer.NO_MORE_DOCS) count++;
assertEquals("section count mismatch", 1, count);
// 3.
bquery = new BooleanQuery();
bquery.add(new TermQuery(new Term("f1","bb")), BooleanClause.Occur.MUST);
bquery.add(new IntMetaDataQuery(intMetaTerm, new IntMetaDataQuery.SimpleValueValidator(200)), BooleanClause.Occur.MUST);
squery = new SectionSearchQuery(bquery);
scorer = squery.weight(searcher).scorer(reader, true, true);
count = 0;
while(scorer.nextDoc() != Scorer.NO_MORE_DOCS) count++;
assertEquals("section count mismatch", 2, count);
// 4.
bquery = new BooleanQuery();
bquery.add(new TermQuery(new Term("f1","aa")), BooleanClause.Occur.MUST);
bquery.add(new IntMetaDataQuery(intMetaTerm, new IntMetaDataQuery.SimpleValueValidator(300)), BooleanClause.Occur.MUST);
squery = new SectionSearchQuery(bquery);
scorer = squery.weight(searcher).scorer(reader, true, true);
count = 0;
while(scorer.nextDoc() != Scorer.NO_MORE_DOCS) count++;
assertEquals("section count mismatch", 1, count);
// 5.
bquery = new BooleanQuery();
bquery.add(new TermQuery(new Term("f1","bb")), BooleanClause.Occur.MUST);
bquery.add(new IntMetaDataQuery(intMetaTerm, new IntMetaDataQuery.SimpleValueValidator(300)), BooleanClause.Occur.MUST);
squery = new SectionSearchQuery(bquery);
scorer = squery.weight(searcher).scorer(reader, true, true);
count = 0;
while(scorer.nextDoc() != Scorer.NO_MORE_DOCS) count++;
assertEquals("section count mismatch", 3, count);