public virtual void TestOutOfOrderDocsScoringSort()
{
// Two Sort criteria to instantiate the multi/single comparators.
Sort[] sort = new Sort[] { new Sort(SortField.FIELD_DOC), new Sort() };
bool[][] tfcOptions = new bool[][] { new bool[] { false, false, false }, new bool[] { false, false, true }, new bool[] { false, true, false }, new bool[] { false, true, true }, new bool[] { true, false, false }, new bool[] { true, false, true }, new bool[] { true, true, false }, new bool[] { true, true, true } };
string[] actualTFCClasses = new string[] { "OutOfOrderOneComparatorNonScoringCollector", "OutOfOrderOneComparatorScoringMaxScoreCollector", "OutOfOrderOneComparatorScoringNoMaxScoreCollector", "OutOfOrderOneComparatorScoringMaxScoreCollector", "OutOfOrderOneComparatorNonScoringCollector", "OutOfOrderOneComparatorScoringMaxScoreCollector", "OutOfOrderOneComparatorScoringNoMaxScoreCollector", "OutOfOrderOneComparatorScoringMaxScoreCollector" };
BooleanQuery bq = new BooleanQuery();
// Add a Query with SHOULD, since bw.Scorer() returns BooleanScorer2
// which delegates to BS if there are no mandatory clauses.
bq.Add(new MatchAllDocsQuery(), Occur.SHOULD);
// Set minNrShouldMatch to 1 so that BQ will not optimize rewrite to return
// the clause instead of BQ.
bq.MinimumNumberShouldMatch = 1;
for (int i = 0; i < sort.Length; i++)
{
for (int j = 0; j < tfcOptions.Length; j++)
{
TopDocsCollector<Entry> tdc = TopFieldCollector.Create(sort[i], 10, tfcOptions[j][0], tfcOptions[j][1], tfcOptions[j][2], false);
Assert.IsTrue(tdc.GetType().Name.EndsWith(actualTFCClasses[j]));
@is.Search(bq, tdc);
TopDocs td = tdc.TopDocs();
ScoreDoc[] sd = td.ScoreDocs;
Assert.AreEqual(10, sd.Length);
}
}
}