diff --git a/solr/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/src/java/org/apache/solr/handler/component/QueryComponent.java index 78c6ccf1c61..0415f2992cc 100644 --- a/solr/src/java/org/apache/solr/handler/component/QueryComponent.java +++ b/solr/src/java/org/apache/solr/handler/component/QueryComponent.java @@ -244,10 +244,15 @@ public class QueryComponent extends SearchComponent cmd.groupCommands = null; if (cmd.groupCommands != null) { + if (rb.doHighlights || rb.isDebug()) { + // we need a single list of the returned docs + cmd.setFlags(cmd.getFlags() | SolrIndexSearcher.GET_DOCLIST); + } + searcher.search(result,cmd); rb.setResult( result ); rsp.add("grouped", result.groupedResults); - // TODO: get "hits" a different way + // TODO: get "hits" a different way to log return; } } catch (ParseException e) { diff --git a/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java index 829e235f196..b62c3ff90e4 100644 --- a/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java +++ b/solr/src/java/org/apache/solr/search/SolrIndexSearcher.java @@ -38,7 +38,6 @@ import java.io.IOException; import java.net.URL; import java.util.*; -import org.apache.solr.search.function.DocValues; import org.apache.solr.search.function.ValueSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -898,7 +897,8 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean { private static final int NO_CHECK_QCACHE = 0x80000000; private static final int GET_DOCSET = 0x40000000; private static final int NO_CHECK_FILTERCACHE = 0x20000000; - + + public static final int GET_DOCLIST = 0x02; // get the documents actually returned in a response public static final int GET_SCORES = 0x01; @@ -913,6 +913,7 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean { boolean needScores = (cmd.getFlags() & GET_SCORES) != 0; boolean getDocSet = (cmd.getFlags() & GET_DOCSET) != 0; + boolean getDocList = (cmd.getFlags() & GET_DOCLIST) != 0; // doclist needed for debugging or highlighting Query query = QueryUtils.makeQueryable(cmd.getQuery()); final Filter luceneFilter = filter==null ? null : filter.getTopFilter(); @@ -977,6 +978,9 @@ public class SolrIndexSearcher extends IndexSearcher implements SolrInfoMBean { // TODO: optionally cache docs and feed them back through rather than re-searching search(query, luceneFilter, MultiCollector.wrap(phase2Collectors)); + Set idSet = new LinkedHashSet(); // used for tracking unique docs when we need a doclist + int maxMatches = 0; + float maxScore = Float.NEGATIVE_INFINITY; NamedList grouped = new SimpleOrderedMap(); for (int cmdnum=0; cmdnum