It looks as though the Explaination object doesn't provide a way to get to the field, which is somewhat annoying. I came across someone doing something similar in the lucene mailing list which may be worth looking at:
Code:
query = query.rewrite(this.getReader());
QueryScorer scorer = new QueryScorer(query);
String found = null;
float maxScore = 0;
for(Field f: (List<Field>) doc.getFields()) {
String text = f.stringValue();
scorer.startFragment(new TextFragment(new StringBuffer(text),0,text.length()));
TokenStream tok = analyzer
.tokenStream(f.name(),new StringReader(text));
System.out.println("Field: " + f + ":: " +f.name() + ": " + f.stringValue());
Token t=new Token();
while(tok!=null && (t=tok.next(t))!=null) {
float s = scorer.getTokenScore(t);
}
float score = scorer.getFragmentScore();
if(score > maxScore) {
maxScore = score;
found = text;
}
}
I haven't tried this but I can give it a go and see if it works.
Not sure if I've helped much...I'll search my lucene mail to find more of a concrete example.
Cheers