lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [49/50] [abbrv] lucene-solr:jira/solr-8593: Merge branch 'apache-https-master' into jira/solr-8593
Date Thu, 20 Oct 2016 19:31:58 GMT
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2e7f5f92/lucene/ivy-versions.properties
----------------------------------------------------------------------
diff --cc lucene/ivy-versions.properties
index a9aed1f,7f8ac12..e34639b
--- a/lucene/ivy-versions.properties
+++ b/lucene/ivy-versions.properties
@@@ -18,8 -18,10 +18,8 @@@ com.codahale.metrics.version = 3.0.
  /com.codahale.metrics/metrics-healthchecks = ${com.codahale.metrics.version}
  
  /com.cybozu.labs/langdetect = 1.1-20120112
- /com.drewnoakes/metadata-extractor = 2.6.2
+ /com.drewnoakes/metadata-extractor = 2.8.1
  
 -/com.facebook.presto/presto-parser = 0.122
 -
  com.fasterxml.jackson.core.version = 2.5.4
  /com.fasterxml.jackson.core/jackson-annotations = ${com.fasterxml.jackson.core.version}
  /com.fasterxml.jackson.core/jackson-core = ${com.fasterxml.jackson.core.version}
@@@ -90,13 -99,7 +97,13 @@@ io.netty.netty-all.version = 4.0.36.Fin
  
  /org.apache.ant/ant = 1.8.2
  /org.apache.avro/avro = 1.7.5
 +
- org.apache.calcite.version = 1.7.0
++org.apache.calcite.version = 1.10.0
 +/org.apache.calcite.avatica/avatica = 1.7.1
 +/org.apache.calcite/calcite-core = ${org.apache.calcite.version}
 +/org.apache.calcite/calcite-linq4j = ${org.apache.calcite.version}
 +
- /org.apache.commons/commons-compress = 1.8.1
+ /org.apache.commons/commons-compress = 1.11
  /org.apache.commons/commons-exec = 1.3
  /org.apache.commons/commons-math3 = 3.4.1
  

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2e7f5f92/solr/core/ivy.xml
----------------------------------------------------------------------
diff --cc solr/core/ivy.xml
index 9f3c190,67e4379..dcd7e78
--- a/solr/core/ivy.xml
+++ b/solr/core/ivy.xml
@@@ -129,16 -134,16 +134,20 @@@
      <dependency org="antlr" name="antlr" rev="${/antlr/antlr}" conf="test.MiniKdc"/>
      <dependency org="net.sf.ehcache" name="ehcache-core" rev="${/net.sf.ehcache/ehcache-core}" conf="test.MiniKdc"/>
  
+     <dependency org="org.apache.curator" name="curator-framework" rev="${/org.apache.curator/curator-framework}" conf="compile"/>
+     <dependency org="org.apache.curator" name="curator-client" rev="${/org.apache.curator/curator-client}" conf="compile"/>
+     <dependency org="org.apache.curator" name="curator-recipes" rev="${/org.apache.curator/curator-recipes}" conf="compile"/>
+ 
      <!-- StatsComponents percentiles Dependencies-->
      <dependency org="com.tdunning" name="t-digest" rev="${/com.tdunning/t-digest}" conf="compile->*"/>
 -    <!-- SQL Parser -->
  
 -    <dependency org="com.facebook.presto" name="presto-parser" rev="${/com.facebook.presto/presto-parser}"/>
 -    <dependency org="io.airlift" name="slice" rev="${/io.airlift/slice}"/>
 +    <!-- SQL Parser -->
 +    <dependency org="org.apache.calcite" name="calcite-core" rev="${/org.apache.calcite/calcite-core}"/>
 +    <dependency org="org.apache.calcite" name="calcite-linq4j" rev="${/org.apache.calcite/calcite-linq4j}"/>
 +    <dependency org="org.apache.calcite.avatica" name="avatica" rev="${/org.apache.calcite.avatica/avatica}"/>
 +    <dependency org="net.hydromatic" name="eigenbase-properties" rev="1.1.5"/>
 +    <dependency org="org.codehaus.janino" name="janino" rev="2.7.6"/>
 +    <dependency org="org.codehaus.janino" name="commons-compiler" rev="2.7.6"/>
  
      <exclude org="*" ext="*" matcher="regexp" type="${ivy.exclude.types}"/> 
    </dependencies>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2e7f5f92/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
----------------------------------------------------------------------
diff --cc solr/core/src/java/org/apache/solr/handler/SQLHandler.java
index 9e76726,3074d9b..c389fb7
--- a/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/SQLHandler.java
@@@ -55,8 -69,17 +55,10 @@@ import org.apache.solr.util.plugin.Solr
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
 -import com.facebook.presto.sql.parser.SqlParser;
 -
  public class SQLHandler extends RequestHandlerBase implements SolrCoreAware , PermissionNameProvider {
  
+   private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+ 
    private static String defaultZkhost = null;
    private static String defaultWorkerCollection = null;
  
@@@ -77,17 -103,25 +82,21 @@@
    }
  
    public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
 -    SolrParams params = req.getParams();
 -    params = adjustParams(params);
 -    req.setParams(params);
 +    ModifiableSolrParams params = new ModifiableSolrParams(req.getParams());
      String sql = params.get("stmt");
 -    int numWorkers = params.getInt("numWorkers", 1);
 -    String workerCollection = params.get("workerCollection", defaultWorkerCollection);
 -    String workerZkhost = params.get("workerZkhost", defaultZkhost);
 -    String mode = params.get("aggregationMode", "map_reduce");
 -    StreamContext context = new StreamContext();
 -
 -    // JDBC driver requires metadata from the SQLHandler. Default to false since this adds a new Metadata stream.
 -    boolean includeMetadata = params.getBool("includeMetadata", false);
 +    // Set defaults for parameters
 +    params.set("numWorkers", params.getInt("numWorkers", 1));
 +    params.set("workerCollection", params.get("workerCollection", defaultWorkerCollection));
 +    params.set("workerZkhost", params.get("workerZkhost", defaultZkhost));
 +    params.set("aggregationMode", params.get("aggregationMode", "map_reduce"));
  
- 
 +    TupleStream tupleStream = null;
      try {
+ 
+       if(!isCloud) {
+         throw new IllegalStateException(sqlNonCloudErrorMsg);
+       }
+ 
        if(sql == null) {
          throw new Exception("stmt parameter cannot be null");
        }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/2e7f5f92/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
----------------------------------------------------------------------
diff --cc solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
index 0bac4d6,4ce2798..d944148
--- a/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestSQLHandler.java
@@@ -18,10 -18,11 +18,8 @@@ package org.apache.solr.handler
  
  import java.io.IOException;
  import java.util.ArrayList;
- import java.util.HashMap;
 -import java.util.Collections;
  import java.util.List;
- import java.util.Map;
  
 -import com.facebook.presto.sql.parser.SqlParser;
 -import com.facebook.presto.sql.tree.Statement;
  import org.apache.solr.client.solrj.io.Tuple;
  import org.apache.solr.client.solrj.io.stream.ExceptionStream;
  import org.apache.solr.client.solrj.io.stream.SolrStream;
@@@ -29,7 -30,11 +27,10 @@@ import org.apache.solr.client.solrj.io.
  import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
  import org.apache.solr.common.cloud.Replica;
  import org.apache.solr.common.params.CommonParams;
+ import org.apache.solr.common.params.ModifiableSolrParams;
+ import org.apache.solr.common.params.SolrParams;
+ 
  import org.junit.After;
 -import org.junit.AfterClass;
  import org.junit.Before;
  import org.junit.Test;
  
@@@ -69,19 -80,223 +70,20 @@@ public class TestSQLHandler extends Abs
    @Test
    public void doTest() throws Exception {
      waitForRecoveriesToFinish(false);
 -    testPredicate();
      testBasicSelect();
 -    testWhere();
 -    testMixedCaseFields();
++//    testWhere();
 +//    testMixedCaseFields();
      testBasicGrouping();
 -    testBasicGroupingFacets();
 -    testSelectDistinct();
 -    testSelectDistinctFacets();
 +    testBasicGroupingFacets(); // TODO push down facets
 +//    testSelectDistinct(); // TODO fails due to sort asc by default missing
 +//    testSelectDistinctFacets(); // TODO push down facets and fails due to sort asc by default missing
      testAggregatesWithoutGrouping();
 -    testSQLException();
 -    testTimeSeriesGrouping();
 -    testTimeSeriesGroupingFacet();
 +//    testSQLException(); // TODO fix exception checking
 +//    testTimeSeriesGrouping();
 +//    testTimeSeriesGroupingFacet(); // TODO push down facets
      testParallelBasicGrouping();
- //    testParallelSelectDistinct(); //TODO fails due to sort asc by default missing
 -    testParallelSelectDistinct();
 -    testParallelTimeSeriesGrouping();
 -    testCatalogStream();
 -    testSchemasStream();
 -    testTablesStream();
 -  }
 -
 -  private void testPredicate() throws Exception {
 -
 -    SqlParser parser = new SqlParser();
 -    String sql = "select a from b where c = 'd'";
 -    Statement statement = parser.createStatement(sql);
 -    SQLHandler.SQLVisitor sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:\"d\")", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c = 5";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:\"5\")", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c <> 'd'";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(-c:\"d\")", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c <> 5";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(-c:\"5\")", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c > 'd'";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:{\"d\" TO *])", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c > 5";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:{\"5\" TO *])", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c >= 'd'";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:[\"d\" TO *])", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c >= 5";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:[\"5\" TO *])", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c < 'd'";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:[* TO \"d\"})", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c < 5";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:[* TO \"5\"})", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c <= 'd'";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:[* TO \"d\"])", sqlVistor.query);
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where c <= 5";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, 0);
 -
 -    assertEquals("(c:[* TO \"5\"])", sqlVistor.query);
 -
 -    //Add parens
 -    parser = new SqlParser();
 -    sql = "select a from b where (c = 'd')";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -
 -    assert(sqlVistor.query.equals("(c:\"d\")"));
 -
 -
 -    //Upper case
 -    parser = new SqlParser();
 -    sql = "select a from b where ('CcC' = 'D')";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -    assert(sqlVistor.query.equals("(CcC:\"D\")"));
 -
 -    //Phrase
 -    parser = new SqlParser();
 -    sql = "select a from b where (c = 'd d')";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -
 -    assert(sqlVistor.query.equals("(c:\"d d\")"));
 -
 -    // AND
 -    parser = new SqlParser();
 -    sql = "select a from b where ((c = 'd') AND (l = 'z'))";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -
 -    assert(sqlVistor.query.equals("((c:\"d\") AND (l:\"z\"))"));
 -
 -    // OR
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where ((c = 'd') OR (l = 'z'))";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -
 -    assert(sqlVistor.query.equals("((c:\"d\") OR (l:\"z\"))"));
 -
 -    // AND NOT
 -
 -    parser = new SqlParser();
 -    sql = "select a from b where ((c = 'd') AND NOT (l = 'z'))";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -
 -    assert(sqlVistor.query.equals("((c:\"d\") AND -(l:\"z\"))"));
 -
 -    // NESTED
 -    parser = new SqlParser();
 -    sql = "select a from b where ((c = 'd') OR ((l = 'z') AND (m = 'j')))";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -
 -    assert(sqlVistor.query.equals("((c:\"d\") OR ((l:\"z\") AND (m:\"j\")))"));
 -
 -    // NESTED NOT
 -    parser = new SqlParser();
 -    sql = "select a from b where ((c = 'd') OR ((l = 'z') AND NOT (m = 'j')))";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -
 -    assert(sqlVistor.query.equals("((c:\"d\") OR ((l:\"z\") AND -(m:\"j\")))"));
 -
 -    // RANGE - Will have to do until SQL BETWEEN is supported.
 -    // NESTED
 -    parser = new SqlParser();
 -    sql = "select a from b where ((c = '[0 TO 100]') OR ((l = '(z)') AND (m = 'j')))";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -
 -    assert(sqlVistor.query.equals("((c:[0 TO 100]) OR ((l:(z)) AND (m:\"j\")))"));
 -
 -    // Wildcard
 -    parser = new SqlParser();
 -    sql = "select a from b where ((c = '[0 TO 100]') OR ((l = '(z*)') AND (m = 'j')))";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -    assert(sqlVistor.query.equals("((c:[0 TO 100]) OR ((l:(z*)) AND (m:\"j\")))"));
 -
 -    // Complex Lucene/Solr Query
 -    parser = new SqlParser();
 -    sql = "select a from b where (('c' = '[0 TO 100]') OR ((l = '(z*)') AND ('M' = '(j OR (k NOT s))')))";
 -    statement = parser.createStatement(sql);
 -    sqlVistor = new SQLHandler.SQLVisitor(new StringBuilder());
 -    sqlVistor.process(statement, new Integer(0));
 -    assert(sqlVistor.query.equals("((c:[0 TO 100]) OR ((l:(z*)) AND (M:(j OR (k NOT s)))))"));
++//    testParallelSelectDistinct();
 +//    testParallelTimeSeriesGrouping();
    }
  
    private void testBasicSelect() throws Exception {
@@@ -101,12 -317,11 +103,11 @@@
        indexDoc(sdoc("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50"));
        indexDoc(sdoc("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60"));
        commit();
+       
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql", 
 -          "stmt", "select 'id', field_i, str_s from collection1 where 'text'='XXXX' order by field_i desc");
++          "stmt", "select id, field_i, str_s from collection1 where text='XXXX' order by field_i desc");
  
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select id, field_i, str_s from collection1 where text='XXXX' order by field_i desc");
- 
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
        assert(tuples.size() == 8);
@@@ -153,14 -368,10 +154,10 @@@
        assert(tuple.getLong("field_i") == 7);
        assert(tuple.get("str_s").equals("a"));
  
- 
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
- 
        //Test unlimited unsorted result. Should sort on _version_ desc
-       params.put("stmt", "select id, field_i, str_s from collection1 where text='XXXX'");
 -      sParams = mapParams(CommonParams.QT, "/sql", "stmt", "select 'id', field_i, str_s from collection1 where 'text'='XXXX'");
++      sParams = mapParams(CommonParams.QT, "/sql", "stmt", "select id, field_i, str_s from collection1 where text='XXXX'");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 8);
@@@ -269,13 -475,11 +261,10 @@@
        assert(tuple.getLong("myInt") == 7);
        assert(tuple.get("myString").equals("a"));
  
 -
+       sParams = mapParams(CommonParams.QT, "/sql",
+           "stmt", "select id as myId, field_i as myInt, str_s as myString from collection1 where text='XXXX' AND id='(1 2 3)' order by field_i desc");
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select id as myId, field_i as myInt, str_s as myString from collection1 where text='XXXX' " +
-           "AND id='(1 2 3)' order by field_i desc");
- 
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 3);
@@@ -331,6 -534,142 +319,141 @@@
      }
    }
  
+   private void testWhere() throws Exception {
+     try {
+       CloudJettyRunner jetty = this.cloudJettys.get(0);
+ 
+       del("*:*");
+ 
+       commit();
+ 
+       indexDoc(sdoc("id", "1", "text", "XXXX XXXX", "str_s", "a", "field_i", "7"));
+       indexDoc(sdoc("id", "2", "text", "XXXX XXXX", "str_s", "b", "field_i", "8"));
+       indexDoc(sdoc("id", "3", "text", "XXXX XXXX", "str_s", "a", "field_i", "20"));
+       indexDoc(sdoc("id", "4", "text", "XXXX XXXX", "str_s", "b", "field_i", "11"));
+       indexDoc(sdoc("id", "5", "text", "XXXX XXXX", "str_s", "c", "field_i", "30"));
+       indexDoc(sdoc("id", "6", "text", "XXXX XXXX", "str_s", "c", "field_i", "40"));
+       indexDoc(sdoc("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50"));
+       indexDoc(sdoc("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60"));
+       commit();
+ 
+       // Equals
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql",
+           "stmt", "select id from collection1 where id = 1 order by id asc");
+ 
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
+       List<Tuple> tuples = getTuples(solrStream);
+ 
+       assertEquals(1, tuples.size());
+ 
+       Tuple tuple = tuples.get(0);
+       assertEquals(1L, tuple.get("id"));
+ 
+       // Not Equals <>
+       sParams = mapParams(CommonParams.QT, "/sql",
+           "stmt", "select id from collection1 where id <> 1 order by id asc limit 10");
+ 
+       solrStream = new SolrStream(jetty.url, sParams);
+       tuples = getTuples(solrStream);
+ 
+       assertEquals(7, tuples.size());
+ 
+       tuple = tuples.get(0);
+       assertEquals(2L, tuple.get("id"));
+       tuple = tuples.get(1);
+       assertEquals(3L, tuple.get("id"));
+       tuple = tuples.get(2);
+       assertEquals(4L, tuple.get("id"));
+       tuple = tuples.get(3);
+       assertEquals(5L, tuple.get("id"));
+       tuple = tuples.get(4);
+       assertEquals(6L, tuple.get("id"));
+       tuple = tuples.get(5);
+       assertEquals(7L, tuple.get("id"));
+       tuple = tuples.get(6);
+       assertEquals(8L, tuple.get("id"));
+ 
+       // Not Equals !=
+       sParams = mapParams(CommonParams.QT, "/sql",
+           "stmt", "select id from collection1 where id != 1 order by id asc limit 10");
+ 
+       solrStream = new SolrStream(jetty.url, sParams);
+       tuples = getTuples(solrStream);
+ 
+       assertEquals(7, tuples.size());
+ 
+       tuple = tuples.get(0);
+       assertEquals(2L, tuple.get("id"));
+       tuple = tuples.get(1);
+       assertEquals(3L, tuple.get("id"));
+       tuple = tuples.get(2);
+       assertEquals(4L, tuple.get("id"));
+       tuple = tuples.get(3);
+       assertEquals(5L, tuple.get("id"));
+       tuple = tuples.get(4);
+       assertEquals(6L, tuple.get("id"));
+       tuple = tuples.get(5);
+       assertEquals(7L, tuple.get("id"));
+       tuple = tuples.get(6);
+       assertEquals(8L, tuple.get("id"));
+ 
+       // Less than
+       sParams = mapParams(CommonParams.QT, "/sql",
+           "stmt", "select id from collection1 where id < 2 order by id asc");
+ 
+       solrStream = new SolrStream(jetty.url, sParams);
+       tuples = getTuples(solrStream);
+ 
+       assertEquals(1, tuples.size());
+ 
+       tuple = tuples.get(0);
+       assertEquals(1L, tuple.get("id"));
+ 
+       // Less than equal
+       sParams = mapParams(CommonParams.QT, "/sql",
+           "stmt", "select id from collection1 where id <= 2 order by id asc");
+ 
+       solrStream = new SolrStream(jetty.url, sParams);
+       tuples = getTuples(solrStream);
+ 
+       assertEquals(2, tuples.size());
+ 
+       tuple = tuples.get(0);
+       assertEquals(1L, tuple.get("id"));
+       tuple = tuples.get(1);
+       assertEquals(2L, tuple.get("id"));
+ 
+       // Greater than
+       sParams = mapParams(CommonParams.QT, "/sql",
+           "stmt", "select id from collection1 where id > 7 order by id asc");
+ 
+       solrStream = new SolrStream(jetty.url, sParams);
+       tuples = getTuples(solrStream);
+ 
+       assertEquals(1, tuples.size());
+ 
+       tuple = tuples.get(0);
+       assertEquals(8L, tuple.get("id"));
+ 
+       // Greater than equal
+       sParams = mapParams(CommonParams.QT, "/sql",
+           "stmt", "select id from collection1 where id >= 7 order by id asc");
+ 
+       solrStream = new SolrStream(jetty.url, sParams);
+       tuples = getTuples(solrStream);
+ 
+       assertEquals(2, tuples.size());
+ 
+       tuple = tuples.get(0);
+       assertEquals(7L, tuple.get("id"));
+       tuple = tuples.get(1);
+       assertEquals(8L, tuple.get("id"));
+ 
+     } finally {
+       delete();
+     }
+   }
+ 
 -
    private void testMixedCaseFields() throws Exception {
      try {
  
@@@ -349,11 -688,10 +472,11 @@@
        indexDoc(sdoc("id", "7", "Text_t", "XXXX XXXX", "Str_s", "c", "Field_i", "50"));
        indexDoc(sdoc("id", "8", "Text_t", "XXXX XXXX", "Str_s", "c", "Field_i", "60"));
        commit();
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select id, Field_i, Str_s from collection1 where Text_t='XXXX' order by Field_i desc");
 +
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql",
+           "stmt", "select id, Field_i, Str_s from Collection1 where Text_t='XXXX' order by Field_i desc");
+ 
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
        assert(tuples.size() == 8);
@@@ -400,12 -738,10 +523,10 @@@
        assert(tuple.getLong("Field_i") == 7);
        assert(tuple.get("Str_s").equals("a"));
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select Str_s, sum(Field_i) as `sum(Field_i)` from collection1 where id='(1 8)' group by Str_s " +
-           "having (sum(Field_i) = 7 OR sum(Field_i) = 60) order by sum(Field_i) desc");
+       sParams = mapParams(CommonParams.QT, "/sql", 
 -          "stmt", "select Str_s, sum(Field_i) from Collection1 where 'id'='(1 8)' group by Str_s having (sum(Field_i) = 7 OR 'sum(Field_i)' = 60) order by 'sum(Field_i)' desc");
++          "stmt", "select Str_s, sum(Field_i) as `sum(Field_i)` from Collection1 where 'id'='(1 8)' group by Str_s having (sum(Field_i) = 7 OR sum(Field_i) = 60) order by sum(Field_i) desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 2);
@@@ -418,12 -754,10 +539,10 @@@
        assert(tuple.get("Str_s").equals("a"));
        assert(tuple.getDouble("sum(Field_i)") == 7);
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select Str_s, sum(Field_i) as `sum(Field_i)` from collection1 where id='(1 8)' group by Str_s " +
-           "having (sum(Field_i) = 7 OR sum(Field_i) = 60) order by sum(Field_i) desc");
+       sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select Str_s, sum(Field_i) from Collection1 where 'id'='(1 8)' group by 'Str_s' having (sum(Field_i) = 7 OR 'sum(Field_i)' = 60) order by 'sum(Field_i)' desc");
++        "stmt", "select Str_s, sum(Field_i) as `sum(Field_i)` from Collection1 where id='(1 8)' group by Str_s having (sum(Field_i) = 7 OR sum(Field_i) = 60) order by sum(Field_i) desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 2);
@@@ -435,8 -769,8 +554,6 @@@
        tuple = tuples.get(1);
        assert(tuple.get("Str_s").equals("a"));
        assert(tuple.getDouble("sum(Field_i)") == 7);
--
--
      } finally {
        delete();
      }
@@@ -483,26 -815,20 +598,20 @@@
        //An exception not detected by the parser thrown from the /select handler
        assert(tuple.getException().contains("sort param field can't be found:"));
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s, count(*), sum(field_iff), min(field_i), max(field_i), " +
-           "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
-           "having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
+       sParams = mapParams(CommonParams.QT, "/sql",
 -          "stmt", "select str_s, count(*), sum(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
++          "stmt", "select str_s, count(*), sum(field_iff), min(field_i), max(field_i), cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuple = getTuple(new ExceptionStream(solrStream));
        assert(tuple.EOF);
        assert(tuple.EXCEPTION);
        //An exception not detected by the parser thrown from the /export handler
        assert(tuple.getException().contains("undefined field:"));
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s, count(*), blah(field_iff), min(field_i), max(field_i), " +
-           "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
-           "having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
+       sParams = mapParams(CommonParams.QT, "/sql",
 -          "stmt", "select str_s, count(*), blah(field_iff), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
++          "stmt", "select str_s, count(*), blah(field_iff), min(field_i), max(field_i), cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s having ((sum(field_iff) = 19) AND (min(field_i) = 8))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuple = getTuple(new ExceptionStream(solrStream));
        assert(tuple.EOF);
        assert(tuple.EXCEPTION);
@@@ -542,12 -867,11 +650,11 @@@
        indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
        indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
        commit();
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), cast(avg(1.0 * field_i) as float)" +
-           " from collection1 where text='XXXX' group by str_s order by sum(field_i) asc limit 2");
 -      
 +
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select str_s, 'count(*)', sum('field_i'), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
++        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s order by sum(field_i) asc limit 2");
+ 
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
        //Only two results because of the limit.
@@@ -565,18 -889,17 +672,16 @@@
  
        tuple = tuples.get(1);
        assert(tuple.get("str_s").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 -
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 27); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 7); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 13.5D); //avg(field_i)
  
+       sParams = mapParams(CommonParams.QT, "/sql",
 -          "stmt", "select str_s as myString, 'count(*)', sum('field_i') as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by sum asc limit 2");
++          "stmt", "select str_s as myString, 'count(*)', sum(field_i) as sum, min(field_i), max(field_i), cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s order by sum asc limit 2");
  
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s as myString, count(*), sum(field_i) as mySum, min(field_i), max(field_i), " +
-           "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s order by mySum asc limit 2");
- 
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        //Only two results because of the limit.
@@@ -592,21 -915,17 +697,20 @@@
  
        tuple = tuples.get(1);
        assert(tuple.get("myString").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 -
 -
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("mySum") == 27);
 +      assert(tuple.getDouble("EXPR$3") == 7); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 13.5D); //avg(field_i)
 +
 +      // TODO fix test - Cannot apply 'NOT' to arguments of type 'NOT<JAVATYPE(CLASS JAVA.LANG.STRING)>'. Supported form(s): 'NOT<BOOLEAN>'
 +      /*
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), "
+       sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
++        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), "
 +          + "cast(avg(1.0 * field_i) as float) from collection1 where (text='XXXX' AND NOT (text='XXXX XXX')) "
 +          + "group by str_s order by str_s desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@@ -632,21 -951,17 +736,20 @@@
  
        tuple = tuples.get(2);
        assert(tuple.get("str_s").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 -
 -
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 27); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 7); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("avg(field_i)") == 13.5D); //avg(field_i)
 +
 +      // TODO fix test - Cannot apply 'NOT' to arguments of type 'NOT<JAVATYPE(CLASS JAVA.LANG.STRING)>'. Supported form(s): 'NOT<BOOLEAN>'
 +      /*
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s as myString, count(*) as myCount, sum(field_i) as mySum, min(field_i) as myMin, "
+       sParams = mapParams(CommonParams.QT, "/sql",
 -          "stmt", "select str_s as myString, count(*) as count, sum(field_i) as sum, min(field_i) as min, max(field_i) as max, avg(field_i) as avg from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
++          "stmt", "select str_s as myString, count(*) as myCount, sum(field_i) as mySum, min(field_i) as myMin, "
 +          + "max(field_i) as myMax, cast(avg(1.0 * field_i) as float) as myAvg from collection1 "
 +          + "where (text='XXXX' AND NOT (text='XXXX XXX')) group by str_s order by str_s desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@@ -672,76 -987,69 +775,71 @@@
  
        tuple = tuples.get(2);
        assert(tuple.get("myString").equals("a"));
 -      assert(tuple.getDouble("count") == 2);
 -      assert(tuple.getDouble("sum") == 27);
 -      assert(tuple.getDouble("min") == 7);
 -      assert(tuple.getDouble("max") == 20);
 -      assert(tuple.getDouble("avg") == 13.5D);
 -
 -
 +      assert(tuple.getDouble("myCount") == 2);
 +      assert(tuple.getDouble("mySum") == 27);
 +      assert(tuple.getDouble("myMin") == 7);
 +      assert(tuple.getDouble("myMax") == 20);
 +      assert(tuple.getDouble("myAvg") == 13.5D);
 +      */
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), cast(avg(1.0 * field_i) as float) " +
+       sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), cast(avg(1.0 * field_i) as float) " +
 +          "from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 1);
  
        tuple = tuples.get(0);
        assert(tuple.get("str_s").equals("b"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 19);
 -      assert(tuple.getDouble("min(field_i)") == 8);
 -      assert(tuple.getDouble("max(field_i)") == 11);
 -      assert(tuple.getDouble("avg(field_i)") == 9.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 19); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 8); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 11); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 9.5D); //avg(field_i)
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), cast(avg(1.0 * field_i) as float) " +
+       sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), cast(avg(1.0 * field_i) as float) " +
 +          "from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 1);
  
        tuple = tuples.get(0);
        assert(tuple.get("str_s").equals("b"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 19);
 -      assert(tuple.getDouble("min(field_i)") == 8);
 -      assert(tuple.getDouble("max(field_i)") == 11);
 -      assert(tuple.getDouble("avg(field_i)") == 9.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 19); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 8); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 11); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 9.5D); //avg(field_i)
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s, count(*), sum(field_i) as mySum, min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql",
 -          "stmt", "select str_s as myString, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by myString having ((sum = 19) AND (min(field_i) = 8))");
++          "stmt", "select str_s, count(*), sum(field_i) as mySum, min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
 +          "having ((sum(field_i) = 19) AND (min(field_i) = 8))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 1);
  
        tuple = tuples.get(0);
 -      assert(tuple.get("myString").equals("b"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum") == 19);
 -      assert(tuple.getDouble("min(field_i)") == 8);
 -      assert(tuple.getDouble("max(field_i)") == 11);
 -      assert(tuple.getDouble("avg(field_i)") == 9.5D);
 -
 +      assert(tuple.get("str_s").equals("b"));
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("mySum") == 19);
 +      assert(tuple.getDouble("EXPR$3") == 8); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 11); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 9.5D); //avg(field_i)
  
- 
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
 +          "having ((sum(field_i) = 19) AND (min(field_i) = 100))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 0);
@@@ -767,12 -1079,10 +865,11 @@@
        indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
        indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
        commit();
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s asc, field_i asc");
 +
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
++          "stmt", "select distinct str_s, field_i from collection1 order by str_s asc, field_i asc");
+ 
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
        assert(tuples.size() == 6);
@@@ -900,14 -1204,11 +991,12 @@@
  
  
        // Test without a sort. Sort should be asc by default.
 -
 +      /*
 +      // TODO figure out what should be sort asc by default (version?)
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select distinct str_s, field_i from collection1");
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+         "stmt", "select distinct str_s, field_i from collection1");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 6);
@@@ -935,15 -1236,14 +1024,13 @@@
        tuple = tuples.get(5);
        assert(tuple.get("str_s").equals("c"));
        assert(tuple.getLong("field_i") == 60);
 -
 +      */
  
        // Test with a predicate.
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
 -
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
++          "stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 2);
@@@ -955,14 -1255,14 +1042,11 @@@
        tuple = tuples.get(1);
        assert(tuple.get("str_s").equals("a"));
        assert(tuple.getLong("field_i") == 20);
--
--
      } finally {
        delete();
      }
    }
  
--
    private void testSelectDistinct() throws Exception {
      try {
  
@@@ -981,11 -1281,11 +1065,11 @@@
        indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
        indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
        commit();
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select distinct str_s, field_i from collection1 order by str_s asc, field_i asc");
 -      
 +
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select distinct 'str_s', 'field_i' from collection1 order by 'str_s' asc, 'field_i' asc");
++          "stmt", "select distinct str_s, field_i from collection1 order by str_s asc, field_i asc");
+ 
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
        assert(tuples.size() == 6);
@@@ -1110,11 -1407,11 +1191,10 @@@
  
  
        // Test without a sort. Sort should be asc by default.
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select distinct str_s, field_i from collection1");
 -
+       sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select distinct str_s, field_i from collection1");
++          "stmt", "select distinct str_s, field_i from collection1");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 6);
@@@ -1144,11 -1441,11 +1224,10 @@@
        assert(tuple.getLong("field_i") == 60);
  
        // Test with a predicate.
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
 -
+       sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
++          "stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 2);
@@@ -1160,8 -1457,8 +1239,6 @@@
        tuple = tuples.get(1);
        assert(tuple.get("str_s").equals("a"));
        assert(tuple.getLong("field_i") == 20);
--
--
      } finally {
        delete();
      }
@@@ -1169,7 -1466,7 +1246,6 @@@
  
    private void testParallelSelectDistinct() throws Exception {
      try {
--
        CloudJettyRunner jetty = this.cloudJettys.get(0);
  
        del("*:*");
@@@ -1317,12 -1608,11 +1385,10 @@@
  
  
        // Test without a sort. Sort should be asc by default.
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", "2");
-       params.put("stmt", "select distinct str_s, field_i from collection1");
 -
+       sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select distinct str_s, field_i from collection1");
++          "stmt", "select distinct str_s, field_i from collection1");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 6);
@@@ -1352,12 -1642,11 +1418,10 @@@
        assert(tuple.getLong("field_i") == 60);
  
        // Test with a predicate.
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", "2");
-       params.put("stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
 -
+       sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
++          "stmt", "select distinct str_s, field_i from collection1 where str_s = 'a'");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 2);
@@@ -1375,11 -1664,11 +1439,8 @@@
      }
    }
  
--
--
    private void testBasicGroupingFacets() throws Exception {
      try {
--
        CloudJettyRunner jetty = this.cloudJettys.get(0);
  
        del("*:*");
@@@ -1395,14 -1684,10 +1456,13 @@@
        indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
        indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
        commit();
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
++
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -      "stmt", "select 'str_s', 'count(*)', sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by 'str_s' order by 'sum(field_i)' asc limit 2");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
 +          "order by sum(field_i) asc limit 2");
  
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
        //Only two results because of the limit.
@@@ -1420,22 -1705,16 +1480,20 @@@
  
        tuple = tuples.get(1);
        assert(tuple.get("str_s").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 -
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 27); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 7); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 13.5D); //avg(field_i)
 +
 +      // TODO fix test - Cannot apply 'NOT' to arguments of type 'NOT<JAVATYPE(CLASS JAVA.LANG.STRING)>'. Supported form(s): 'NOT<BOOLEAN>'
 +      /*
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), "
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by str_s order by str_s desc");
++        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), "
 +          + "cast(avg(1.0 * field_i) as float) from collection1 where (text='XXXX' AND NOT (text='XXXX XXX')) "
 +          + "group by str_s order by str_s desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@@ -1461,21 -1740,16 +1519,19 @@@
  
        tuple = tuples.get(2);
        assert(tuple.get("str_s").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 27); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 7); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 13.5D); //avg(field_i)
  
 +      // TODO fix test - Cannot apply 'NOT' to arguments of type 'NOT<JAVATYPE(CLASS JAVA.LANG.STRING)>'. Supported form(s): 'NOT<BOOLEAN>'
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select str_s as myString, count(*), sum(field_i) as mySum, min(field_i), max(field_i), "
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select str_s as myString, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where (text='XXXX' AND NOT text='XXXX XXX') group by myString order by myString desc");
++        "stmt", "select str_s as myString, count(*), sum(field_i) as mySum, min(field_i), max(field_i), "
 +          + "cast(avg(1.0 * field_i) as float) from collection1 where (text='XXXX' AND NOT (text='XXXX XXX')) "
 +          + "group by str_s order by myString desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@@ -1501,81 -1775,70 +1557,72 @@@
  
        tuple = tuples.get(2);
        assert(tuple.get("myString").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 -
 -
 -
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("mySum") == 27);
 +      assert(tuple.getDouble("EXPR$3") == 7); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 13.5D); //avg(field_i)
 +      */
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having 'sum(field_i)' = 19");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 1);
  
        tuple = tuples.get(0);
        assert(tuple.get("str_s").equals("b"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 19);
 -      assert(tuple.getDouble("min(field_i)") == 8);
 -      assert(tuple.getDouble("max(field_i)") == 11);
 -      assert(tuple.getDouble("avg(field_i)") == 9.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 19); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 8); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 11); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 9.5D); //avg(field_i)
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having (('sum(field_i)' = 19) AND (min(field_i) = 8))");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
 +          "having ((sum(field_i) = 19) AND (min(field_i) = 8))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 1);
  
        tuple = tuples.get(0);
        assert(tuple.get("str_s").equals("b"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 19);
 -      assert(tuple.getDouble("min(field_i)") == 8);
 -      assert(tuple.getDouble("max(field_i)") == 11);
 -      assert(tuple.getDouble("avg(field_i)") == 9.5D);
 -
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 19); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 8); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 11); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 9.5D); //avg(field_i)
  
- 
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select str_s, count(*), sum(field_i) as mySum, min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select str_s myString, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by myString having ((sum = 19) AND (min(field_i) = 8))");
++          "stmt",  "select str_s, count(*), sum(field_i) as mySum, min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
 +          "having ((sum(field_i) = 19) AND (min(field_i) = 8))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 1);
  
        tuple = tuples.get(0);
 -      assert(tuple.get("myString").equals("b"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum") == 19);
 -      assert(tuple.getDouble("min(field_i)") == 8);
 -      assert(tuple.getDouble("max(field_i)") == 11);
 -      assert(tuple.getDouble("avg(field_i)") == 9.5D);
 +      assert(tuple.get("str_s").equals("b"));
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("mySum") == 19);
 +      assert(tuple.getDouble("EXPR$3") == 8); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 11); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 9.5D); //avg(field_i)
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
 +          "having ((sum(field_i) = 19) AND (min(field_i) = 100))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 0);
@@@ -1601,14 -1871,10 +1648,13 @@@
        indexr("id", "7", "text", "XXXX XXXX", "str_s", "c", "field_i", "50");
        indexr("id", "8", "text", "XXXX XXXX", "str_s", "c", "field_i", "60");
        commit();
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", "2");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
++
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by sum(field_i) asc limit 2");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
 +          "order by sum(field_i) asc limit 2");
  
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
        //Only two results because of the limit.
@@@ -1626,20 -1892,16 +1672,18 @@@
  
        tuple = tuples.get(1);
        assert(tuple.get("str_s").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 27); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 7);  //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 13.5D); //avg(field_i)
 +
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", "2");
-       params.put("stmt", "select str_s, count(*), sum(field_i) as mySum, min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select str_s, count(*), sum(field_i) as sum, min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by sum asc limit 2");
++          "stmt", "select str_s, count(*), sum(field_i) as mySum, min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s order by mySum asc limit 2");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        //Only two results because of the limit.
@@@ -1655,20 -1917,17 +1699,18 @@@
  
        tuple = tuples.get(1);
        assert(tuple.get("str_s").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("mySum") == 27);
 +      assert(tuple.getDouble("EXPR$3") == 7); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 13.5D); //avg(field_i)
  
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", "2");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s order by str_s desc");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s order by str_s desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@@ -1694,20 -1953,17 +1736,18 @@@
  
        tuple = tuples.get(2);
        assert(tuple.get("str_s").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 27); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 7); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 13.5D); //avg(field_i)
  
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", "2");
-       params.put("stmt", "select str_s as myString, count(*), sum(field_i), min(field_i), max(field_i), " +
 -      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",                           
 -        "stmt", "select str_s as myString, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by myString order by myString desc");
++      sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
++          "stmt", "select str_s as myString, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s order by myString desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        //The sort by and order by match and no limit is applied. All the Tuples should be returned in
@@@ -1733,64 -1989,63 +1773,57 @@@
  
        tuple = tuples.get(2);
        assert(tuple.get("myString").equals("a"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 27);
 -      assert(tuple.getDouble("min(field_i)") == 7);
 -      assert(tuple.getDouble("max(field_i)") == 20);
 -      assert(tuple.getDouble("avg(field_i)") == 13.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 27); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 7); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 20); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 13.5D); //avg(field_i)
  
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", "2");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s having sum(field_i) = 19");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 1);
  
        tuple = tuples.get(0);
        assert(tuple.get("str_s").equals("b"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 19);
 -      assert(tuple.getDouble("min(field_i)") == 8);
 -      assert(tuple.getDouble("max(field_i)") == 11);
 -      assert(tuple.getDouble("avg(field_i)") == 9.5D);
 -
 -      tuple = tuples.get(0);
 -      assert(tuple.get("str_s").equals("b"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 19);
 -      assert(tuple.getDouble("min(field_i)") == 8);
 -      assert(tuple.getDouble("max(field_i)") == 11);
 -      assert(tuple.getDouble("avg(field_i)") == 9.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 19); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 8); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 11); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 9.5D); //avg(field_i)
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", "2");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 8))");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
 +          "having ((sum(field_i) = 19) AND (min(field_i) = 8))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 1);
  
        tuple = tuples.get(0);
        assert(tuple.get("str_s").equals("b"));
 -      assert(tuple.getDouble("count(*)") == 2);
 -      assert(tuple.getDouble("sum(field_i)") == 19);
 -      assert(tuple.getDouble("min(field_i)") == 8);
 -      assert(tuple.getDouble("max(field_i)") == 11);
 -      assert(tuple.getDouble("avg(field_i)") == 9.5D);
 +      assert(tuple.getDouble("EXPR$1") == 2); //count(*)
 +      assert(tuple.getDouble("EXPR$2") == 19); //sum(field_i)
 +      assert(tuple.getDouble("EXPR$3") == 8); //min(field_i)
 +      assert(tuple.getDouble("EXPR$4") == 11); //max(field_i)
 +      assert(tuple.getDouble("EXPR$5") == 9.5D); //avg(field_i)
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", "2");
-       params.put("stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
+       sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), avg(field_i) from collection1 where text='XXXX' group by str_s having ((sum(field_i) = 19) AND (min(field_i) = 100))");
++          "stmt", "select str_s, count(*), sum(field_i), min(field_i), max(field_i), " +
 +          "cast(avg(1.0 * field_i) as float) from collection1 where text='XXXX' group by str_s " +
 +          "having ((sum(field_i) = 19) AND (min(field_i) = 100))");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
        assert(tuples.size() == 0);
--
      } finally {
        delete();
      }
@@@ -1798,7 -2053,7 +1831,6 @@@
  
  
    private void testAggregatesWithoutGrouping() throws Exception {
--
      CloudJettyRunner jetty = this.cloudJettys.get(0);
  
      del("*:*");
@@@ -1818,13 -2073,11 +1850,11 @@@
  
      commit();
  
-     Map params = new HashMap();
-     params.put(CommonParams.QT, "/sql");
-     params.put("stmt", "select count(*), sum(a_i), min(a_i), max(a_i), cast(avg(1.0 * a_i) as float), sum(a_f), " +
 -    SolrParams sParams = mapParams(CommonParams.QT, "/sql", "stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1");
++    SolrParams sParams = mapParams(CommonParams.QT, "/sql", "stmt", "select count(*), sum(a_i), min(a_i), max(a_i), cast(avg(1.0 * a_i) as float), sum(a_f), " +
 +        "min(a_f), max(a_f), avg(a_f) from collection1");
  
-     SolrStream solrStream = new SolrStream(jetty.url, params);
+     SolrStream solrStream = new SolrStream(jetty.url, sParams);
  
 -
      List<Tuple> tuples = getTuples(solrStream);
  
      assert(tuples.size() == 1);
@@@ -1833,33 -2086,32 +1863,31 @@@
  
      Tuple tuple = tuples.get(0);
  
 -    Double sumi = tuple.getDouble("sum(a_i)");
 -    Double sumf = tuple.getDouble("sum(a_f)");
 -    Double mini = tuple.getDouble("min(a_i)");
 -    Double minf = tuple.getDouble("min(a_f)");
 -    Double maxi = tuple.getDouble("max(a_i)");
 -    Double maxf = tuple.getDouble("max(a_f)");
 -    Double avgi = tuple.getDouble("avg(a_i)");
 -    Double avgf = tuple.getDouble("avg(a_f)");
 -    Double count = tuple.getDouble("count(*)");
 -
 -    assertTrue(sumi.longValue() == 70);
 -    assertTrue(sumf.doubleValue() == 55.0D);
 -    assertTrue(mini.doubleValue() == 0.0D);
 -    assertTrue(minf.doubleValue() == 1.0D);
 -    assertTrue(maxi.doubleValue() == 14.0D);
 -    assertTrue(maxf.doubleValue() == 10.0D);
 -    assertTrue(avgi.doubleValue() == 7.0D);
 -    assertTrue(avgf.doubleValue() == 5.5D);
 -    assertTrue(count.doubleValue() == 10);
 -
 -
 +    Double count = tuple.getDouble("EXPR$0"); //count(*)
 +    Double sumi = tuple.getDouble("EXPR$1"); //sum(a_i)
 +    Double mini = tuple.getDouble("EXPR$2"); //min(a_i)
 +    Double maxi = tuple.getDouble("EXPR$3"); //max(a_i)
 +    Double avgi = tuple.getDouble("EXPR$4"); //avg(a_i)
 +    Double sumf = tuple.getDouble("EXPR$5"); //sum(a_f)
 +    Double minf = tuple.getDouble("EXPR$6"); //min(a_f)
 +    Double maxf = tuple.getDouble("EXPR$7"); //max(a_f)
 +    Double avgf = tuple.getDouble("EXPR$8"); //avg(a_f)
 +
 +    assertTrue(count == 10);
 +    assertTrue(sumi == 70);
 +    assertTrue(mini == 0.0D);
 +    assertTrue(maxi == 14.0D);
 +    assertTrue(avgi == 7.0D);
 +    assertTrue(sumf == 55.0D);
 +    assertTrue(minf == 1.0D);
 +    assertTrue(maxf == 10.0D);
 +    assertTrue(avgf == 5.5D);
  
-     params = new HashMap();
-     params.put(CommonParams.QT, "/sql");
-     params.put("stmt", "select count(*) as myCount, sum(a_i) as mySum, min(a_i) as myMin, max(a_i) as myMax, " +
+     sParams = mapParams(CommonParams.QT, "/sql",
 -      "stmt", "select count(*) as count, sum(a_i) as sum, min(a_i) as min, max(a_i) as max, avg(a_i) as avg, sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1");
++        "stmt", "select count(*) as myCount, sum(a_i) as mySum, min(a_i) as myMin, max(a_i) as myMax, " +
 +        "cast(avg(1.0 * a_i) as float) as myAvg, sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1");
  
-     solrStream = new SolrStream(jetty.url, params);
- 
+     solrStream = new SolrStream(jetty.url, sParams);
  
      tuples = getTuples(solrStream);
  
@@@ -1869,33 -2121,35 +1897,32 @@@
  
      tuple = tuples.get(0);
  
 -    sumi = tuple.getDouble("sum");
 -    sumf = tuple.getDouble("sum(a_f)");
 -    mini = tuple.getDouble("min");
 -    minf = tuple.getDouble("min(a_f)");
 -    maxi = tuple.getDouble("max");
 -    maxf = tuple.getDouble("max(a_f)");
 -    avgi = tuple.getDouble("avg");
 -    avgf = tuple.getDouble("avg(a_f)");
 -    count = tuple.getDouble("count");
 -
 -    assertTrue(sumi.longValue() == 70);
 -    assertTrue(sumf.doubleValue() == 55.0D);
 -    assertTrue(mini.doubleValue() == 0.0D);
 -    assertTrue(minf.doubleValue() == 1.0D);
 -    assertTrue(maxi.doubleValue() == 14.0D);
 -    assertTrue(maxf.doubleValue() == 10.0D);
 -    assertTrue(avgi.doubleValue() == 7.0D);
 -    assertTrue(avgf.doubleValue() == 5.5D);
 -    assertTrue(count.doubleValue() == 10);
 -
 -
 -
 +    count = tuple.getDouble("myCount");
 +    sumi = tuple.getDouble("mySum");
 +    mini = tuple.getDouble("myMin");
 +    maxi = tuple.getDouble("myMax");
 +    avgi = tuple.getDouble("myAvg");
 +    sumf = tuple.getDouble("EXPR$5"); //sum(a_f)
 +    minf = tuple.getDouble("EXPR$6"); //min(a_f)
 +    maxf = tuple.getDouble("EXPR$7"); //max(a_f)
 +    avgf = tuple.getDouble("EXPR$8"); //avg(a_f)
 +
 +    assertTrue(count == 10);
 +    assertTrue(mini == 0.0D);
 +    assertTrue(maxi == 14.0D);
 +    assertTrue(sumi == 70);
 +    assertTrue(avgi == 7.0D);
 +    assertTrue(sumf == 55.0D);
 +    assertTrue(minf == 1.0D);
 +    assertTrue(maxf == 10.0D);
 +    assertTrue(avgf == 5.5D);
  
      // Test where clause hits
-     params = new HashMap();
-     params.put(CommonParams.QT, "/sql");
-     params.put("stmt", "select count(*), sum(a_i), min(a_i), max(a_i), cast(avg(1.0 * a_i) as float), sum(a_f), " +
 -
+     sParams = mapParams(CommonParams.QT, "/sql",
 -      "stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where id = 2");
++        "stmt", "select count(*), sum(a_i), min(a_i), max(a_i), cast(avg(1.0 * a_i) as float), sum(a_f), " +
 +        "min(a_f), max(a_f), avg(a_f) from collection1 where id = 2");
  
-     solrStream = new SolrStream(jetty.url, params);
+     solrStream = new SolrStream(jetty.url, sParams);
  
      tuples = getTuples(solrStream);
  
@@@ -1925,12 -2179,11 +1952,11 @@@
  
  
      // Test zero hits
-     params = new HashMap();
-     params.put(CommonParams.QT, "/sql");
-     params.put("stmt", "select count(*), sum(a_i), min(a_i), max(a_i), cast(avg(1.0 * a_i) as float), sum(a_f), " +
 -
+     sParams = mapParams(CommonParams.QT, "/sql",
 -      "stmt", "select count(*), sum(a_i), min(a_i), max(a_i), avg(a_i), sum(a_f), min(a_f), max(a_f), avg(a_f) from collection1 where a_s = 'blah'");
++        "stmt", "select count(*), sum(a_i), min(a_i), max(a_i), cast(avg(1.0 * a_i) as float), sum(a_f), " +
 +        "min(a_f), max(a_f), avg(a_f) from collection1 where a_s = 'blah'");
  
-     solrStream = new SolrStream(jetty.url, params);
+     solrStream = new SolrStream(jetty.url, sParams);
  
      tuples = getTuples(solrStream);
  
@@@ -1962,9 -2215,12 +1988,8 @@@
      commit();
    }
  
 -
 -
 -
    private void testTimeSeriesGrouping() throws Exception {
      try {
--
        CloudJettyRunner jetty = this.cloudJettys.get(0);
  
        del("*:*");
@@@ -1981,14 -2237,13 +2006,13 @@@
        indexr("id", "8", "year_i", "2014", "month_i", "4",  "day_i", "2", "item_i", "1");
  
        commit();
 +
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
++          "stmt",  "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
  
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 2);
  
        Tuple tuple = null;
@@@ -1999,14 -2254,15 +2023,15 @@@
  
        tuple = tuples.get(1);
        assert(tuple.getLong("year_i") == 2014);
 -      assert(tuple.getDouble("sum(item_i)") == 7);
 +      assert(tuple.getDouble("EXPR$1") == 7); //sum(item_i)
  
-       params.put("stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i " +
+       sParams = mapParams(CommonParams.QT, "/sql",
 -          "stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
++          "stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i " +
 +          "order by year_i desc, month_i desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 3);
  
        tuple = null;
@@@ -2024,16 -2280,15 +2049,15 @@@
        tuple = tuples.get(2);
        assert(tuple.getLong("year_i") == 2014);
        assert(tuple.getLong("month_i") == 4);
 -      assert(tuple.getDouble("sum(item_i)") == 7);
 +      assert(tuple.getDouble("EXPR$2") == 7); //sum(item_i)
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i " +
+       sParams = mapParams(CommonParams.QT, "/sql",
 -        "stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
++          "stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i " +
 +          "order by year_i desc, month_i desc, day_i desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 6);
  
        tuple = null;
@@@ -2099,14 -2354,13 +2123,12 @@@
        indexr("id", "8", "year_i", "2014", "month_i", "4", "day_i", "2", "item_i", "1");
  
        commit();
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
+         "stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
  
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 2);
  
        Tuple tuple = null;
@@@ -2117,18 -2371,16 +2139,16 @@@
  
        tuple = tuples.get(1);
        assert(tuple.getLong("year_i") == 2014);
 -      assert(tuple.getDouble("sum(item_i)") == 7);
 +      assert(tuple.getDouble("EXPR$1") == 7); //sum(item_i)
  
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i " +
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
++          "stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i " +
 +          "order by year_i desc, month_i desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 3);
  
        tuple = tuples.get(0);
@@@ -2144,18 -2396,16 +2164,16 @@@
        tuple = tuples.get(2);
        assert(tuple.getLong("year_i") == 2014);
        assert(tuple.getLong("month_i") == 4);
 -      assert(tuple.getDouble("sum(item_i)") == 7);
 +      assert(tuple.getDouble("EXPR$2") == 7); //sum(item_i)
  
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("aggregationMode", "facet");
-       params.put("stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i " +
+       sParams = mapParams(CommonParams.QT, "/sql", "aggregationMode", "facet",
 -        "stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
++          "stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i " +
 +          "order by year_i desc, month_i desc, day_i desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 6);
  
        tuple = tuples.get(0);
@@@ -2200,7 -2450,7 +2218,6 @@@
  
    private void testParallelTimeSeriesGrouping() throws Exception {
      try {
--
        CloudJettyRunner jetty = this.cloudJettys.get(0);
  
        del("*:*");
@@@ -2217,14 -2467,13 +2234,12 @@@
        indexr("id", "8", "year_i", "2014", "month_i", "4", "day_i", "2", "item_i", "1");
  
        commit();
-       Map params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", 2);
-       params.put("stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
+       SolrParams sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2", 
+           "stmt", "select year_i, sum(item_i) from collection1 group by year_i order by year_i desc");
  
-       SolrStream solrStream = new SolrStream(jetty.url, params);
+       SolrStream solrStream = new SolrStream(jetty.url, sParams);
        List<Tuple> tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 2);
  
        Tuple tuple = null;
@@@ -2236,17 -2485,15 +2251,15 @@@
  
        tuple = tuples.get(1);
        assert(tuple.getLong("year_i") == 2014);
 -      assert(tuple.getDouble("sum(item_i)") == 7);
 +      assert(tuple.getDouble("EXPR$1") == 7); //sum(item_i)
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", 2);
-       params.put("stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i " +
+       sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i order by year_i desc, month_i desc");
++          "stmt", "select year_i, month_i, sum(item_i) from collection1 group by year_i, month_i " +
 +          "order by year_i desc, month_i desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 3);
  
        tuple = null;
@@@ -2266,18 -2513,16 +2279,16 @@@
        tuple = tuples.get(2);
        assert(tuple.getLong("year_i") == 2014);
        assert(tuple.getLong("month_i") == 4);
 -      assert(tuple.getDouble("sum(item_i)") == 7);
 +      assert(tuple.getDouble("EXPR$2") == 7); //sum(item_i)
  
  
-       params = new HashMap();
-       params.put(CommonParams.QT, "/sql");
-       params.put("numWorkers", 2);
-       params.put("stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i " +
+       sParams = mapParams(CommonParams.QT, "/sql", "numWorkers", "2",
 -        "stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i order by year_i desc, month_i desc, day_i desc");
++          "stmt", "select year_i, month_i, day_i, sum(item_i) from collection1 group by year_i, month_i, day_i " +
 +          "order by year_i desc, month_i desc, day_i desc");
  
-       solrStream = new SolrStream(jetty.url, params);
+       solrStream = new SolrStream(jetty.url, sParams);
        tuples = getTuples(solrStream);
  
 -      //Only two results because of the limit.
        assert(tuples.size() == 6);
  
        tuple = null;


Mime
View raw message