SOLR-10383: Fix debug related NullPointerException in solr/contrib/ltr OriginalScoreFeature class.

(Vitezslav Zak, Christine Poerschke)
This commit is contained in:
Christine Poerschke 2017-04-03 13:01:16 +01:00 committed by Shalin Shekhar Mangar
parent cbe610035b
commit 9868907fe7
3 changed files with 18 additions and 3 deletions

View File

@ -196,6 +196,14 @@ Other Changes
* SOLR-9601: Redone DataImportHandler 'tika' example, removing all unused and irrelevant definitions (Alexandre Rafalovitch) * SOLR-9601: Redone DataImportHandler 'tika' example, removing all unused and irrelevant definitions (Alexandre Rafalovitch)
================== 6.5.1 ==================
Bug Fixes
----------------------
* SOLR-10383: Fix debug related NullPointerException in solr/contrib/ltr OriginalScoreFeature class.
(Vitezslav Zak, Christine Poerschke)
================== 6.5.0 ================== ================== 6.5.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -104,7 +104,7 @@ public class OriginalScoreFeature extends Feature {
// was already scored in step 1 // was already scored in step 1
// we shouldn't need to calc original score again. // we shouldn't need to calc original score again.
final DocInfo docInfo = getDocInfo(); final DocInfo docInfo = getDocInfo();
return (docInfo.hasOriginalDocScore() ? docInfo.getOriginalDocScore() : originalScorer.score()); return (docInfo != null && docInfo.hasOriginalDocScore() ? docInfo.getOriginalDocScore() : originalScorer.score());
} }
@Override @Override

View File

@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.Map; import java.util.Map;
import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.ltr.FeatureLoggerTestUtils; import org.apache.solr.ltr.FeatureLoggerTestUtils;
import org.apache.solr.ltr.TestRerankBase; import org.apache.solr.ltr.TestRerankBase;
import org.apache.solr.ltr.model.LinearModel; import org.apache.solr.ltr.model.LinearModel;
@ -106,7 +107,10 @@ public class TestOriginalScoreFeature extends TestRerankBase {
final String doc3Score = ((Double) ((Map<String,Object>) ((ArrayList<Object>) ((Map<String,Object>) jsonParse final String doc3Score = ((Double) ((Map<String,Object>) ((ArrayList<Object>) ((Map<String,Object>) jsonParse
.get("response")).get("docs")).get(3)).get("score")).toString(); .get("response")).get("docs")).get(3)).get("score")).toString();
final boolean debugQuery = false; final boolean debugQuery = random().nextBoolean();
if (debugQuery) {
query.add(CommonParams.DEBUG_QUERY, "true");
}
query.remove("fl"); query.remove("fl");
query.add("fl", "*, score, fv:[fv]"); query.add("fl", "*, score, fv:[fv]");
@ -142,7 +146,10 @@ public class TestOriginalScoreFeature extends TestRerankBase {
} }
assertJQ("/query" + query.toQueryString(), "/response/docs/["+docIdx+"]/fv=='"+fv+"'"); assertJQ("/query" + query.toQueryString(), "/response/docs/["+docIdx+"]/fv=='"+fv+"'");
// TODO: use debugQuery if (debugQuery) {
assertJQ("/query" + query.toQueryString(),
"/debug/explain/"+docId+"=='\n"+origScoreFeatureValue+" = LinearModel(name="+modelName+",featureWeights=["+origScoreFeatureName+"=1.0]) model applied to features, sum of:\n "+origScoreFeatureValue+" = prod of:\n 1.0 = weight on feature\n "+origScoreFeatureValue+" = OriginalScoreFeature [query:"+query.getQuery()+"]\n'");
}
} }
} }