lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1363555 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/handler/component/StatsComponent.java core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
Date Thu, 19 Jul 2012 21:28:12 GMT
Author: hossman
Date: Thu Jul 19 21:28:11 2012
New Revision: 1363555

URL: http://svn.apache.org/viewvc?rev=1363555&view=rev
Log:
SOLR-3642: Correct broken check for multivalued fields in stats.facet

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsComponent.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1363555&r1=1363554&r2=1363555&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Thu Jul 19 21:28:11 2012
@@ -112,6 +112,8 @@ Bug Fixes
   file name using the "config" attribute prevented the override file from being
   used. (Ryan Zezeski, hossman)
 
+* SOLR-3642: Correct broken check for multivalued fields in stats.facet
+  (Yandong Yao, hossman)
 
 Other Changes
 ----------------------

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsComponent.java?rev=1363555&r1=1363554&r2=1363555&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsComponent.java
(original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/StatsComponent.java
Thu Jul 19 21:28:11 2012
@@ -256,13 +256,12 @@ class SimpleStats {
     FieldCache.DocTermsIndex facetTermsIndex;
     for( String facetField : facet ) {
       SchemaField fsf = searcher.getSchema().getField(facetField);
-      FieldType facetFieldType = fsf.getType();
 
-      if (facetFieldType.isTokenized() || facetFieldType.isMultiValued()) {
+      if ( fsf.multiValued()) {
         throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
-          "Stats can only facet on single-valued fields, not: " + facetField
-          + "[" + facetFieldType + "]");
-        }
+          "Stats can only facet on single-valued fields, not: " + facetField );
+      }
+
       try {
         facetTermsIndex = FieldCache.DEFAULT.getTermsIndex(searcher.getAtomicReader(), facetField);
       }

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java?rev=1363555&r1=1363554&r2=1363555&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
(original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/StatsComponentTest.java
Thu Jul 19 21:28:11 2012
@@ -27,6 +27,10 @@ import java.text.SimpleDateFormat;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.params.StatsParams;
+
+import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.schema.SchemaField;
+
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.request.SolrQueryRequest;
@@ -340,4 +344,25 @@ public class StatsComponentTest extends 
     assertQ("test string statistics values", req,
         "//null[@name='active_dt'][.='']");
   }
+
+  public void testStatsFacetMultivaluedErrorHandling() throws Exception {
+    SolrCore core = h.getCore();
+    SchemaField foo_ss = core.getSchema().getField("foo_ss");
+
+    assertU(adoc("id", "1", "active_i", "1", "foo_ss", "aa" ));
+    assertU(adoc("id", "2", "active_i", "1", "foo_ss", "bb" ));
+    assertU(adoc("id", "3", "active_i", "5", "foo_ss", "aa" ));
+    assertU(commit());
+
+    assertTrue("schema no longer satisfies test requirements: foo_ss no longer multivalued",
foo_ss.multiValued());
+    assertTrue("schema no longer satisfies test requirements: foo_ss's fieldtype no longer
single valued", ! foo_ss.getType().isMultiValued());
+    
+    assertQEx("no failure trying to get stats facet on foo_ss",
+              req("q", "*:*", 
+                  "stats", "true",
+                  "stats.field", "active_i",
+                  "stats.facet", "foo_ss"),
+              400);
+
+  }
 }



Mime
View raw message