lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsmi...@apache.org
Subject svn commit: r1502730 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/request/SimpleFacets.java core/src/test/org/apache/solr/request/SimpleFacetsTest.java
Date Sat, 13 Jul 2013 00:05:10 GMT
Author: dsmiley
Date: Sat Jul 13 00:05:10 2013
New Revision: 1502730

URL: http://svn.apache.org/r1502730
Log:
SOLR-5034: A facet.query that parses or analyzes down to a null Query would throw a NPE.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1502730&r1=1502729&r2=1502730&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sat Jul 13 00:05:10 2013
@@ -307,6 +307,9 @@ Bug Fixes
   switching shard states. Multiple bugs related to sub shard recovery and
   replication are also fixed. (shalin)
 
+* SOLR-5034: A facet.query that parses or analyzes down to a null Query would
+  throw a NPE. Fixed. (David Smiley)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/request/SimpleFacets.java?rev=1502730&r1=1502729&r2=1502730&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/request/SimpleFacets.java Sat Jul
13 00:05:10 2013
@@ -295,7 +295,9 @@ public class SimpleFacets {
         // TODO: slight optimization would prevent double-parsing of any localParams
         Query qobj = QParser.getParser(q, null, req).getQuery();
 
-        if (params.getBool(GroupParams.GROUP_FACET, false)) {
+        if (qobj == null) {
+          res.add(key, 0);
+        } else if (params.getBool(GroupParams.GROUP_FACET, false)) {
           res.add(key, getGroupedFacetQueryCount(qobj));
         } else {
           res.add(key, searcher.numDocs(qobj, docs));

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java?rev=1502730&r1=1502729&r2=1502730&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/request/SimpleFacetsTest.java Sat
Jul 13 00:05:10 2013
@@ -621,6 +621,13 @@ public class SimpleFacetsTest extends So
                 )
             ,"*[count(//lst[@name='zerolen_s']/int)=1]"
      );
+
+    assertQ("a facet.query that analyzes to no query shoud not NPE",
+        req("q", "*:*",
+            "facet", "true",
+            "facet.query", "{!field key=k f=lengthfilt}a"),//2 char minimum
+        "//lst[@name='facet_queries']/int[@name='k'][.='0']"
+    );
   }
 
   public static void indexDateFacets() {



Mime
View raw message