lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject [1/3] lucene-solr:jira/solr-6203: SOLR-6203: applied Judith Silverman's latest patch to working branch
Date Thu, 01 Dec 2016 21:02:19 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/jira/solr-6203 859eb0837 -> 6476f2867


SOLR-6203: applied Judith Silverman's latest patch to working branch


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

Branch: refs/heads/jira/solr-6203
Commit: 99e2e3d42400558aa1f404f27dd4e15350a85559
Parents: 859eb08
Author: Christine Poerschke <cpoerschke@apache.org>
Authored: Thu Dec 1 20:51:47 2016 +0000
Committer: Christine Poerschke <cpoerschke@apache.org>
Committed: Thu Dec 1 20:51:47 2016 +0000

----------------------------------------------------------------------
 .../solr/handler/component/QueryComponent.java  | 24 ++++----
 .../component/QueryElevationComponent.java      |  4 +-
 .../apache/solr/search/grouping/Command.java    | 23 ++++++++
 .../search/grouping/GroupingSpecification.java  | 18 +++---
 .../distributed/command/QueryCommand.java       |  8 +++
 .../command/SearchGroupsFieldCommand.java       | 52 +++++++++++++----
 .../command/TopGroupsFieldCommand.java          | 59 ++++++++++++++------
 .../SearchGroupShardResponseProcessor.java      | 13 +++--
 .../TopGroupsShardResponseProcessor.java        | 17 +++---
 .../SearchGroupsResultTransformer.java          | 13 +++--
 .../ShardResultTransformer.java                 |  8 +--
 .../TopGroupsResultTransformer.java             | 20 ++++---
 12 files changed, 177 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
index 84ade43..4b20d91 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
@@ -255,23 +255,23 @@ public class QueryComponent extends SearchComponent
     final SortSpec groupSortSpec = searcher.weightSortSpec(sortSpec, Sort.RELEVANCE);
 
     // groupSort defaults to sort
-    String sortWithinGroupStr = params.get(GroupParams.GROUP_SORT);
+    String withinGroupSortStr = params.get(GroupParams.GROUP_SORT);
     //TODO: move weighting of sort
-    final SortSpec sortSpecWithinGroup;
-    if (sortWithinGroupStr != null) {
-      SortSpec parsedSortSpecWithinGroup = SortSpecParsing.parseSortSpec(sortWithinGroupStr,
req);
-      sortSpecWithinGroup = searcher.weightSortSpec(parsedSortSpecWithinGroup, Sort.RELEVANCE);
+    final SortSpec withinGroupSortSpec;
+    if (withinGroupSortStr != null) {
+      SortSpec parsedWithinGroupSortSpec = SortSpecParsing.parseSortSpec(withinGroupSortStr,
req);
+      withinGroupSortSpec = searcher.weightSortSpec(parsedWithinGroupSortSpec, Sort.RELEVANCE);
     } else {
-      sortSpecWithinGroup = new SortSpec(
+      withinGroupSortSpec = new SortSpec(
           groupSortSpec.getSort(),
           groupSortSpec.getSchemaFields(),
           groupSortSpec.getCount(),
           groupSortSpec.getOffset());
     }
-    sortSpecWithinGroup.setOffset(params.getInt(GroupParams.GROUP_OFFSET, 0));
-    sortSpecWithinGroup.setCount(params.getInt(GroupParams.GROUP_LIMIT, 1));
+    withinGroupSortSpec.setOffset(params.getInt(GroupParams.GROUP_OFFSET, 0));
+    withinGroupSortSpec.setCount(params.getInt(GroupParams.GROUP_LIMIT, 1));
 
-    groupingSpec.setSortSpecWithinGroup(sortSpecWithinGroup);
+    groupingSpec.setWithinGroupSortSpec(withinGroupSortSpec);
     groupingSpec.setGroupSortSpec(groupSortSpec);
 
     String formatStr = params.get(GroupParams.GROUP_FORMAT, Grouping.Format.grouped.name());
@@ -397,7 +397,7 @@ public class QueryComponent extends SearchComponent
           for (String field : groupingSpec.getFields()) {
             topsGroupsActionBuilder.addCommandField(new SearchGroupsFieldCommand.Builder()
                 .setField(schema.getField(field))
-                .setGroupSort(groupingSpec.getGroupSort())
+                .setGroupSortSpec(groupingSpec.getGroupSortSpec())
                 .setTopNGroups(cmd.getOffset() + cmd.getLen())
                 .setIncludeGroupCount(groupingSpec.isIncludeGroupCount())
                 .build()
@@ -439,8 +439,8 @@ public class QueryComponent extends SearchComponent
             secondPhaseBuilder.addCommandField(
                 new TopGroupsFieldCommand.Builder()
                     .setField(schemaField)
-                    .setGroupSort(groupingSpec.getGroupSort())
-                    .setSortWithinGroup(groupingSpec.getSortWithinGroup())
+                    .setGroupSortSpec(groupingSpec.getGroupSortSpec())
+                    .setWithinGroupSortSpec(groupingSpec.getWithinGroupSortSpec())
                     .setFirstPhaseGroups(topGroups)
                     .setMaxDocPerGroup(docsToCollect)
                     .setNeedScores(needScores)

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
index f72fc89..25157cf 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
@@ -465,10 +465,10 @@ public class QueryElevationComponent extends SearchComponent implements
SolrCore
         if (modGroupSortSpec != null) {
           groupingSpec.setGroupSortSpec(modGroupSortSpec);
         }
-        SortSpec withinGroupSortSpec = groupingSpec.getSortSpecWithinGroup();
+        SortSpec withinGroupSortSpec = groupingSpec.getWithinGroupSortSpec();
         SortSpec modWithinGroupSortSpec = this.modifySortSpec(withinGroupSortSpec, force,
comparator);
         if (modWithinGroupSortSpec != null) {
-          groupingSpec.setSortSpecWithinGroup(modWithinGroupSortSpec);
+          groupingSpec.setWithinGroupSortSpec(modWithinGroupSortSpec);
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/search/grouping/Command.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/Command.java b/solr/core/src/java/org/apache/solr/search/grouping/Command.java
index 55e2d96..fb64e8a 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/Command.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/Command.java
@@ -18,6 +18,7 @@ package org.apache.solr.search.grouping;
 
 import org.apache.lucene.search.Collector;
 import org.apache.lucene.search.Sort;
+import org.apache.solr.search.SortSpec;
 import java.io.IOException;
 import java.util.List;
 
@@ -57,9 +58,31 @@ public interface Command<T> {
    */
   Sort getGroupSort();
 
+
+
+  @Deprecated
   /**
    * @return The sort inside a group
    */
   Sort getSortWithinGroup();
 
+  /**
+   * @return The sort inside a group
+   */
+  Sort getWithinGroupSort();
+
+
+  // JTODO Would be nice to add these two but don't want to break anything for users of the
interface.
+//   /**
+//    * @return The group SortSpec (overall sort)
+//    */
+//   SortSpec getGroupSortSpec();
+
+
+
+//   /**
+//    * @return The SortSpec inside a group
+//    */
+//   SortSpec getWithinGroupSortSpec();
+
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/search/grouping/GroupingSpecification.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/GroupingSpecification.java
b/solr/core/src/java/org/apache/solr/search/grouping/GroupingSpecification.java
index 4194dd0..e1e276e 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/GroupingSpecification.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/GroupingSpecification.java
@@ -31,7 +31,7 @@ public class GroupingSpecification {
   private String[] queries = new String[]{};
   private String[] functions = new String[]{};
   private SortSpec groupSortSpec;
-  private SortSpec sortSpecWithinGroup;
+  private SortSpec withinGroupSortSpec;
   private boolean includeGroupCount;
   private boolean main;
   private Grouping.Format responseFormat;
@@ -76,7 +76,7 @@ public class GroupingSpecification {
 
   @Deprecated
   public int getWithinGroupOffset() {
-    return sortSpecWithinGroup.getOffset();
+    return withinGroupSortSpec.getOffset();
   }
   @Deprecated
   public int getGroupOffset() {
@@ -86,8 +86,9 @@ public class GroupingSpecification {
 
   @Deprecated
   public int getWithinGroupLimit() {
-    return sortSpecWithinGroup.getCount();
+    return withinGroupSortSpec.getCount();
   }
+
   @Deprecated
   public int getGroupLimit() {
     return getWithinGroupLimit();
@@ -114,10 +115,9 @@ public class GroupingSpecification {
 
   @Deprecated
   public Sort getSortWithinGroup() {
-    return sortSpecWithinGroup.getSort();
+    return withinGroupSortSpec.getSort();
   }
 
-
   public boolean isIncludeGroupCount() {
     return includeGroupCount;
   }
@@ -166,12 +166,12 @@ public class GroupingSpecification {
     this.groupSortSpec = groupSortSpec;
   }
 
-  public SortSpec getSortSpecWithinGroup() {
-    return sortSpecWithinGroup;
+  public SortSpec getWithinGroupSortSpec() {
+    return withinGroupSortSpec;
   }
 
-  public void setSortSpecWithinGroup(SortSpec sortSpecWithinGroup) {
-    this.sortSpecWithinGroup = sortSpecWithinGroup;
+  public void setWithinGroupSortSpec(SortSpec withinGroupSortSpec) {
+    this.withinGroupSortSpec = withinGroupSortSpec;
   }
 
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java
b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java
index afb8ba7..030416f 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/QueryCommand.java
@@ -21,6 +21,7 @@ import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.search.DocSet;
 import org.apache.solr.search.QParser;
 import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.search.SortSpec;
 import org.apache.solr.search.SyntaxError;
 import org.apache.solr.search.grouping.Command;
 import org.apache.solr.search.grouping.collector.FilterCollector;
@@ -148,8 +149,15 @@ public class QueryCommand implements Command<QueryCommandResult>
{
     return sort;
   }
 
+  @Deprecated
   @Override
   public Sort getSortWithinGroup() {
     return null;
   }
+
+
+  @Override
+  public Sort getWithinGroupSort() {
+    return null;
+  }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java
b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java
index fc04599..621c384 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/SearchGroupsFieldCommand.java
@@ -29,6 +29,7 @@ import org.apache.lucene.search.grouping.term.TermFirstPassGroupingCollector;
 import org.apache.lucene.util.BytesRef;
 import org.apache.solr.schema.FieldType;
 import org.apache.solr.schema.SchemaField;
+import org.apache.solr.search.SortSpec;
 import org.apache.solr.search.grouping.Command;
 
 import java.io.IOException;
@@ -42,7 +43,7 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman
   public static class Builder {
 
     private SchemaField field;
-    private Sort groupSort;
+    private SortSpec groupSortSpec;
     private Integer topNGroups;
     private boolean includeGroupCount = false;
 
@@ -51,8 +52,15 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman
       return this;
     }
 
-    public Builder setGroupSort(Sort groupSort) {
-      this.groupSort = groupSort;
+    // We can't reconstruct a SortSpec from a Sort.
+     @Deprecated  // JTODO
+     public Builder setGroupSort(Sort groupSort) {
+  //      this.groupSort = groupSort;
+        return this;
+      }
+
+    public Builder setGroupSortSpec(SortSpec groupSortSpec) {
+      this.groupSortSpec = groupSortSpec;
       return this;
     }
 
@@ -67,32 +75,35 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman
     }
 
     public SearchGroupsFieldCommand build() {
-      if (field == null || groupSort == null || topNGroups == null) {
-        throw new IllegalStateException("All fields must be set");
-      }
+        if (field == null || groupSortSpec == null || groupSortSpec.getSort() == null ||
topNGroups == null) {
+            throw new IllegalStateException("All fields must be set");
+        }
 
-      return new SearchGroupsFieldCommand(field, groupSort, topNGroups, includeGroupCount);
+      return new SearchGroupsFieldCommand(field, groupSortSpec, topNGroups, includeGroupCount);
     }
 
   }
 
   private final SchemaField field;
-  private final Sort groupSort;
+  private final SortSpec groupSortSpec;
   private final int topNGroups;
   private final boolean includeGroupCount;
 
   private AbstractFirstPassGroupingCollector firstPassGroupingCollector;
   private AbstractAllGroupsCollector allGroupsCollector;
 
-  private SearchGroupsFieldCommand(SchemaField field, Sort groupSort, int topNGroups, boolean
includeGroupCount) {
+  private SearchGroupsFieldCommand(SchemaField field, SortSpec groupSortSpec, int topNGroups,
boolean includeGroupCount) {
     this.field = field;
-    this.groupSort = groupSort;
+    this.groupSortSpec = groupSortSpec;
     this.topNGroups = topNGroups;
     this.includeGroupCount = includeGroupCount;
   }
 
   @Override
   public List<Collector> create() throws IOException {
+
+    final Sort groupSort = groupSortSpec.getSort();
+
     final List<Collector> collectors = new ArrayList<>(2);
     final FieldType fieldType = field.getType();
     if (topNGroups > 0) {
@@ -137,14 +148,33 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman
     return new SearchGroupsFieldCommandResult(groupCount, topGroups);
   }
 
+  @Deprecated
   @Override
   public Sort getSortWithinGroup() {
+      return null;
+  }
+
+
+  @Override
+  public Sort getWithinGroupSort() {
     return null;
   }
 
+
   @Override
   public Sort getGroupSort() {
-    return groupSort;
+      return groupSortSpec.getSort();
+  }
+
+
+//  @Override  // Not yet part of interface
+  public SortSpec getGroupSortSpec() {
+    return groupSortSpec;
+  }
+
+//  @Override // Not yet part of interface
+  public SortSpec getWithinGroupSortSpec() {
+      return null;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java
b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java
index 2660b21..cdeb86a 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/command/TopGroupsFieldCommand.java
@@ -29,6 +29,7 @@ import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.mutable.MutableValue;
 import org.apache.solr.schema.FieldType;
 import org.apache.solr.schema.SchemaField;
+import org.apache.solr.search.SortSpec;
 import org.apache.solr.search.grouping.Command;
 
 import java.io.IOException;
@@ -46,8 +47,8 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>>
{
   public static class Builder {
 
     private SchemaField field;
-    private Sort groupSort;
-    private Sort sortWithinGroup;
+    private SortSpec groupSortSpec;
+    private SortSpec withinGroupSortSpec;
     private Collection<SearchGroup<BytesRef>> firstPhaseGroups;
     private Integer maxDocPerGroup;
     private boolean needScores = false;
@@ -58,16 +59,31 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>>
{
       return this;
     }
 
+    //JTODO
+    // We can't reconstruct a SortSpec from a Sort.
+    @Deprecated
     public Builder setGroupSort(Sort groupSort) {
-      this.groupSort = groupSort;
+  //      this.groupSort = groupSort;
       return this;
     }
 
+    // Same as above
+    @Deprecated
     public Builder setSortWithinGroup(Sort sortWithinGroup) {
-      this.sortWithinGroup = sortWithinGroup;
+//      this.withinGroupSort = sortWithinGroup;
       return this;
     }
 
+    public Builder setGroupSortSpec(SortSpec groupSortSpec) {
+        this.groupSortSpec = groupSortSpec;
+        return this;
+    }
+
+    public Builder setWithinGroupSortSpec(SortSpec withinGroupSortSpec) {
+        this.withinGroupSortSpec = withinGroupSortSpec;
+        return this;
+    }
+
     public Builder setFirstPhaseGroups(Collection<SearchGroup<BytesRef>> firstPhaseGroups)
{
       this.firstPhaseGroups = firstPhaseGroups;
       return this;
@@ -89,19 +105,19 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>>
{
     }
 
     public TopGroupsFieldCommand build() {
-      if (field == null || groupSort == null ||  sortWithinGroup == null || firstPhaseGroups
== null ||
+        if (field == null || groupSortSpec == null || groupSortSpec.getSort() == null ||
withinGroupSortSpec == null ||  withinGroupSortSpec.getSort() == null || firstPhaseGroups
== null ||
           maxDocPerGroup == null) {
         throw new IllegalStateException("All required fields must be set");
       }
 
-      return new TopGroupsFieldCommand(field, groupSort, sortWithinGroup, firstPhaseGroups,
maxDocPerGroup, needScores, needMaxScore);
+      return new TopGroupsFieldCommand(field, groupSortSpec, withinGroupSortSpec, firstPhaseGroups,
maxDocPerGroup, needScores, needMaxScore);
     }
 
   }
 
   private final SchemaField field;
-  private final Sort groupSort;
-  private final Sort sortWithinGroup;
+  private final SortSpec groupSortSpec;
+  private final SortSpec withinGroupSortSpec;
   private final Collection<SearchGroup<BytesRef>> firstPhaseGroups;
   private final int maxDocPerGroup;
   private final boolean needScores;
@@ -109,15 +125,15 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>>
{
   private AbstractSecondPassGroupingCollector secondPassCollector;
 
   private TopGroupsFieldCommand(SchemaField field,
-                                Sort groupSort,
-                                Sort sortWithinGroup,
+                                SortSpec groupSortSpec,
+                                SortSpec withinGroupSortSpec,
                                 Collection<SearchGroup<BytesRef>> firstPhaseGroups,
                                 int maxDocPerGroup,
                                 boolean needScores,
                                 boolean needMaxScore) {
     this.field = field;
-    this.groupSort = groupSort;
-    this.sortWithinGroup = sortWithinGroup;
+    this.groupSortSpec = groupSortSpec;
+    this.withinGroupSortSpec = withinGroupSortSpec;
     this.firstPhaseGroups = firstPhaseGroups;
     this.maxDocPerGroup = maxDocPerGroup;
     this.needScores = needScores;
@@ -130,17 +146,20 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>>
{
       return Collections.emptyList();
     }
 
+    final Sort groupSort = groupSortSpec.getSort();
+    final Sort withinGroupSort = withinGroupSortSpec.getSort();
+
     final List<Collector> collectors = new ArrayList<>(1);
     final FieldType fieldType = field.getType();
     if (fieldType.getNumericType() != null) {
       ValueSource vs = fieldType.getValueSource(field, null);
       Collection<SearchGroup<MutableValue>> v = GroupConverter.toMutable(field,
firstPhaseGroups);
       secondPassCollector = new FunctionSecondPassGroupingCollector(
-          v, groupSort, sortWithinGroup, maxDocPerGroup, needScores, needMaxScore, true,
vs, new HashMap<Object,Object>()
+          v, groupSort, withinGroupSort, maxDocPerGroup, needScores, needMaxScore, true,
vs, new HashMap<Object,Object>()
       );
     } else {
       secondPassCollector = new TermSecondPassGroupingCollector(
-          field.getName(), firstPhaseGroups, groupSort, sortWithinGroup, maxDocPerGroup,
needScores, needMaxScore, true
+          field.getName(), firstPhaseGroups, groupSort, withinGroupSort, maxDocPerGroup,
needScores, needMaxScore, true
       );
     }
     collectors.add(secondPassCollector);
@@ -151,7 +170,7 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>>
{
   @SuppressWarnings("unchecked")
   public TopGroups<BytesRef> result() {
     if (firstPhaseGroups.isEmpty()) {
-      return new TopGroups<>(groupSort.getSort(), sortWithinGroup.getSort(), 0, 0,
new GroupDocs[0], Float.NaN);
+      return new TopGroups<>(groupSortSpec.getSort().getSort(), withinGroupSortSpec.getSort().getSort(),
0, 0, new GroupDocs[0], Float.NaN);
     }
 
     FieldType fieldType = field.getType();
@@ -169,11 +188,17 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>>
{
 
   @Override
   public Sort getGroupSort() {
-    return groupSort;
+      return groupSortSpec.getSort();
   }
 
+  @Deprecated
   @Override
   public Sort getSortWithinGroup() {
-    return sortWithinGroup;
+      return getWithinGroupSort();
+  }
+
+  @Override
+  public Sort getWithinGroupSort() {
+      return withinGroupSortSpec.getSort();
   }
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java
b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java
index 0acd6f9..dedd010 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/SearchGroupShardResponseProcessor.java
@@ -48,11 +48,12 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor
    */
   @Override
   public void process(ResponseBuilder rb, ShardRequest shardRequest) {
-    SortSpec ss = rb.getSortSpec();
-    Sort groupSort = rb.getGroupingSpec().getGroupSort();
+//    SortSpec ss = rb.getSortSpec(); // used only for offset and count; might as well use
groupSortSpec (?)
+    SortSpec groupSortSpec = rb.getGroupingSpec().getGroupSortSpec();
     final String[] fields = rb.getGroupingSpec().getFields();
-    Sort sortWithinGroup = rb.getGroupingSpec().getSortWithinGroup();
-    assert sortWithinGroup != null;
+
+    SortSpec withinGroupSortSpec = rb.getGroupingSpec().getWithinGroupSortSpec();
+    assert withinGroupSortSpec.getSort() != null;
 
     final Map<String, List<Collection<SearchGroup<BytesRef>>>> commandSearchGroups
= new HashMap<>(fields.length, 1.0f);
     final Map<String, Map<SearchGroup<BytesRef>, Set<String>>> tempSearchGroupToShards
= new HashMap<>(fields.length, 1.0f);
@@ -108,7 +109,7 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor
         maxElapsedTime = (int) Math.max(maxElapsedTime, srsp.getSolrResponse().getElapsedTime());
         @SuppressWarnings("unchecked")
         NamedList<NamedList> firstPhaseResult = (NamedList<NamedList>) srsp.getSolrResponse().getResponse().get("firstPhase");
-        final Map<String, SearchGroupsFieldCommandResult> result = serializer.transformToNative(firstPhaseResult,
groupSort, sortWithinGroup, srsp.getShard());
+        final Map<String, SearchGroupsFieldCommandResult> result = serializer.transformToNative(firstPhaseResult,
groupSortSpec, withinGroupSortSpec, srsp.getShard());
         for (String field : commandSearchGroups.keySet()) {
           final SearchGroupsFieldCommandResult firstPhaseCommandResult = result.get(field);
 
@@ -141,7 +142,7 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor
       rb.firstPhaseElapsedTime = maxElapsedTime;
       for (String groupField : commandSearchGroups.keySet()) {
         List<Collection<SearchGroup<BytesRef>>> topGroups = commandSearchGroups.get(groupField);
-        Collection<SearchGroup<BytesRef>> mergedTopGroups = SearchGroup.merge(topGroups,
ss.getOffset(), ss.getCount(), groupSort);
+        Collection<SearchGroup<BytesRef>> mergedTopGroups = SearchGroup.merge(topGroups,
groupSortSpec.getOffset(), groupSortSpec.getCount(), groupSortSpec.getSort());
         if (mergedTopGroups == null) {
           continue;
         }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java
b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java
index 7e38e5d..da4c18a 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/responseprocessor/TopGroupsShardResponseProcessor.java
@@ -34,6 +34,7 @@ import org.apache.solr.handler.component.ShardRequest;
 import org.apache.solr.handler.component.ShardResponse;
 import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.search.Grouping;
+import org.apache.solr.search.SortSpec;
 import org.apache.solr.search.grouping.distributed.ShardResponseProcessor;
 import org.apache.solr.search.grouping.distributed.command.QueryCommandResult;
 import org.apache.solr.search.grouping.distributed.shardresultserializer.TopGroupsResultTransformer;
@@ -57,11 +58,13 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor
{
   @Override
   @SuppressWarnings("unchecked")
   public void process(ResponseBuilder rb, ShardRequest shardRequest) {
-    Sort groupSort = rb.getGroupingSpec().getGroupSort();
+    SortSpec groupSortSpec = rb.getGroupingSpec().getGroupSortSpec();
+    Sort groupSort = groupSortSpec.getSort();
     String[] fields = rb.getGroupingSpec().getFields();
     String[] queries = rb.getGroupingSpec().getQueries();
-    Sort sortWithinGroup = rb.getGroupingSpec().getSortWithinGroup();
-    assert sortWithinGroup != null;
+    SortSpec withinGroupSortSpec = rb.getGroupingSpec().getWithinGroupSortSpec();
+    Sort withinGroupSort = withinGroupSortSpec.getSort();
+    assert withinGroupSortSpec != null;
 
     // If group.format=simple group.offset doesn't make sense
     int groupOffsetDefault;
@@ -124,7 +127,7 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor
{
       NamedList<NamedList> secondPhaseResult = (NamedList<NamedList>) srsp.getSolrResponse().getResponse().get("secondPhase");
       if(secondPhaseResult == null)
         continue;
-      Map<String, ?> result = serializer.transformToNative(secondPhaseResult, groupSort,
sortWithinGroup, srsp.getShard());
+      Map<String, ?> result = serializer.transformToNative(secondPhaseResult, groupSortSpec,
withinGroupSortSpec, srsp.getShard());
       int numFound = 0;
       float maxScore = Float.NaN;
       for (String field : commandTopGroups.keySet()) {
@@ -167,7 +170,7 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor
{
             docsPerGroup += subTopGroups.totalGroupedHitCount;
           }
         }
-        rb.mergedTopGroups.put(groupField, TopGroups.merge(topGroups.toArray(topGroupsArr),
groupSort, sortWithinGroup, groupOffsetDefault, docsPerGroup, TopGroups.ScoreMergeMode.None));
+        rb.mergedTopGroups.put(groupField, TopGroups.merge(topGroups.toArray(topGroupsArr),
groupSort, withinGroupSort, groupOffsetDefault, docsPerGroup, TopGroups.ScoreMergeMode.None));
       }
 
       for (String query : commandTopDocs.keySet()) {
@@ -181,10 +184,10 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor
{
 
         int topN = rb.getGroupingSpec().getOffset() + rb.getGroupingSpec().getLimit();
         final TopDocs mergedTopDocs;
-        if (sortWithinGroup.equals(Sort.RELEVANCE)) {
+        if (withinGroupSort.equals(Sort.RELEVANCE)) {
           mergedTopDocs = TopDocs.merge(topN, topDocs.toArray(new TopDocs[topDocs.size()]));
         } else {
-          mergedTopDocs = TopDocs.merge(sortWithinGroup, topN, topDocs.toArray(new TopFieldDocs[topDocs.size()]));
+          mergedTopDocs = TopDocs.merge(withinGroupSort, topN, topDocs.toArray(new TopFieldDocs[topDocs.size()]));
         }
         rb.mergedQueryCommandResults.put(query, new QueryCommandResult(mergedTopDocs, mergedMatches));
       }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/SearchGroupsResultTransformer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/SearchGroupsResultTransformer.java
b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/SearchGroupsResultTransformer.java
index 7b8aad8..c711070 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/SearchGroupsResultTransformer.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/SearchGroupsResultTransformer.java
@@ -23,6 +23,7 @@ import org.apache.solr.common.util.NamedList;
 import org.apache.solr.schema.FieldType;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.search.SortSpec;
 import org.apache.solr.search.grouping.Command;
 import org.apache.solr.search.grouping.distributed.command.SearchGroupsFieldCommand;
 import org.apache.solr.search.grouping.distributed.command.SearchGroupsFieldCommandResult;
@@ -57,7 +58,7 @@ public class SearchGroupsResultTransformer implements ShardResultTransformer<Lis
         final SearchGroupsFieldCommandResult fieldCommandResult = fieldCommand.result();
         final Collection<SearchGroup<BytesRef>> searchGroups = fieldCommandResult.getSearchGroups();
         if (searchGroups != null) {
-          commandResult.add(TOP_GROUPS, serializeSearchGroup(searchGroups, fieldCommand.getGroupSort()));
+          commandResult.add(TOP_GROUPS, serializeSearchGroup(searchGroups, fieldCommand.getGroupSortSpec()));
         }
         final Integer groupedCount = fieldCommandResult.getGroupCount();
         if (groupedCount != null) {
@@ -76,9 +77,10 @@ public class SearchGroupsResultTransformer implements ShardResultTransformer<Lis
    * {@inheritDoc}
    */
   @Override
-  public Map<String, SearchGroupsFieldCommandResult> transformToNative(NamedList<NamedList>
shardResponse, Sort groupSort, Sort sortWithinGroup, String shard) {
-//public Map<String, SearchGroupsFieldCommandResult> transformToNative(NamedList<NamedList>
shardResponse, SortSpec groupSortSpec, SortSpec sortSpecWithinGroup, String shard) {
+  public Map<String, SearchGroupsFieldCommandResult> transformToNative(NamedList<NamedList>
shardResponse, SortSpec groupSortSpec, SortSpec withinGroupSortSpec, String shard) {
     final Map<String, SearchGroupsFieldCommandResult> result = new HashMap<>(shardResponse.size());
+    final Sort groupSort = groupSortSpec.getSort();
+
     for (Map.Entry<String, NamedList> command : shardResponse) {
       List<SearchGroup<BytesRef>> searchGroups = new ArrayList<>();
       NamedList topGroupsAndGroupCount = command.getValue();
@@ -108,9 +110,10 @@ public class SearchGroupsResultTransformer implements ShardResultTransformer<Lis
     return result;
   }
 
-  private NamedList serializeSearchGroup(Collection<SearchGroup<BytesRef>> data,
Sort groupSort) {
-//private NamedList serializeSearchGroup(Collection<SearchGroup<BytesRef>> data,
SortSpec groupSortSpec) {
+
+  private NamedList serializeSearchGroup(Collection<SearchGroup<BytesRef>> data,
SortSpec groupSortSpec) {
     final NamedList<Object[]> result = new NamedList<>(data.size());
+    final Sort groupSort = groupSortSpec.getSort();
 
     for (SearchGroup<BytesRef> searchGroup : data) {
       Object[] convertedSortValues = new Object[searchGroup.sortValues.length];

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/ShardResultTransformer.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/ShardResultTransformer.java
b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/ShardResultTransformer.java
index 3a026ca..bf69a47 100644
--- a/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/ShardResultTransformer.java
+++ b/solr/core/src/java/org/apache/solr/search/grouping/distributed/shardresultserializer/ShardResultTransformer.java
@@ -18,6 +18,7 @@ package org.apache.solr.search.grouping.distributed.shardresultserializer;
 
 import org.apache.lucene.search.Sort;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.search.SortSpec;
 
 import java.io.IOException;
 
@@ -43,12 +44,11 @@ public interface ShardResultTransformer<T, R> {
    * Transforms the specified shard response into native structures.
    *
    * @param shardResponse The shard response containing data in a {@link NamedList} structure
-   * @param groupSort The group sort
-   * @param sortWithinGroup The sort inside a group
+   * @param groupSortSpec The group SortSpec
+   * @param withinGroupSortSpec The SortSpec inside a group
    * @param shard The shard address where the response originated from
    * @return native structure of the data
    */
-  R transformToNative(NamedList<NamedList> shardResponse, Sort groupSort, Sort sortWithinGroup,
String shard);
-//R transformToNative(NamedList<NamedList> shardResponse, SortSpec groupSortSpec, SortSpec
sortSpecWithinGroup, String shard);
+  R transformToNative(NamedList<NamedList> shardResponse, SortSpec groupSortSpec, SortSpec
withinGroupSortSpec, String shard);
 
 }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/99e2e3d4/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 b93f9a0..f0de8f4 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
@@ -39,6 +39,7 @@ import org.apache.solr.handler.component.ShardDoc;
 import org.apache.solr.schema.FieldType;
 import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
+import org.apache.solr.search.SortSpec;
 import org.apache.solr.search.grouping.Command;
 import org.apache.solr.search.grouping.distributed.command.QueryCommand;
 import org.apache.solr.search.grouping.distributed.command.QueryCommandResult;
@@ -89,11 +90,12 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
    * {@inheritDoc}
    */
   @Override
-  public Map<String, ?> transformToNative(NamedList<NamedList> shardResponse,
Sort groupSort, Sort sortWithinGroup, String shard) {
-//public Map<String, ?> transformToNative(NamedList<NamedList> shardResponse,
SortSpec groupSortSpec, SortSpec sortSpecWithinGroup, String shard) {
+    public Map<String, ?> transformToNative(NamedList<NamedList> shardResponse,
SortSpec groupSortSpec, SortSpec withinGroupSortSpec, String shard) {
     Map<String, Object> result = new HashMap<>();
 
     final IndexSchema schema = rb.req.getSearcher().getSchema();
+    final Sort groupSort = groupSortSpec.getSort();
+    final Sort withinGroupSort = withinGroupSortSpec.getSort();
 
     for (Map.Entry<String, NamedList> entry : shardResponse) {
       String key = entry.getKey();
@@ -111,10 +113,10 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
         List<NamedList<Object>> documents = (List<NamedList<Object>>)
commandResult.get("documents");
         ScoreDoc[] scoreDocs = transformToNativeShardDoc(documents, groupSort, shard, schema);
         final TopDocs topDocs;
-        if (sortWithinGroup.equals(Sort.RELEVANCE)) {
+        if (withinGroupSort.equals(Sort.RELEVANCE)) {
           topDocs = new TopDocs(totalHits, scoreDocs, maxScore);
         } else {
-          topDocs = new TopFieldDocs(totalHits, scoreDocs, sortWithinGroup.getSort(), maxScore);
+          topDocs = new TopFieldDocs(totalHits, scoreDocs, withinGroupSort.getSort(), maxScore);
         }
         result.put(key, new QueryCommandResult(topDocs, matches));
         continue;
@@ -135,7 +137,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
 
         @SuppressWarnings("unchecked")
         List<NamedList<Object>> documents = (List<NamedList<Object>>)
groupResult.get("documents");
-        ScoreDoc[] scoreDocs = transformToNativeShardDoc(documents, sortWithinGroup, shard,
schema);
+        ScoreDoc[] scoreDocs = transformToNativeShardDoc(documents, withinGroupSort, shard,
schema);
 
         BytesRef groupValueRef = groupValue != null ? new BytesRef(groupValue) : null;
         groupDocs.add(new GroupDocs<>(Float.NaN, maxScore, totalGroupHits, scoreDocs,
groupValueRef, null));
@@ -144,7 +146,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
       @SuppressWarnings("unchecked")
       GroupDocs<BytesRef>[] groupDocsArr = groupDocs.toArray(new GroupDocs[groupDocs.size()]);
       TopGroups<BytesRef> topGroups = new TopGroups<>(
-           groupSort.getSort(), sortWithinGroup.getSort(), totalHitCount, totalGroupedHitCount,
groupDocsArr, Float.NaN
+           groupSort.getSort(), withinGroupSort.getSort(), totalHitCount, totalGroupedHitCount,
groupDocsArr, Float.NaN
       );
 
       result.put(key, topGroups);
@@ -225,8 +227,8 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
         Object[] convertedSortValues  = new Object[fieldDoc.fields.length];
         for (int j = 0; j < fieldDoc.fields.length; j++) {
           Object sortValue  = fieldDoc.fields[j];
-          Sort sortWithinGroup = rb.getGroupingSpec().getSortWithinGroup();
-          SchemaField field = sortWithinGroup.getSort()[j].getField() != null ? schema.getFieldOrNull(sortWithinGroup.getSort()[j].getField())
: null;
+          Sort withinGroupSort = rb.getGroupingSpec().getWithinGroupSortSpec().getSort();
+          SchemaField field = withinGroupSort.getSort()[j].getField() != null ? schema.getFieldOrNull(withinGroupSort.getSort()[j].getField())
: null;
           if (field != null) {
             FieldType fieldType = field.getType();
             if (sortValue != null) {
@@ -234,7 +236,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer<List<C
             }
           }
           convertedSortValues[j] = sortValue;
-        //convertedSortValues[j] = aNewStaticMethod(j, rb.getGroupingSpec().getSortSpecWithinGroup(),
fieldDoc.fields);
+        //convertedSortValues[j] = aNewStaticMethod(j, rb.getGroupingSpec().getWithinGroupSortSpec(),
fieldDoc.fields);
         }
         document.add("sortValues", convertedSortValues);
       }


Mime
View raw message