lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject [2/2] lucene-solr:branch_6x: SOLR-8940: Fix group.sort option
Date Tue, 31 May 2016 23:53:09 GMT
SOLR-8940: Fix group.sort option

(cherry picked from commit 18256fc2873f198e8e577c6eb0f337df1d1cda24)


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

Branch: refs/heads/branch_6x
Commit: 22faa09882f818ce5f91d0230d84f7dc8cc1c084
Parents: 6662cdc
Author: Chris Hostetter <hossman@apache.org>
Authored: Tue May 31 16:12:24 2016 -0700
Committer: Chris Hostetter <hossman@apache.org>
Committed: Tue May 31 16:12:55 2016 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 ++
 .../TopGroupsResultTransformer.java             |  2 +-
 .../apache/solr/TestDistributedGrouping.java    | 34 +++++++++++++++++++-
 3 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/22faa098/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 70d4b12..b818345 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -214,6 +214,8 @@ Bug Fixes
 * SOLR-9165: Spellcheck does not return collations if "maxCollationTries" is used with "cursorMark".
   (James Dyer)
 
+* SOLR-8940: Fix group.sort option (hossman)
+
 Optimizations
 ----------------------
 * SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/22faa098/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java
b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java
index f65bcf2..37e837e 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/TopGroupsResultTransformer.java
@@ -134,7 +134,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
 
         @SuppressWarnings("unchecked")
         List<NamedList<Object>> documents = (List<NamedList<Object>>)
groupResult.get("documents");
-        ScoreDoc[] scoreDocs = transformToNativeShardDoc(documents, groupSort, shard, schema);
+        ScoreDoc[] scoreDocs = transformToNativeShardDoc(documents, sortWithinGroup, shard,
schema);
 
         BytesRef groupValueRef = groupValue != null ? new BytesRef(groupValue) : null;
         groupDocs.add(new GroupDocs<>(Float.NaN, maxScore, totalGroupHits, scoreDocs,
groupValueRef, null));

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/22faa098/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java b/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java
index 5d19fd6..af42ff4 100644
--- a/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java
+++ b/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java
@@ -23,9 +23,11 @@ import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.SolrDocumentList;
 import org.junit.Test;
 
 import java.io.IOException;
+import java.util.List;
 
 /**
  * TODO? perhaps use:
@@ -44,7 +46,7 @@ public class TestDistributedGrouping extends BaseDistributedSearchTestCase
{
   String tlong = "other_tl1";
   String tdate_a = "a_n_tdt";
   String tdate_b = "b_n_tdt";
-  String oddField="oddField_s";
+  String oddField="oddField_s1";
 
   @Test
   public void test() throws Exception {
@@ -265,6 +267,36 @@ public class TestDistributedGrouping extends BaseDistributedSearchTestCase
{
     query("q", "{!func}id", "rows", 100, "fl", "score,id," + i1, "group", "true", "group.field",
i1, "group.limit", 10, "sort", "score desc, _docid_ asc, id asc");
     query("q", "{!func}id", "rows", 100, "fl", "score,id," + i1, "group", "true", "group.field",
i1, "group.limit", 10);
 
+    // some explicit checks of non default sorting, and sort/group.sort with diff clauses
+    query("q", "{!func}id", "rows", 100, "fl", tlong + ",id," + i1, "group", "true",
+          "group.field", i1, "group.limit", 10,
+          "sort", tlong+" asc, id desc");
+    query("q", "{!func}id", "rows", 100, "fl", tlong + ",id," + i1, "group", "true",
+          "group.field", i1, "group.limit", 10,
+          "sort", "id asc",
+          "group.sort", tlong+" asc, id desc");
+    query("q", "{!func}id", "rows", 100, "fl", tlong + ",id," + i1, "group", "true",
+          "group.field", i1, "group.limit", 10,
+          "sort", tlong+" asc, id desc",
+          "group.sort", "id asc");
+    rsp = query("q", "{!func}id", "fq", oddField+":[* TO *]",
+                "rows", 100, "fl", tlong + ",id," + i1, "group", "true",
+                "group.field", i1, "group.limit", 10,
+                "sort", tlong+" asc",
+                "group.sort", oddField+" asc");
+    nl = (NamedList<?>) rsp.getResponse().get("grouped");
+    nl = (NamedList<?>) nl.get(i1);
+    assertEquals(rsp.toString(), 6, nl.get("matches"));
+    assertEquals(rsp.toString(), 2, ((List<NamedList<?>>)nl.get("groups")).size());
+    nl = ((List<NamedList<?>>)nl.get("groups")).get(0);
+    assertEquals(rsp.toString(), 232, nl.get("groupValue"));
+    SolrDocumentList docs = (SolrDocumentList) nl.get("doclist");
+    assertEquals(docs.toString(), 5, docs.getNumFound());
+    assertEquals(docs.toString(), 22, docs.get(0).getFirstValue("id"));
+    assertEquals(docs.toString(), 21, docs.get(4).getFirstValue("id"));
+
+    
+
     // Can't validate the response, but can check if no errors occur.
     simpleQuery("q", "*:*", "rows", 100, "fl", "id," + i1, "group", "true", "group.query",
t1 + ":kings OR " + t1 + ":eggs", "group.limit", 10, "sort", i1 + " asc, id asc", CommonParams.TIME_ALLOWED,
1);
     


Mime
View raw message