Apache Lucene open-source search software
SOLR-4330: group.sort is ignored when using group.truncate and ex/tag local params together
Koji Sekiguchiae7624887039
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex b916a12fc60..c56e6886d75 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -68,6 +68,9 @@ Bug Fixes* SOLR-4309: /browse: Improve JQuery autosuggest behavior (janhoy)+* SOLR-4330: group.sort is ignored when using group.truncate and ex/tag+ local params together (koji)+Optimizations----------------------diff --git a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java b/solr/core/src/java/org/apache/solr/request/SimpleFacets.javaindex 369fdae071a..fda08fe426f 100644--- a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java+++ b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java@@ -160,6 +160,7 @@ public class SimpleFacets {DocSet base = searcher.getDocSet(qlist);if (rb.grouping() && rb.getGroupingSpec().isTruncateGroups()) {Grouping grouping = new Grouping(searcher, null, rb.getQueryCommand(), false, 0, false);+ grouping.setGroupSort(rb.getGroupingSpec().getSortWithinGroup());if (rb.getGroupingSpec().getFields().length > 0) {grouping.addFieldCommand(rb.getGroupingSpec().getFields()[0], req);} else if (rb.getGroupingSpec().getFunctions().length > 0) {diff --git a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java b/solr/core/src/test/org/apache/solr/TestGroupingSearch.javaindex 98c6ebee779..61ca2b9340d 100644--- a/solr/core/src/test/org/apache/solr/TestGroupingSearch.java+++ b/solr/core/src/test/org/apache/solr/TestGroupingSearch.java@@ -360,6 +360,29 @@ public class TestGroupingSearch extends SolrTestCaseJ4 {);}+ @Test+ public void testGroupingGroupedBasedFacetingWithTaggedFilter() throws Exception {+ assertU(add(doc("id", "1", "cat_sI", "a", "bday", "2012-11-20T00:00:00Z")));+ assertU(add(doc("id", "2", "cat_sI", "b", "bday", "2012-11-21T00:00:00Z")));+ assertU(add(doc("id", "3", "cat_sI", "a", "bday", "2012-11-20T00:00:00Z")));+ assertU(add(doc("id", "4", "cat_sI", "b", "bday", "2013-01-15T00:00:00Z")));+ assertU(add(doc("id", "5", "cat_sI", "a", "bday", "2013-01-14T00:00:00Z")));+ assertU(commit());++ // Facet counts based on groups+ SolrQueryRequest req = req("q", "*:*", "rows", "1", "group", "true", "group.field", "cat_sI",+ "sort", "cat_sI asc", "fl", "id", "fq", "{!tag=chk}bday:[2012-12-18T00:00:00Z TO 2013-01-17T23:59:59Z]",+ "facet", "true", "group.truncate", "true", "group.sort", "bday desc",+ "facet.query", "{!ex=chk key=LW1}bday:[2013-01-11T00:00:00Z TO 2013-01-17T23:59:59Z]",+ "facet.query", "{!ex=chk key=LM1}bday:[2012-12-18T00:00:00Z TO 2013-01-17T23:59:59Z]",+ "facet.query", "{!ex=chk key=LM3}bday:[2012-10-18T00:00:00Z TO 2013-01-17T23:59:59Z]");+ assertJQ(+ req,+ "/grouped=={'cat_sI':{'matches':2,'groups':[{'groupValue':'a','doclist':{'numFound':1,'start':0,'docs':[{'id':'5'}]}}]}}",+ "/facet_counts=={'facet_queries':{'LW1':2,'LM1':2,'LM3':2},'facet_fields':{},'facet_dates':{},'facet_ranges':{}}"+ );+ }+static String f = "foo_i";static String f2 = "foo2_i";