Apache Lucene open-source search software
SOLR-8277: (Search|Top)GroupsFieldCommand tweaks
Christine Poerschke11d8f445bee8
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex df4bbb05027..a674c674aaa 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -557,6 +557,8 @@ Other Changes* SOLR-8194: Improve error reporting for null documents in UpdateRequest (MarkusJelsma, Alan Woodward)+* SOLR-8277: (Search|Top)GroupsFieldCommand tweaks (Christine Poerschke)+================== 5.3.1 ==================Bug Fixesdiff --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.javaindex a81599ab536..e29e8e046cb 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@@ -94,8 +94,8 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman@Overridepublic List<Collector> create() throws IOException {- List<Collector> collectors = new ArrayList<>();- FieldType fieldType = field.getType();+ final List<Collector> collectors = new ArrayList<>(2);+ final FieldType fieldType = field.getType();if (topNGroups > 0) {if (fieldType.getNumericType() != null) {ValueSource vs = fieldType.getValueSource(field, null);@@ -120,7 +120,7 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldComman@Overridepublic SearchGroupsFieldCommandResult result() {final Collection<SearchGroup<BytesRef>> topGroups;- if (topNGroups > 0) {+ if (firstPassGroupingCollector != null) {if (field.getType().getNumericType() != null) {topGroups = GroupConverter.fromMutable(field, firstPassGroupingCollector.getTopGroups(0, true));} else {@@ -130,7 +130,7 @@ public class SearchGroupsFieldCommand implements Command<SearchGroupsFieldCommantopGroups = Collections.emptyList();}final Integer groupCount;- if (includeGroupCount) {+ if (allGroupsCollector != null) {groupCount = allGroupsCollector.getGroupCount();} else {groupCount = null;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.javaindex eb8b4851f6a..d65058c987e 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@@ -131,8 +131,8 @@ public class TopGroupsFieldCommand implements Command<TopGroups<BytesRef>> {return Collections.emptyList();}- List<Collector> collectors = new ArrayList<>();- FieldType fieldType = field.getType();+ 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);