public virtual void TestRandomQueries()
{
const string field = "data";
string[] vals = new string[] { "1", "2", "3", "4", "5", "6", "A", "Z", "B", "Y", "Z", "X", "foo" };
int maxLev = 4;
// callback object to set a random setMinimumNumberShouldMatch
TestBoolean2.Callback minNrCB = new CallbackAnonymousInnerClassHelper(this, field, vals);
// increase number of iterations for more complete testing
int num = AtLeast(20);
for (int i = 0; i < num; i++)
{
int lev = Random().Next(maxLev);
int seed = Random().Next();
BooleanQuery q1 = TestBoolean2.RandBoolQuery(new Random(seed), true, lev, field, vals, null);
// BooleanQuery q2 = TestBoolean2.randBoolQuery(new Random(seed), lev, field, vals, minNrCB);
BooleanQuery q2 = TestBoolean2.RandBoolQuery(new Random(seed), true, lev, field, vals, null);
// only set minimumNumberShouldMatch on the top level query since setting
// at a lower level can change the score.
minNrCB.PostCreate(q2);
// Can't use Hits because normalized scores will mess things
// up. The non-sorting version of search() that returns TopDocs
// will not normalize scores.
TopDocs top1 = s.Search(q1, null, 100);
TopDocs top2 = s.Search(q2, null, 100);
if (i < 100)
{
QueryUtils.Check(Random(), q1, s, Similarity);
QueryUtils.Check(Random(), q2, s, Similarity);
}
AssertSubsetOfSameScores(q2, top1, top2);
}
// System.out.println("Total hits:"+tot);
}