You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sa...@apache.org on 2017/05/12 23:39:20 UTC

[2/2] lucene-solr:branch_6x: SOLR-10400: Replace (instanceof TrieFooField || instanceof FooPointField) constructs with FieldType.getNumberType() or SchemaField.getSortField() where appropriate.

SOLR-10400: Replace (instanceof TrieFooField || instanceof FooPointField) constructs with FieldType.getNumberType() or SchemaField.getSortField() where appropriate.

Conflicts:
	solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java


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

Branch: refs/heads/branch_6x
Commit: cbc32130caec4e1d64d1b10dba2a0486b2263418
Parents: 6de3640
Author: Steve Rowe <sa...@gmail.com>
Authored: Fri May 12 19:22:06 2017 -0400
Committer: Steve Rowe <sa...@gmail.com>
Committed: Fri May 12 19:38:44 2017 -0400

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  3 +
 .../solr/handler/component/ExpandComponent.java | 34 ++++----
 .../solr/search/CollapsingQParserPlugin.java    | 82 ++++++++++++--------
 .../DocumentExpressionDictionaryFactory.java    | 35 +--------
 .../DistributedExpandComponentTest.java         | 50 ++++++------
 .../handler/component/TestExpandComponent.java  | 62 +++++++--------
 .../solr/search/TestCollapseQParserPlugin.java  | 18 +++++
 7 files changed, 141 insertions(+), 143 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbc32130/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index db4258c..28b9d89 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -37,6 +37,9 @@ Other Changes
 
 * SOLR-10617: JDBCStream accepts columns of type TIME, DATE & TIMESTAMP as well as CLOBs and decimal
   numeric types (James Dyer)
+                                      
+* SOLR-10400: Replace (instanceof TrieFooField || instanceof FooPointField) constructs with 
+  FieldType.getNumberType() or SchemaField.getSortField() where appropriate. (hossman, Steve Rowe)
 
 ==================  6.6.0 ==================
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbc32130/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java b/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
index 84f38f9..aacc826 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/ExpandComponent.java
@@ -73,17 +73,10 @@ import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.core.PluginInfo;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.schema.DoublePointField;
 import org.apache.solr.schema.FieldType;
-import org.apache.solr.schema.FloatPointField;
-import org.apache.solr.schema.IntPointField;
-import org.apache.solr.schema.LongPointField;
+import org.apache.solr.schema.NumberType;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.schema.StrField;
-import org.apache.solr.schema.TrieDoubleField;
-import org.apache.solr.schema.TrieFloatField;
-import org.apache.solr.schema.TrieIntField;
-import org.apache.solr.schema.TrieLongField;
 import org.apache.solr.search.CollapsingQParserPlugin;
 import org.apache.solr.search.DocIterator;
 import org.apache.solr.search.DocList;
@@ -218,7 +211,7 @@ public class ExpandComponent extends SearchComponent implements PluginInfoInitia
     FieldType fieldType = schemaField.getType();
 
     SortedDocValues values = null;
-    long nullValue = 0;
+    long nullValue = 0L;
 
     if(fieldType instanceof StrField) {
       //Get The Top Level SortedDocValues
@@ -233,21 +226,20 @@ public class ExpandComponent extends SearchComponent implements PluginInfoInitia
     } else {
       //Get the nullValue for the numeric collapse field
       String defaultValue = searcher.getSchema().getField(field).getDefaultValue();
-      if(defaultValue != null) {
-        if(fieldType instanceof TrieIntField || fieldType instanceof TrieLongField ||
-            fieldType instanceof IntPointField || fieldType instanceof LongPointField) {
+      
+      final NumberType numType = fieldType.getNumberType();
+
+      // Since the expand component depends on the operation of the collapse component, 
+      // which validates that numeric field types are 32-bit,
+      // we don't need to handle invalid 64-bit field types here.
+      if (defaultValue != null) {
+        if (numType == NumberType.INTEGER) {
           nullValue = Long.parseLong(defaultValue);
-        } else if(fieldType instanceof TrieFloatField || fieldType instanceof FloatPointField){
+        } else if (numType == NumberType.FLOAT) {
           nullValue = Float.floatToIntBits(Float.parseFloat(defaultValue));
-        } else if(fieldType instanceof TrieDoubleField || fieldType instanceof DoublePointField){
-          nullValue = Double.doubleToLongBits(Double.parseDouble(defaultValue));
-        }
-      } else {
-        if(fieldType instanceof TrieFloatField || fieldType instanceof FloatPointField){
-          nullValue = Float.floatToIntBits(0.0f);
-        } else if(fieldType instanceof TrieDoubleField || fieldType instanceof DoublePointField){
-          nullValue = Double.doubleToLongBits(0.0f);
         }
+      } else if (NumberType.FLOAT.equals(numType)) { // Integer case already handled by nullValue defaulting to 0
+        nullValue = Float.floatToIntBits(0.0f);
       }
     }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbc32130/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
index d6f04bb..612642c 100644
--- a/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
@@ -67,13 +67,8 @@ import org.apache.solr.request.LocalSolrQueryRequest;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.request.SolrRequestInfo;
 import org.apache.solr.schema.FieldType;
-import org.apache.solr.schema.FloatPointField;
-import org.apache.solr.schema.IntPointField;
-import org.apache.solr.schema.LongPointField;
 import org.apache.solr.schema.StrField;
-import org.apache.solr.schema.TrieFloatField;
-import org.apache.solr.schema.TrieIntField;
-import org.apache.solr.schema.TrieLongField;
+import org.apache.solr.schema.NumberType;
 import org.apache.solr.uninverting.UninvertingReader;
 
 import static org.apache.solr.common.params.CommonParams.SORT;
@@ -905,14 +900,26 @@ public class CollapsingQParserPlugin extends QParserPlugin {
       } else if (funcQuery != null) {
         this.collapseStrategy =  new OrdValueSourceStrategy(maxDoc, nullPolicy, new int[valueCount], groupHeadSelector, this.needsScores, boostDocs, funcQuery, searcher, collapseValues);
       } else {
-        if(fieldType instanceof TrieIntField || fieldType instanceof IntPointField) {
-          this.collapseStrategy = new OrdIntStrategy(maxDoc, nullPolicy, new int[valueCount], groupHeadSelector, this.needsScores, boostDocs, collapseValues);
-        } else if(fieldType instanceof TrieFloatField || fieldType instanceof FloatPointField) {
-          this.collapseStrategy = new OrdFloatStrategy(maxDoc, nullPolicy, new int[valueCount], groupHeadSelector, this.needsScores, boostDocs, collapseValues);
-        } else if(fieldType instanceof TrieLongField || fieldType instanceof LongPointField) {
-          this.collapseStrategy =  new OrdLongStrategy(maxDoc, nullPolicy, new int[valueCount], groupHeadSelector, this.needsScores, boostDocs, collapseValues);
-        } else {
-          throw new IOException("min/max must be either Int/Long/Float field types");
+        NumberType numType = fieldType.getNumberType();
+        if (null == numType) {
+          throw new IOException("min/max must be either Int/Long/Float based field types");
+        }
+        switch (numType) {
+          case INTEGER: {
+            this.collapseStrategy = new OrdIntStrategy(maxDoc, nullPolicy, new int[valueCount], groupHeadSelector, this.needsScores, boostDocs, collapseValues);
+            break;
+          }
+          case FLOAT: {
+            this.collapseStrategy = new OrdFloatStrategy(maxDoc, nullPolicy, new int[valueCount], groupHeadSelector, this.needsScores, boostDocs, collapseValues);
+            break;
+          }
+          case LONG: {
+            this.collapseStrategy =  new OrdLongStrategy(maxDoc, nullPolicy, new int[valueCount], groupHeadSelector, this.needsScores, boostDocs, collapseValues);
+            break;
+          }
+          default: {
+            throw new IOException("min/max must be either Int/Long/Float field types");
+          }
         }
       }
     }
@@ -1069,12 +1076,20 @@ public class CollapsingQParserPlugin extends QParserPlugin {
       } else if (funcQuery != null) {
         this.collapseStrategy =  new IntValueSourceStrategy(maxDoc, size, collapseField, nullValue, nullPolicy, groupHeadSelector, this.needsScores, boostDocsMap, funcQuery, searcher);
       } else {
-        if(fieldType instanceof TrieIntField || fieldType instanceof IntPointField) {
-          this.collapseStrategy = new IntIntStrategy(maxDoc, size, collapseField, nullValue, nullPolicy, groupHeadSelector, this.needsScores, boostDocsMap);
-        } else if(fieldType instanceof TrieFloatField || fieldType instanceof FloatPointField) {
-          this.collapseStrategy = new IntFloatStrategy(maxDoc, size, collapseField, nullValue, nullPolicy, groupHeadSelector, this.needsScores, boostDocsMap);
-        } else {
-          throw new IOException("min/max must be Int or Float field types when collapsing on numeric fields");
+        NumberType numType = fieldType.getNumberType();
+        assert null != numType; // shouldn't make it here for non-numeric types
+        switch (numType) {
+          case INTEGER: {
+            this.collapseStrategy = new IntIntStrategy(maxDoc, size, collapseField, nullValue, nullPolicy, groupHeadSelector, this.needsScores, boostDocsMap);
+            break;
+          }
+          case FLOAT: {
+            this.collapseStrategy = new IntFloatStrategy(maxDoc, size, collapseField, nullValue, nullPolicy, groupHeadSelector, this.needsScores, boostDocsMap);
+            break;
+          }
+          default: {
+            throw new IOException("min/max must be Int or Float field types when collapsing on numeric fields");
+          }
         }
       }
     }
@@ -1159,14 +1174,11 @@ public class CollapsingQParserPlugin extends QParserPlugin {
   }
 
   private static class CollectorFactory {
-
+    /** @see #isNumericCollapsible */
+    private final static EnumSet<NumberType> NUMERIC_COLLAPSIBLE_TYPES = EnumSet.of(NumberType.INTEGER,
+                                                                                    NumberType.FLOAT);
     private boolean isNumericCollapsible(FieldType collapseFieldType) {
-      if (collapseFieldType instanceof TrieIntField || collapseFieldType instanceof IntPointField ||
-          collapseFieldType instanceof TrieFloatField || collapseFieldType instanceof FloatPointField) {
-        return true;
-      } else {
-        return false;
-      }
+      return NUMERIC_COLLAPSIBLE_TYPES.contains(collapseFieldType.getNumberType());
     }
 
     public DelegatingCollector getCollector(String collapseField,
@@ -1239,14 +1251,15 @@ public class CollapsingQParserPlugin extends QParserPlugin {
 
           int nullValue = 0;
 
-          if(collapseFieldType instanceof TrieFloatField || collapseFieldType instanceof FloatPointField) {
-            if(defaultValue != null) {
+          // must be non-null at this point
+          if (collapseFieldType.getNumberType().equals(NumberType.FLOAT)) {
+            if (defaultValue != null) {
               nullValue = Float.floatToIntBits(Float.parseFloat(defaultValue));
             } else {
               nullValue = Float.floatToIntBits(0.0f);
             }
           } else {
-            if(defaultValue != null) {
+            if (defaultValue != null) {
               nullValue = Integer.parseInt(defaultValue);
             }
           }
@@ -1273,18 +1286,19 @@ public class CollapsingQParserPlugin extends QParserPlugin {
                                             funcQuery,
                                             searcher);
 
-        } else if(isNumericCollapsible(collapseFieldType)) {
+        } else if (isNumericCollapsible(collapseFieldType)) {
 
           int nullValue = 0;
 
-          if(collapseFieldType instanceof TrieFloatField || collapseFieldType instanceof FloatPointField) {
-            if(defaultValue != null) {
+          // must be non-null at this point
+          if (collapseFieldType.getNumberType().equals(NumberType.FLOAT)) {
+            if (defaultValue != null) {
               nullValue = Float.floatToIntBits(Float.parseFloat(defaultValue));
             } else {
               nullValue = Float.floatToIntBits(0.0f);
             }
           } else {
-            if(defaultValue != null) {
+            if (defaultValue != null) {
               nullValue = Integer.parseInt(defaultValue);
             }
           }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbc32130/solr/core/src/java/org/apache/solr/spelling/suggest/DocumentExpressionDictionaryFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/suggest/DocumentExpressionDictionaryFactory.java b/solr/core/src/java/org/apache/solr/spelling/suggest/DocumentExpressionDictionaryFactory.java
index 3b7abdf..61fdbcc 100644
--- a/solr/core/src/java/org/apache/solr/spelling/suggest/DocumentExpressionDictionaryFactory.java
+++ b/solr/core/src/java/org/apache/solr/spelling/suggest/DocumentExpressionDictionaryFactory.java
@@ -28,15 +28,6 @@ import org.apache.lucene.search.SortField;
 import org.apache.lucene.search.spell.Dictionary;
 import org.apache.lucene.search.suggest.DocumentValueSourceDictionary;
 import org.apache.solr.core.SolrCore;
-import org.apache.solr.schema.DoublePointField;
-import org.apache.solr.schema.FieldType;
-import org.apache.solr.schema.FloatPointField;
-import org.apache.solr.schema.IntPointField;
-import org.apache.solr.schema.LongPointField;
-import org.apache.solr.schema.TrieDoubleField;
-import org.apache.solr.schema.TrieFloatField;
-import org.apache.solr.schema.TrieIntField;
-import org.apache.solr.schema.TrieLongField;
 import org.apache.solr.search.SolrIndexSearcher;
 
 /**
@@ -81,15 +72,7 @@ public class DocumentExpressionDictionaryFactory extends DictionaryFactory {
       if (params.getName(i).equals(SORT_FIELD)) {
         String sortFieldName = (String) params.getVal(i);
 
-        SortField.Type sortFieldType = getSortFieldType(core, sortFieldName);
-        
-        if (sortFieldType == null) {
-          throw new IllegalArgumentException(sortFieldName + " could not be mapped to any appropriate type"
-              + " [long, int, float, double]");
-        }
-        
-        SortField sortField = new SortField(sortFieldName, sortFieldType);
-        sortFields.add(sortField);
+        sortFields.add(getSortField(core, sortFieldName));
       }
     }
    
@@ -111,20 +94,8 @@ public class DocumentExpressionDictionaryFactory extends DictionaryFactory {
     return expression.getDoubleValuesSource(bindings).toLongValuesSource();
   }
   
-  private SortField.Type getSortFieldType(SolrCore core, String sortFieldName) {
-    SortField.Type type = null;
-    String fieldTypeName = core.getLatestSchema().getField(sortFieldName).getType().getTypeName();
-    FieldType ft = core.getLatestSchema().getFieldTypes().get(fieldTypeName);
-    if (ft instanceof TrieFloatField || ft instanceof FloatPointField) {
-      type = SortField.Type.FLOAT;
-    } else if (ft instanceof TrieIntField || ft instanceof IntPointField) {
-      type = SortField.Type.INT;
-    } else if (ft instanceof TrieLongField || ft instanceof LongPointField) {
-      type = SortField.Type.LONG;
-    } else if (ft instanceof TrieDoubleField || ft instanceof DoublePointField) {
-      type = SortField.Type.DOUBLE;
-    }
-    return type;
+  private SortField getSortField(SolrCore core, String sortFieldName) {
+    return core.getLatestSchema().getField(sortFieldName).getSortField(true);
   }
   
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbc32130/solr/core/src/test/org/apache/solr/handler/component/DistributedExpandComponentTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedExpandComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedExpandComponentTest.java
index c94f79f..5ca527f 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedExpandComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedExpandComponentTest.java
@@ -50,18 +50,18 @@ public class DistributedExpandComponentTest extends BaseDistributedSearchTestCas
     
     del("*:*");
 
-    index_specific(0,"id","1", "term_s", "YYYY", group, "group1", "test_ti", "5",  "test_tl", "10", "test_tf", "2000");
-    index_specific(0,"id","2", "term_s", "YYYY", group, "group1", "test_ti", "50", "test_tl", "100", "test_tf", "200");
-    index_specific(1,"id","5", "term_s", "YYYY", group, "group2", "test_ti", "4",  "test_tl", "10", "test_tf", "2000");
-    index_specific(1,"id","6", "term_s", "YYYY", group, "group2", "test_ti", "10", "test_tl", "100", "test_tf", "200");
-    index_specific(0,"id","7", "term_s", "YYYY", group, "group1", "test_ti", "1",  "test_tl", "100000", "test_tf", "2000");
-    index_specific(1,"id","8", "term_s", "YYYY", group, "group2", "test_ti", "2",  "test_tl", "100000", "test_tf", "200");
-    index_specific(2,"id","9", "term_s", "YYYY", group, "group3", "test_ti", "1000", "test_tl", "1005", "test_tf", "3000");
-    index_specific(2, "id", "10", "term_s", "YYYY", group, "group3", "test_ti", "1500", "test_tl", "1001", "test_tf", "3200");
-    index_specific(2,"id", "11",  "term_s", "YYYY", group, "group3", "test_ti", "1300", "test_tl", "1002", "test_tf", "3300");
-    index_specific(1,"id","12", "term_s", "YYYY", group, "group4", "test_ti", "15",  "test_tl", "10", "test_tf", "2000");
-    index_specific(1,"id","13", "term_s", "YYYY", group, "group4", "test_ti", "16",  "test_tl", "9", "test_tf", "2000");
-    index_specific(1,"id","14", "term_s", "YYYY", group, "group4", "test_ti", "1",  "test_tl", "20", "test_tf", "2000");
+    index_specific(0,"id","1", "term_s", "YYYY", group, "group1", "test_i", "5",  "test_l", "10", "test_f", "2000");
+    index_specific(0,"id","2", "term_s", "YYYY", group, "group1", "test_i", "50", "test_l", "100", "test_f", "200");
+    index_specific(1,"id","5", "term_s", "YYYY", group, "group2", "test_i", "4",  "test_l", "10", "test_f", "2000");
+    index_specific(1,"id","6", "term_s", "YYYY", group, "group2", "test_i", "10", "test_l", "100", "test_f", "200");
+    index_specific(0,"id","7", "term_s", "YYYY", group, "group1", "test_i", "1",  "test_l", "100000", "test_f", "2000");
+    index_specific(1,"id","8", "term_s", "YYYY", group, "group2", "test_i", "2",  "test_l", "100000", "test_f", "200");
+    index_specific(2,"id","9", "term_s", "YYYY", group, "group3", "test_i", "1000", "test_l", "1005", "test_f", "3000");
+    index_specific(2, "id", "10", "term_s", "YYYY", group, "group3", "test_i", "1500", "test_l", "1001", "test_f", "3200");
+    index_specific(2,"id", "11",  "term_s", "YYYY", group, "group3", "test_i", "1300", "test_l", "1002", "test_f", "3300");
+    index_specific(1,"id","12", "term_s", "YYYY", group, "group4", "test_i", "15",  "test_l", "10", "test_f", "2000");
+    index_specific(1,"id","13", "term_s", "YYYY", group, "group4", "test_i", "16",  "test_l", "9", "test_f", "2000");
+    index_specific(1,"id","14", "term_s", "YYYY", group, "group4", "test_i", "1",  "test_l", "20", "test_f", "2000");
 
 
     commit();
@@ -79,15 +79,15 @@ public class DistributedExpandComponentTest extends BaseDistributedSearchTestCas
     handle.put("_version_", SKIP);
     handle.put("expanded", UNORDERED);
 
-    query("q", "*:*", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_ti)", "expand", "true", "fl","*,score");
-    query("q", "*:*", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_ti)", "expand", "true", "expand.sort", "test_tl desc", "fl","*,score");
-    query("q", "*:*", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_ti)", "expand", "true", "expand.sort", "test_tl desc", "expand.rows", "1", "fl","*,score");
+    query("q", "*:*", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_i)", "expand", "true", "fl","*,score");
+    query("q", "*:*", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_i)", "expand", "true", "expand.sort", "test_l desc", "fl","*,score");
+    query("q", "*:*", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_i)", "expand", "true", "expand.sort", "test_l desc", "expand.rows", "1", "fl","*,score");
     //Test no expand results
-    query("q", "test_ti:5", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_ti)", "expand", "true", "expand.sort", "test_tl desc", "expand.rows", "1", "fl","*,score");
+    query("q", "test_i:5", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_i)", "expand", "true", "expand.sort", "test_l desc", "expand.rows", "1", "fl","*,score");
     //Test zero results
-    query("q", "test_ti:5434343", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_ti)", "expand", "true", "expand.sort", "test_tl desc", "expand.rows", "1", "fl","*,score");
+    query("q", "test_i:5434343", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_i)", "expand", "true", "expand.sort", "test_l desc", "expand.rows", "1", "fl","*,score");
     //Test page 2
-    query("q", "*:*", "start","1", "rows", "1", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_ti)", "expand", "true", "fl","*,score");
+    query("q", "*:*", "start","1", "rows", "1", "fq", "{!collapse field="+group+"}", "defType", "edismax", "bf", "field(test_i)", "expand", "true", "fl","*,score");
 
 
     //First basic test case.
@@ -95,7 +95,7 @@ public class DistributedExpandComponentTest extends BaseDistributedSearchTestCas
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
 
     setDistributedParams(params);
@@ -114,9 +114,9 @@ public class DistributedExpandComponentTest extends BaseDistributedSearchTestCas
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
-    params.add("expand.sort", "test_tl desc");
+    params.add("expand.sort", "test_l desc");
     setDistributedParams(params);
     rsp = queryServer(params);
     results = rsp.getExpandedResults();
@@ -133,9 +133,9 @@ public class DistributedExpandComponentTest extends BaseDistributedSearchTestCas
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
-    params.add("expand.sort", "test_tl desc");
+    params.add("expand.sort", "test_l desc");
     params.add("expand.rows", "1");
     setDistributedParams(params);
     rsp = queryServer(params);
@@ -153,7 +153,7 @@ public class DistributedExpandComponentTest extends BaseDistributedSearchTestCas
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
     params.add("fl", "id");
 
@@ -172,7 +172,7 @@ public class DistributedExpandComponentTest extends BaseDistributedSearchTestCas
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
     params.add("distrib.singlePass", "true");
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbc32130/solr/core/src/test/org/apache/solr/handler/component/TestExpandComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/handler/component/TestExpandComponent.java b/solr/core/src/test/org/apache/solr/handler/component/TestExpandComponent.java
index d1906d5..332e346 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/TestExpandComponent.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/TestExpandComponent.java
@@ -48,7 +48,7 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
 
   @Test
   public void testExpand() throws Exception {
-    List<String> groups = new ArrayList();
+    List<String> groups = new ArrayList<>();
     groups.add("group_s");
     groups.add("group_s_dv");
 
@@ -62,7 +62,7 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
 
   @Test
   public void testNumericExpand() throws Exception {
-    List<String> groups = new ArrayList();
+    List<String> groups = new ArrayList<>();
     groups.add("group_i");
     groups.add("group_ti_dv");
     groups.add("group_f");
@@ -82,30 +82,30 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
 
   private void _testExpand(String group, String floatAppend, String hint) throws Exception {
 
-    String[] doc = {"id","1", "term_s", "YYYY", group, "1"+floatAppend, "test_ti", "5", "test_tl", "10", "test_tf", "2000", "type_s", "parent"};
+    String[] doc = {"id","1", "term_s", "YYYY", group, "1"+floatAppend, "test_i", "5", "test_l", "10", "test_f", "2000", "type_s", "parent"};
     assertU(adoc(doc));
     assertU(commit());
-    String[] doc1 = {"id","2", "term_s","YYYY", group, "1"+floatAppend, "test_ti", "50", "test_tl", "100", "test_tf", "200", "type_s", "child"};
+    String[] doc1 = {"id","2", "term_s","YYYY", group, "1"+floatAppend, "test_i", "50", "test_l", "100", "test_f", "200", "type_s", "child"};
     assertU(adoc(doc1));
 
-    String[] doc2 = {"id","3", "term_s", "YYYY", "test_ti", "5000", "test_tl", "100", "test_tf", "200"};
+    String[] doc2 = {"id","3", "term_s", "YYYY", "test_i", "5000", "test_l", "100", "test_f", "200"};
     assertU(adoc(doc2));
     assertU(commit());
-    String[] doc3 = {"id","4", "term_s", "YYYY", "test_ti", "500", "test_tl", "1000", "test_tf", "2000"};
+    String[] doc3 = {"id","4", "term_s", "YYYY", "test_i", "500", "test_l", "1000", "test_f", "2000"};
     assertU(adoc(doc3));
 
 
-    String[] doc4 = {"id","5", "term_s", "YYYY", group, "2"+floatAppend, "test_ti", "4", "test_tl", "10", "test_tf", "2000", "type_s", "parent"};
+    String[] doc4 = {"id","5", "term_s", "YYYY", group, "2"+floatAppend, "test_i", "4", "test_l", "10", "test_f", "2000", "type_s", "parent"};
     assertU(adoc(doc4));
     assertU(commit());
-    String[] doc5 = {"id","6", "term_s","YYYY", group, "2"+floatAppend, "test_ti", "10", "test_tl", "100", "test_tf", "200", "type_s", "child"};
+    String[] doc5 = {"id","6", "term_s","YYYY", group, "2"+floatAppend, "test_i", "10", "test_l", "100", "test_f", "200", "type_s", "child"};
     assertU(adoc(doc5));
     assertU(commit());
 
-    String[] doc6 = {"id","7", "term_s", "YYYY", group, "1"+floatAppend, "test_ti", "1", "test_tl", "100000", "test_tf", "2000", "type_s", "child"};
+    String[] doc6 = {"id","7", "term_s", "YYYY", group, "1"+floatAppend, "test_i", "1", "test_l", "100000", "test_f", "2000", "type_s", "child"};
     assertU(adoc(doc6));
     assertU(commit());
-    String[] doc7 = {"id","8", "term_s","YYYY", group, "2"+floatAppend, "test_ti", "2", "test_tl", "100000", "test_tf", "200", "type_s", "child"};
+    String[] doc7 = {"id","8", "term_s","YYYY", group, "2"+floatAppend, "test_i", "2", "test_l", "100000", "test_f", "200", "type_s", "child"};
     assertU(adoc(doc7));
 
     assertU(commit());
@@ -115,7 +115,7 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+hint+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
     assertQ(req(params), "*[count(/response/result/doc)=2]",
         "*[count(/response/lst[@name='expanded']/result)=2]",
@@ -133,7 +133,7 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+hint+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
     params.add("rows", "1");
     params.add("start", "1");
@@ -149,9 +149,9 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+hint+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
-    params.add("expand.sort", "test_tl desc, sub(1,1) asc");//the "sub()" just testing function queries
+    params.add("expand.sort", "test_l desc, sub(1,1) asc");//the "sub()" just testing function queries
     assertQ(req(params), "*[count(/response/result/doc)=2]",
         "*[count(/response/lst[@name='expanded']/result)=2]",
         "/response/result/doc[1]/float[@name='id'][.='2.0']",
@@ -168,9 +168,9 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+hint+" nullPolicy=collapse}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
-    params.add("expand.sort", "test_tl desc");
+    params.add("expand.sort", "test_l desc");
     assertQ(req(params), "*[count(/response/result/doc)=3]",
         "*[count(/response/lst[@name='expanded']/result)=2]",
         "/response/result/doc[1]/float[@name='id'][.='3.0']",
@@ -188,11 +188,11 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     params = new ModifiableSolrParams();
     params.add("q", "type_s:parent");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
     params.add("expand.q", "type_s:child");
     params.add("expand.field", group);
-    params.add("expand.sort", "test_tl desc");
+    params.add("expand.sort", "test_l desc");
     assertQ(req(params), "*[count(/response/result/doc)=2]",
         "*[count(/response/lst[@name='expanded']/result)=2]",
         "/response/result/doc[1]/float[@name='id'][.='1.0']",
@@ -210,11 +210,11 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     params.add("q", "*:*");
     params.add("fq", "type_s:parent");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
     params.add("expand.fq", "type_s:child");
     params.add("expand.field", group);
-    params.add("expand.sort", "test_tl desc");
+    params.add("expand.sort", "test_l desc");
     assertQ(req(params), "*[count(/response/result/doc)=2]",
         "*[count(/response/lst[@name='expanded']/result)=2]",
         "/response/result/doc[1]/float[@name='id'][.='1.0']",
@@ -231,12 +231,12 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     params.add("q", "*:*");
     params.add("fq", "type_s:parent");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
     params.add("expand.q", "type_s:child");
     params.add("expand.fq", "*:*");
     params.add("expand.field", group);
-    params.add("expand.sort", "test_tl desc");
+    params.add("expand.sort", "test_l desc");
     assertQ(req(params), "*[count(/response/result/doc)=2]",
         "*[count(/response/lst[@name='expanded']/result)=2]",
         "/response/result/doc[1]/float[@name='id'][.='1.0']",
@@ -253,9 +253,9 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+hint+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
-    params.add("expand.sort", "test_tl desc");
+    params.add("expand.sort", "test_l desc");
     params.add("expand.rows", "1");
     assertQ(req(params), "*[count(/response/result/doc)=2]",
         "*[count(/response/lst[@name='expanded']/result)=2]",
@@ -271,12 +271,12 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     //Test no group results
 
     params = new ModifiableSolrParams();
-    params.add("q", "test_ti:5");
+    params.add("q", "test_i:5");
     params.add("fq", "{!collapse field="+group+hint+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
-    params.add("expand.sort", "test_tl desc");
+    params.add("expand.sort", "test_l desc");
     params.add("expand.rows", "1");
     assertQ(req(params), "*[count(/response/result/doc)=1]",
         "*[count(/response/lst[@name='expanded']/result)=0]"
@@ -285,12 +285,12 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     //Test zero results
 
     params = new ModifiableSolrParams();
-    params.add("q", "test_ti:5532535");
+    params.add("q", "test_i:5532535");
     params.add("fq", "{!collapse field="+group+hint+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
-    params.add("expand.sort", "test_tl desc");
+    params.add("expand.sort", "test_l desc");
     params.add("expand.rows", "1");
     assertQ(req(params), "*[count(/response/result/doc)=0]",
         "*[count(/response/lst[@name='expanded']/result)=0]"
@@ -302,7 +302,7 @@ public class TestExpandComponent extends SolrTestCaseJ4 {
     params.add("q", "*:*");
     params.add("fq", "{!collapse field="+group+hint+"}");
     params.add("defType", "edismax");
-    params.add("bf", "field(test_ti)");
+    params.add("bf", "field(test_i)");
     params.add("expand", "true");
     params.add("fl", "id");
     assertQ(req(params), "*[count(/response/result/doc)=2]",

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cbc32130/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
index 026e194..ef0404c 100644
--- a/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
+++ b/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
@@ -16,6 +16,7 @@
  */
 package org.apache.solr.search;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashSet;
@@ -915,4 +916,21 @@ public class TestCollapseQParserPlugin extends SolrTestCaseJ4 {
     
   }
 
+  @Test
+  public void test64BitCollapseFieldException() {
+    ModifiableSolrParams doubleParams = new ModifiableSolrParams();
+    doubleParams.add("q", "*:*");
+    doubleParams.add("fq", "{!collapse field=group_d}");
+    expectThrows(RuntimeException.class, IOException.class, () -> h.query(req(doubleParams)));
+
+    ModifiableSolrParams dateParams = new ModifiableSolrParams();
+    dateParams.add("q", "*:*");
+    dateParams.add("fq", "{!collapse field=group_dt}");
+    expectThrows(RuntimeException.class, IOException.class, () -> h.query(req(dateParams)));
+
+    ModifiableSolrParams longParams = new ModifiableSolrParams();
+    longParams.add("q", "*:*");
+    longParams.add("fq", "{!collapse field=group_l}");
+    expectThrows(RuntimeException.class, IOException.class, () -> h.query(req(longParams)));
+  }
 }