Fixed a NPE in Query.explain().

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150155 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Doug Cutting 2003-12-15 22:26:13 +00:00
parent 859e6eee20
commit 321b292be9
3 changed files with 12 additions and 3 deletions

View File

@ -212,7 +212,10 @@ public class PhrasePrefixQuery extends Query {
fieldExpl.addDetail(idfExpl);
Explanation fieldNormExpl = new Explanation();
fieldNormExpl.setValue(Similarity.decodeNorm(reader.norms(field)[doc]));
byte[] fieldNorms = reader.norms(field);
float fieldNorm =
fieldNorms!=null ? Similarity.decodeNorm(fieldNorms[doc]) : 0.0f;
fieldNormExpl.setValue(fieldNorm);
fieldNormExpl.setDescription("fieldNorm(field="+field+", doc="+doc+")");
fieldExpl.addDetail(fieldNormExpl);

View File

@ -210,7 +210,10 @@ public class PhraseQuery extends Query {
fieldExpl.addDetail(idfExpl);
Explanation fieldNormExpl = new Explanation();
fieldNormExpl.setValue(Similarity.decodeNorm(reader.norms(field)[doc]));
byte[] fieldNorms = reader.norms(field);
float fieldNorm =
fieldNorms!=null ? Similarity.decodeNorm(fieldNorms[doc]) : 0.0f;
fieldNormExpl.setValue(fieldNorm);
fieldNormExpl.setDescription("fieldNorm(field="+field+", doc="+doc+")");
fieldExpl.addDetail(fieldNormExpl);

View File

@ -139,7 +139,10 @@ public class TermQuery extends Query {
fieldExpl.addDetail(idfExpl);
Explanation fieldNormExpl = new Explanation();
fieldNormExpl.setValue(Similarity.decodeNorm(reader.norms(field)[doc]));
byte[] fieldNorms = reader.norms(field);
float fieldNorm =
fieldNorms!=null ? Similarity.decodeNorm(fieldNorms[doc]) : 0.0f;
fieldNormExpl.setValue(fieldNorm);
fieldNormExpl.setDescription("fieldNorm(field="+field+", doc="+doc+")");
fieldExpl.addDetail(fieldNormExpl);