lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1146296 - in /lucene/dev/branches/branch_3x/solr: CHANGES.txt core/src/java/org/apache/solr/handler/component/QueryComponent.java core/src/test/org/apache/solr/TestGroupingSearch.java
Date Wed, 13 Jul 2011 19:40:01 GMT
Author: mvg
Date: Wed Jul 13 19:40:01 2011
New Revision: 1146296

URL: http://svn.apache.org/viewvc?rev=1146296&view=rev
Log:
SOLR-2642: Fixed sorting by function when using grouping.

Modified:
    lucene/dev/branches/branch_3x/solr/CHANGES.txt
    lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
    lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/TestGroupingSearch.java

Modified: lucene/dev/branches/branch_3x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/CHANGES.txt?rev=1146296&r1=1146295&r2=1146296&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Wed Jul 13 19:40:01 2011
@@ -96,7 +96,9 @@ Bug Fixes
   if there are documents to display.
 
 * SOLR-2564: Fixed ArrayIndexOutOfBoundsException when using simple format and start >
0
- 
+
+* SOLR-2642: Fixed sorting by function when using grouping. (Thomas Heigl, Martijn van Groningen)
+
  Other Changes
 ----------------------
 

Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java?rev=1146296&r1=1146295&r2=1146296&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
(original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
Wed Jul 13 19:40:01 2011
@@ -201,9 +201,9 @@ public class QueryComponent extends Sear
 
         boolean includeTotalGroupCount = params.getBool(GroupParams.GROUP_TOTAL_COUNT, false);
         Grouping.TotalCount defaultTotalCount = includeTotalGroupCount ? Grouping.TotalCount.grouped
: Grouping.TotalCount.ungrouped;
-        Sort sort = cmd.getSort();
+        Sort sort = searcher.weightSort(cmd.getSort());
         // groupSort defaults to sort
-        Sort groupSort = groupSortStr == null ? cmd.getSort() : QueryParsing.parseSort(groupSortStr,
req);
+        Sort groupSort = groupSortStr == null ?  sort : searcher.weightSort(QueryParsing.parseSort(groupSortStr,
req));
 
         int limitDefault = cmd.getLen(); // this is normally from "rows"
         int groupOffsetDefault = params.getInt(GroupParams.GROUP_OFFSET, 0);

Modified: lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/TestGroupingSearch.java?rev=1146296&r1=1146295&r2=1146296&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
(original)
+++ lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/TestGroupingSearch.java
Wed Jul 13 19:40:01 2011
@@ -242,6 +242,26 @@ public class TestGroupingSearch extends 
     );
   }
 
+  @Test
+  public void testGroupingSortByFunction() throws Exception {
+    assertU(add(doc("id", "1", "value1_i", "1", "value2_i", "1", "store", "45.18014,-93.87742")));
+    assertU(add(doc("id", "2", "value1_i", "1", "value2_i", "2", "store", "45.18014,-93.87743")));
+    assertU(add(doc("id", "3", "value1_i", "1", "value2_i", "3", "store", "45.18014,-93.87744")));
+    assertU(add(doc("id", "4", "value1_i", "1", "value2_i", "4", "store", "45.18014,-93.87745")));
+    assertU(add(doc("id", "5", "value1_i", "1", "value2_i", "5", "store", "45.18014,-93.87746")));
+    assertU(commit());
+
+    assertJQ(
+        req("q", "*:*", "sort", "sum(value1_i, value2_i) desc", "rows", "1", "group", "true",
"group.field", "id", "fl", "id"),
+        "/grouped=={'id':{'matches':5,'groups':[{'groupValue':'5','doclist':{'numFound':1,'start':0,'docs':[{'id':'5'}]}}]}}"
+    );
+
+    assertJQ(
+        req("q", "*:*", "sort", "geodist(45.18014,-93.87742,store) asc", "rows", "1", "group",
"true", "group.field", "id", "fl", "id"),
+        "/grouped=={'id':{'matches':5,'groups':[{'groupValue':'1','doclist':{'numFound':1,'start':0,'docs':[{'id':'1'}]}}]}}"
+    );
+  }
+
   static String f = "foo_s1";
   static String f2 = "foo2_i";
 



Mime
View raw message