public virtual void TestEqualScores()
{
// NOTE: uses index build in *this* setUp
IndexSearcher search = NewSearcher(Reader);
ScoreDoc[] result;
// some hits match more terms then others, score should be the same
result = search.Search(Csrq("data", "1", "6", T, T), null, 1000).ScoreDocs;
int numHits = result.Length;
AssertEquals("wrong number of results", 6, numHits);
float score = result[0].Score;
for (int i = 1; i < numHits; i++)
{
Assert.AreEqual(score, result[i].Score, SCORE_COMP_THRESH, "score for " + i + " was not the same");
}
result = search.Search(Csrq("data", "1", "6", T, T, MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE), null, 1000).ScoreDocs;
numHits = result.Length;
AssertEquals("wrong number of results", 6, numHits);
for (int i = 0; i < numHits; i++)
{
Assert.AreEqual(score, result[i].Score, SCORE_COMP_THRESH, "score for " + i + " was not the same");
}
result = search.Search(Csrq("data", "1", "6", T, T, MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT), null, 1000).ScoreDocs;
numHits = result.Length;
AssertEquals("wrong number of results", 6, numHits);
for (int i = 0; i < numHits; i++)
{
Assert.AreEqual(score, result[i].Score, SCORE_COMP_THRESH, "score for " + i + " was not the same");
}
}