lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject [06/10] lucene-solr:apiv2: SOLR-9114: NPE using TermVectorComponent, MoreLikeThisComponent in combination with ExactStatsCache
Date Tue, 24 Jan 2017 08:58:11 GMT
SOLR-9114: NPE using TermVectorComponent, MoreLikeThisComponent in combination with ExactStatsCache


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

Branch: refs/heads/apiv2
Commit: d34f549df6cee0db7cbff1ec2639262c2f7e21e2
Parents: 6693c26
Author: Cao Manh Dat <datcm@apache.org>
Authored: Mon Jan 23 17:41:35 2017 +0700
Committer: Cao Manh Dat <datcm@apache.org>
Committed: Mon Jan 23 17:41:35 2017 +0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 ++
 .../component/MoreLikeThisComponent.java        | 12 +++++++++-
 .../handler/component/TermVectorComponent.java  |  9 ++++++++
 .../component/DistributedMLTComponentTest.java  | 23 ++++++++++++++++++++
 .../TermVectorComponentDistributedTest.java     | 18 +++++++++++++++
 5 files changed, 63 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d34f549d/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index abd2983..a68f445 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -121,6 +121,8 @@ Bug Fixes
 
 * SOLR-9979: Macro expansion should not be done in shard requests (Tomás Fernández Löbbe)
 
+* SOLR-9114: NPE using TermVectorComponent, MoreLikeThisComponent in combination with ExactStatsCache
(Cao Manh Dat, Varun Thacker)
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d34f549d/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java
b/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java
index 893cdf3..55edc63 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/MoreLikeThisComponent.java
@@ -221,7 +221,17 @@ public class MoreLikeThisComponent extends SearchComponent {
     }
     super.finishStage(rb);
   }
-  
+
+  @Override
+  public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
+    SolrParams params = rb.req.getParams();
+    if (!params.getBool(COMPONENT_NAME, false)) return;
+    if ((sreq.purpose & ShardRequest.PURPOSE_GET_MLT_RESULTS) == 0
+        && (sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) == 0) {
+      sreq.params.set(COMPONENT_NAME, "false");
+    }
+  }
+
   /**
    * Returns NamedList based on the order of
    * resultIds.shardDoc.positionInResponse

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d34f549d/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java
b/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java
index c887277..e81ed85 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/TermVectorComponent.java
@@ -464,6 +464,15 @@ public class TermVectorComponent extends SearchComponent implements SolrCoreAwar
     }
   }
 
+  @Override
+  public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
+    SolrParams params = rb.req.getParams();
+    if (!params.getBool(COMPONENT_NAME, false)) return;
+    if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) == 0) {
+      sreq.params.set(COMPONENT_NAME, "false");
+    }
+  }
+
   //////////////////////// NamedListInitializedPlugin methods //////////////////////
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d34f549d/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java
b/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java
index dd1d5c8..10116b9 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedMLTComponentTest.java
@@ -20,11 +20,17 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.lucene.util.TestUtil;
 import org.apache.solr.BaseDistributedSearchTestCase;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.params.MoreLikeThisParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.search.stats.ExactStatsCache;
+import org.apache.solr.search.stats.LRUStatsCache;
+import org.apache.solr.search.stats.LocalStatsCache;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
@@ -49,6 +55,23 @@ public class DistributedMLTComponentTest extends BaseDistributedSearchTestCase
{
     requestHandlerName = "mltrh";
     super.distribSetUp();
   }
+
+  @BeforeClass
+  public static void beforeClass() {
+    int statsType = TestUtil.nextInt(random(), 1, 3);
+    if (statsType == 1) {
+      System.setProperty("solr.statsCache", ExactStatsCache.class.getName());
+    } else if (statsType == 2) {
+      System.setProperty("solr.statsCache", LRUStatsCache.class.getName());
+    } else {
+      System.setProperty("solr.statsCache", LocalStatsCache.class.getName());
+    }
+  }
+
+  @AfterClass
+  public static void afterClass() {
+    System.clearProperty("solr.statsCache");
+  }
   
   @Test
   @ShardsFixed(num = 3)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d34f549d/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java
b/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java
index 5d7ff9a..0527d9e 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/TermVectorComponentDistributedTest.java
@@ -18,9 +18,14 @@ package org.apache.solr.handler.component;
 
 import org.apache.lucene.util.Constants;
 
+import org.apache.lucene.util.TestUtil;
 import org.apache.solr.BaseDistributedSearchTestCase;
 import org.apache.solr.common.params.ShardParams;
 import org.apache.solr.common.params.TermVectorParams;
+import org.apache.solr.search.stats.ExactStatsCache;
+import org.apache.solr.search.stats.LRUStatsCache;
+import org.apache.solr.search.stats.LocalStatsCache;
+import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -29,6 +34,19 @@ public class TermVectorComponentDistributedTest extends BaseDistributedSearchTes
   public static void betterNotBeJ9() {
     assumeFalse("FIXME: SOLR-5792: This test fails under IBM J9", 
                 Constants.JAVA_VENDOR.startsWith("IBM"));
+    int statsType = TestUtil.nextInt(random(), 1, 3);
+    if (statsType == 1) {
+      System.setProperty("solr.statsCache", ExactStatsCache.class.getName());
+    } else if (statsType == 2) {
+      System.setProperty("solr.statsCache", LRUStatsCache.class.getName());
+    } else {
+      System.setProperty("solr.statsCache", LocalStatsCache.class.getName());
+    }
+  }
+
+  @AfterClass
+  public static void afterClass() {
+    System.clearProperty("solr.statsCache");
   }
 
   @Test


Mime
View raw message