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 80ea4cd9ade..a4962789a0c 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 @@ -47,7 +47,7 @@ public class TopGroupsFieldCommand implements Command> { private SchemaField field; private Sort groupSort; - private Sort sortWithinGroup; + private Sort withinGroupSort; private Collection> firstPhaseGroups; private Integer maxDocPerGroup; private boolean needScores = false; @@ -63,8 +63,8 @@ public class TopGroupsFieldCommand implements Command> { return this; } - public Builder setSortWithinGroup(Sort sortWithinGroup) { - this.sortWithinGroup = sortWithinGroup; + public Builder setSortWithinGroup(Sort withinGroupSort) { + this.withinGroupSort = withinGroupSort; return this; } @@ -89,19 +89,19 @@ public class TopGroupsFieldCommand implements Command> { } public TopGroupsFieldCommand build() { - if (field == null || groupSort == null || sortWithinGroup == null || firstPhaseGroups == null || + if (field == null || groupSort == null || withinGroupSort == 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, groupSort, withinGroupSort, firstPhaseGroups, maxDocPerGroup, needScores, needMaxScore); } } private final SchemaField field; private final Sort groupSort; - private final Sort sortWithinGroup; + private final Sort withinGroupSort; private final Collection> firstPhaseGroups; private final int maxDocPerGroup; private final boolean needScores; @@ -110,14 +110,14 @@ public class TopGroupsFieldCommand implements Command> { private TopGroupsFieldCommand(SchemaField field, Sort groupSort, - Sort sortWithinGroup, + Sort withinGroupSort, Collection> firstPhaseGroups, int maxDocPerGroup, boolean needScores, boolean needMaxScore) { this.field = field; this.groupSort = groupSort; - this.sortWithinGroup = sortWithinGroup; + this.withinGroupSort = withinGroupSort; this.firstPhaseGroups = firstPhaseGroups; this.maxDocPerGroup = maxDocPerGroup; this.needScores = needScores; @@ -136,11 +136,11 @@ public class TopGroupsFieldCommand implements Command> { ValueSource vs = fieldType.getValueSource(field, null); Collection> v = GroupConverter.toMutable(field, firstPhaseGroups); secondPassCollector = new TopGroupsCollector<>(new ValueSourceGroupSelector(vs, new HashMap<>()), - v, groupSort, sortWithinGroup, maxDocPerGroup, needScores, needMaxScore, true + v, groupSort, withinGroupSort, maxDocPerGroup, needScores, needMaxScore, true ); } else { secondPassCollector = new TopGroupsCollector<>(new TermGroupSelector(field.getName()), - firstPhaseGroups, groupSort, sortWithinGroup, maxDocPerGroup, needScores, needMaxScore, true + firstPhaseGroups, groupSort, withinGroupSort, maxDocPerGroup, needScores, needMaxScore, true ); } collectors.add(secondPassCollector); @@ -151,7 +151,7 @@ public class TopGroupsFieldCommand implements Command> { @SuppressWarnings("unchecked") public TopGroups result() { if (firstPhaseGroups.isEmpty()) { - return new TopGroups<>(groupSort.getSort(), sortWithinGroup.getSort(), 0, 0, new GroupDocs[0], Float.NaN); + return new TopGroups<>(groupSort.getSort(), withinGroupSort.getSort(), 0, 0, new GroupDocs[0], Float.NaN); } FieldType fieldType = field.getType(); @@ -174,6 +174,6 @@ public class TopGroupsFieldCommand implements Command> { @Override public Sort getWithinGroupSort() { - return sortWithinGroup; + return withinGroupSort; } } 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 a12cad1912c..ab13f7244b5 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 @@ -55,8 +55,8 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor SortSpec ss = rb.getSortSpec(); Sort groupSort = rb.getGroupingSpec().getGroupSort(); final String[] fields = rb.getGroupingSpec().getFields(); - Sort sortWithinGroup = rb.getGroupingSpec().getSortWithinGroup(); - assert sortWithinGroup != null; + Sort withinGroupSort = rb.getGroupingSpec().getSortWithinGroup(); + assert withinGroupSort != null; final Map>>> commandSearchGroups = new HashMap<>(fields.length, 1.0f); final Map, Set>> tempSearchGroupToShards = new HashMap<>(fields.length, 1.0f); @@ -111,7 +111,7 @@ public class SearchGroupShardResponseProcessor implements ShardResponseProcessor maxElapsedTime = (int) Math.max(maxElapsedTime, srsp.getSolrResponse().getElapsedTime()); @SuppressWarnings("unchecked") NamedList firstPhaseResult = (NamedList) srsp.getSolrResponse().getResponse().get("firstPhase"); - final Map result = serializer.transformToNative(firstPhaseResult, groupSort, sortWithinGroup, srsp.getShard()); + final Map result = serializer.transformToNative(firstPhaseResult, groupSort, withinGroupSort, srsp.getShard()); for (String field : commandSearchGroups.keySet()) { final SearchGroupsFieldCommandResult firstPhaseCommandResult = result.get(field); 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 2ac83c64e29..231e9bd548f 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 @@ -58,8 +58,8 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor { Sort groupSort = rb.getGroupingSpec().getGroupSort(); String[] fields = rb.getGroupingSpec().getFields(); String[] queries = rb.getGroupingSpec().getQueries(); - Sort sortWithinGroup = rb.getGroupingSpec().getSortWithinGroup(); - assert sortWithinGroup != null; + Sort withinGroupSort = rb.getGroupingSpec().getSortWithinGroup(); + assert withinGroupSort != null; // If group.format=simple group.offset doesn't make sense int groupOffsetDefault; @@ -122,7 +122,7 @@ public class TopGroupsShardResponseProcessor implements ShardResponseProcessor { NamedList secondPhaseResult = (NamedList) srsp.getSolrResponse().getResponse().get("secondPhase"); if(secondPhaseResult == null) continue; - Map result = serializer.transformToNative(secondPhaseResult, groupSort, sortWithinGroup, srsp.getShard()); + Map result = serializer.transformToNative(secondPhaseResult, groupSort, withinGroupSort, srsp.getShard()); int numFound = 0; float maxScore = Float.NaN; for (String field : commandTopGroups.keySet()) { @@ -164,7 +164,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()) { @@ -178,10 +178,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)); } 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 2602221a654..77dfcefd47d 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 @@ -77,7 +77,7 @@ public class SearchGroupsResultTransformer implements ShardResultTransformer transformToNative(NamedList shardResponse, Sort groupSort, Sort sortWithinGroup, String shard) { + public Map transformToNative(NamedList shardResponse, Sort groupSort, Sort withinGroupSort, String shard) { final Map result = new HashMap<>(shardResponse.size()); for (Map.Entry command : shardResponse) { List> searchGroups = new ArrayList<>(); 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 04a3dfc263d..47e20a0018c 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 @@ -44,10 +44,10 @@ public interface ShardResultTransformer { * * @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 withinGroupSort The sort inside a group * @param shard The shard address where the response originated from * @return native structure of the data */ - R transformToNative(NamedList shardResponse, Sort groupSort, Sort sortWithinGroup, String shard); + R transformToNative(NamedList shardResponse, Sort groupSort, Sort withinGroupSort, String shard); } 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 83c81e5e9fd..41145ba6eef 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 @@ -92,7 +92,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer transformToNative(NamedList shardResponse, Sort groupSort, Sort sortWithinGroup, String shard) { + public Map transformToNative(NamedList shardResponse, Sort groupSort, Sort withinGroupSort, String shard) { Map result = new HashMap<>(); final IndexSchema schema = rb.req.getSearcher().getSchema(); @@ -113,10 +113,10 @@ public class TopGroupsResultTransformer implements ShardResultTransformer> documents = (List>) 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; @@ -137,7 +137,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer> documents = (List>) 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)); @@ -146,7 +146,7 @@ public class TopGroupsResultTransformer implements ShardResultTransformer[] groupDocsArr = groupDocs.toArray(new GroupDocs[groupDocs.size()]); TopGroups 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); @@ -222,8 +222,8 @@ public class TopGroupsResultTransformer implements ShardResultTransformer