lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject lucene-solr:jira/solr-8593: Fix sorts when grouping
Date Wed, 04 May 2016 16:18:07 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/jira/solr-8593 9e6f0b7a2 -> a414d2468


Fix sorts when grouping


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

Branch: refs/heads/jira/solr-8593
Commit: a414d246842837b99596e4b575afc73117df5e31
Parents: 9e6f0b7
Author: Kevin Risden <krisden@apache.org>
Authored: Wed May 4 11:18:05 2016 -0500
Committer: Kevin Risden <krisden@apache.org>
Committed: Wed May 4 11:18:05 2016 -0500

----------------------------------------------------------------------
 .../org/apache/solr/handler/sql/SolrTable.java  | 21 +++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/a414d246/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java b/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
index d937d09..167dc95 100644
--- a/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
+++ b/solr/core/src/java/org/apache/solr/handler/sql/SolrTable.java
@@ -94,27 +94,34 @@ class SolrTable extends AbstractQueryableTable implements TranslatableTable
{
 
     // List<String> doesn't have add so must make a new ArrayList
     List<String> fieldsList = new ArrayList<>(fields);
+    List<String> orderList = new ArrayList<>(order);
 
-    if (order.isEmpty()) {
-      if(limit != null && Integer.parseInt(limit) > -1) {
-        solrParams.put(CommonParams.SORT, DEFAULT_SCORE_FIELD + " desc");
+    if (!metrics.isEmpty()) {
+      for(String bucket : buckets) {
+        orderList.add(bucket + " desc");
+      }
+    }
+
+    if (orderList.isEmpty()) {
+      if (limit != null && Integer.parseInt(limit) > -1) {
+        orderList.add(DEFAULT_SCORE_FIELD + " desc");
 
         // Make sure the default score field is in the field list
         if (!fieldsList.contains(DEFAULT_SCORE_FIELD)) {
           fieldsList.add(DEFAULT_SCORE_FIELD);
         }
       } else {
-        solrParams.put(CommonParams.SORT, DEFAULT_VERSION_FIELD + " desc");
+        orderList.add(DEFAULT_VERSION_FIELD + " desc");
 
         // Make sure the default sort field is in the field list
         if (!fieldsList.contains(DEFAULT_VERSION_FIELD)) {
           fieldsList.add(DEFAULT_VERSION_FIELD);
         }
       }
-    } else {
-      solrParams.put(CommonParams.SORT, String.join(",", order));
     }
 
+    solrParams.put(CommonParams.SORT, String.join(",", orderList));
+
     if (fieldsList.isEmpty()) {
       solrParams.put(CommonParams.FL, "*");
     } else {
@@ -124,7 +131,7 @@ class SolrTable extends AbstractQueryableTable implements TranslatableTable
{
     TupleStream tupleStream;
     String zk = properties.getProperty("zk");
     try {
-      if(metrics.isEmpty()) {
+      if (metrics.isEmpty()) {
         if (limit == null) {
           solrParams.put(CommonParams.QT, "/export");
           tupleStream = new CloudSolrStream(zk, collection, solrParams);


Mime
View raw message