lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject lucene-solr:master: SOLR-11164, SOLR-11180, SOLR-11220: Fix NullPointerException and always-returns-zero contrib/ltr OriginalScoreFeature issues in SolrCloud mode. (Yuki Yano, Jonathan Gonzalez, Ryan Yacyshyn, Christine Poerschke)
Date Fri, 25 Aug 2017 14:35:05 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master 554f0d5f2 -> 492265014


SOLR-11164, SOLR-11180, SOLR-11220: Fix NullPointerException and always-returns-zero contrib/ltr
OriginalScoreFeature issues in SolrCloud mode.
(Yuki Yano, Jonathan Gonzalez, Ryan Yacyshyn, Christine Poerschke)


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/49226501
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/49226501
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/49226501

Branch: refs/heads/master
Commit: 492265014b549d5517e5ec25ffdd0e5557a4ed39
Parents: 554f0d5
Author: Christine Poerschke <cpoerschke@apache.org>
Authored: Fri Aug 25 14:26:13 2017 +0100
Committer: Christine Poerschke <cpoerschke@apache.org>
Committed: Fri Aug 25 15:34:04 2017 +0100

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  4 +++
 .../LTRFeatureLoggerTransformerFactory.java     |  8 ++---
 .../org/apache/solr/ltr/TestLTROnSolrCloud.java | 31 ++++++++++++--------
 .../solr/ltr/feature/TestExternalFeatures.java  |  8 ++---
 4 files changed, 31 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/49226501/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 6e69622..609356e 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -105,6 +105,10 @@ Bug Fixes
 
 * SOLR-11289: fix comma handling in terms component. (yonik)
 
+* SOLR-11164, SOLR-11180, SOLR-11220: Fix NullPointerException and always-returns-zero
+  contrib/ltr OriginalScoreFeature issues in SolrCloud mode.
+  (Yuki Yano, Jonathan Gonzalez, Ryan Yacyshyn, Christine Poerschke)
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/49226501/solr/contrib/ltr/src/java/org/apache/solr/ltr/response/transform/LTRFeatureLoggerTransformerFactory.java
----------------------------------------------------------------------
diff --git a/solr/contrib/ltr/src/java/org/apache/solr/ltr/response/transform/LTRFeatureLoggerTransformerFactory.java
b/solr/contrib/ltr/src/java/org/apache/solr/ltr/response/transform/LTRFeatureLoggerTransformerFactory.java
index 42d519a..f625d63 100644
--- a/solr/contrib/ltr/src/java/org/apache/solr/ltr/response/transform/LTRFeatureLoggerTransformerFactory.java
+++ b/solr/contrib/ltr/src/java/org/apache/solr/ltr/response/transform/LTRFeatureLoggerTransformerFactory.java
@@ -225,15 +225,15 @@ public class LTRFeatureLoggerTransformerFactory extends TransformerFactory
{
               true,
               threadManager); // request feature weights to be created for all features
 
-          // Local transformer efi if provided
-          scoringQuery.setOriginalQuery(context.getQuery());
-
         }catch (final Exception e) {
           throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
               "retrieving the feature store "+featureStoreName, e);
         }
       }
 
+      if (scoringQuery.getOriginalQuery() == null) {
+        scoringQuery.setOriginalQuery(context.getQuery());
+      }
       if (scoringQuery.getFeatureLogger() == null){
         scoringQuery.setFeatureLogger( SolrQueryRequestContextUtils.getFeatureLogger(req)
);
       }
@@ -261,7 +261,7 @@ public class LTRFeatureLoggerTransformerFactory extends TransformerFactory
{
     @Override
     public void transform(SolrDocument doc, int docid)
         throws IOException {
-      implTransform(doc, docid, 0.0f);
+      implTransform(doc, docid, null);
     }
 
     private void implTransform(SolrDocument doc, int docid, Float score)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/49226501/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestLTROnSolrCloud.java
----------------------------------------------------------------------
diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestLTROnSolrCloud.java b/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestLTROnSolrCloud.java
index f6cab58..d0042c8 100644
--- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestLTROnSolrCloud.java
+++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/TestLTROnSolrCloud.java
@@ -29,6 +29,7 @@ import org.apache.solr.cloud.AbstractDistribZkTestBase;
 import org.apache.solr.cloud.MiniSolrCloudCluster;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.ltr.feature.OriginalScoreFeature;
 import org.apache.solr.ltr.feature.SolrFeature;
 import org.apache.solr.ltr.feature.ValueFeature;
 import org.apache.solr.ltr.model.LinearModel;
@@ -53,9 +54,9 @@ public class TestLTROnSolrCloud extends TestRerankBase {
 
     int numberOfShards = random().nextInt(4)+1;
     int numberOfReplicas = random().nextInt(2)+1;
-    int maxShardsPerNode = numberOfShards+random().nextInt(4)+1;
+    int maxShardsPerNode = random().nextInt(4)+1;
 
-    int numberOfNodes = numberOfShards * maxShardsPerNode;
+    int numberOfNodes = (numberOfShards*numberOfReplicas + (maxShardsPerNode-1))/maxShardsPerNode;
 
     setupSolrCluster(numberOfShards, numberOfReplicas, numberOfNodes, maxShardsPerNode);
 
@@ -106,21 +107,21 @@ public class TestLTROnSolrCloud extends TestRerankBase {
     final Float original_result7_score = (Float)queryResponse.getResults().get(7).get("score");
 
     final String result0_features= FeatureLoggerTestUtils.toFeatureVector(
-        "powpularityS","64.0", "c3","2.0");
+        "powpularityS","64.0", "c3","2.0", "original","0.0");
     final String result1_features= FeatureLoggerTestUtils.toFeatureVector(
-        "powpularityS","49.0", "c3","2.0");
+        "powpularityS","49.0", "c3","2.0", "original","1.0");
     final String result2_features= FeatureLoggerTestUtils.toFeatureVector(
-        "powpularityS","36.0", "c3","2.0");
+        "powpularityS","36.0", "c3","2.0", "original","2.0");
     final String result3_features= FeatureLoggerTestUtils.toFeatureVector(
-        "powpularityS","25.0", "c3","2.0");
+        "powpularityS","25.0", "c3","2.0", "original","3.0");
     final String result4_features= FeatureLoggerTestUtils.toFeatureVector(
-        "powpularityS","16.0", "c3","2.0");
+        "powpularityS","16.0", "c3","2.0", "original","4.0");
     final String result5_features= FeatureLoggerTestUtils.toFeatureVector(
-        "powpularityS", "9.0", "c3","2.0");
+        "powpularityS", "9.0", "c3","2.0", "original","5.0");
     final String result6_features= FeatureLoggerTestUtils.toFeatureVector(
-        "powpularityS", "4.0", "c3","2.0");
+        "powpularityS", "4.0", "c3","2.0", "original","6.0");
     final String result7_features= FeatureLoggerTestUtils.toFeatureVector(
-        "powpularityS", "1.0", "c3","2.0");
+        "powpularityS", "1.0", "c3","2.0", "original","7.0");
 
 
     // Test feature vectors returned (without re-ranking)
@@ -256,8 +257,8 @@ public class TestLTROnSolrCloud extends TestRerankBase {
 
   private void loadModelsAndFeatures() throws Exception {
     final String featureStore = "test";
-    final String[] featureNames = new String[] {"powpularityS","c3"};
-    final String jsonModelParams = "{\"weights\":{\"powpularityS\":1.0,\"c3\":1.0}}";
+    final String[] featureNames = new String[] {"powpularityS","c3", "original"};
+    final String jsonModelParams = "{\"weights\":{\"powpularityS\":1.0,\"c3\":1.0,\"original\":0.1}}";
 
     loadFeature(
             featureNames[0],
@@ -271,6 +272,12 @@ public class TestLTROnSolrCloud extends TestRerankBase {
             featureStore,
             "{\"value\":2}"
     );
+    loadFeature(
+            featureNames[2],
+            OriginalScoreFeature.class.getCanonicalName(),
+            featureStore,
+            null
+    );
 
     loadModel(
              "powpularityS-model",

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/49226501/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestExternalFeatures.java
----------------------------------------------------------------------
diff --git a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestExternalFeatures.java
b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestExternalFeatures.java
index c6ae30f..45e856a 100644
--- a/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestExternalFeatures.java
+++ b/solr/contrib/ltr/src/test/org/apache/solr/ltr/feature/TestExternalFeatures.java
@@ -139,9 +139,9 @@ public class TestExternalFeatures extends TestRerankBase {
 
     final String docs0fvalias_dense_csv = FeatureLoggerTestUtils.toFeatureVector(
         "occurrences","0.0",
-        "originalScore","0.0");
+        "originalScore","1.0");
     final String docs0fvalias_sparse_csv = FeatureLoggerTestUtils.toFeatureVector(
-        "originalScore","0.0");
+        "originalScore","1.0");
 
     final String docs0fvalias_default_csv = chooseDefaultFeatureVector(docs0fvalias_dense_csv,
docs0fvalias_sparse_csv);
 
@@ -159,9 +159,9 @@ public class TestExternalFeatures extends TestRerankBase {
 
     final String docs0fvalias_dense_csv = FeatureLoggerTestUtils.toFeatureVector(
         "occurrences","0.0",
-        "originalScore","0.0");
+        "originalScore","1.0");
     final String docs0fvalias_sparse_csv = FeatureLoggerTestUtils.toFeatureVector(
-        "originalScore","0.0");
+        "originalScore","1.0");
 
     final String docs0fvalias_default_csv = chooseDefaultFeatureVector(docs0fvalias_dense_csv,
docs0fvalias_sparse_csv);
 


Mime
View raw message