public virtual void TestFieldScoreReverse()
{
Directory dir = NewDirectory();
RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, Similarity, TimeZone);
Document doc = new Document();
doc.Add(NewTextField("value", "foo bar bar bar bar", Field.Store.NO));
writer.AddDocument(doc);
doc = new Document();
doc.Add(NewTextField("value", "foo foo foo foo foo", Field.Store.NO));
writer.AddDocument(doc);
IndexReader ir = writer.Reader;
writer.Dispose();
IndexSearcher searcher = NewSearcher(ir);
Sort sort = new Sort(new SortField(null, SortField.Type_e.SCORE, true));
TopDocs actual = searcher.Search(new TermQuery(new Term("value", "foo")), 10, sort);
Assert.AreEqual(2, actual.TotalHits);
TopDocs expected = searcher.Search(new TermQuery(new Term("value", "foo")), 10);
// the two topdocs should be the reverse of each other
Assert.AreEqual(expected.TotalHits, actual.TotalHits);
Assert.AreEqual(actual.ScoreDocs[0].Doc, expected.ScoreDocs[1].Doc);
Assert.AreEqual(actual.ScoreDocs[1].Doc, expected.ScoreDocs[0].Doc);
ir.Dispose();
dir.Dispose();
}