FunctionQuery functionQuery = new FunctionQuery(valueSource);
IndexReader r = DirectoryReader.open(dir);
IndexSearcher s = new IndexSearcher(r);
TopDocs td = s.search(functionQuery,null,1000);
assertEquals("All docs should be matched!",N_DOCS,td.totalHits);
ScoreDoc sd[] = td.scoreDocs;
for (ScoreDoc aSd : sd) {
float score = aSd.score;
log(s.explain(functionQuery, aSd.doc));
String id = s.getIndexReader().document(aSd.doc).get(ID_FIELD);
float expectedScore = expectedFieldScore(id); // "ID7" --> 7.0