use of org.apache.lucene.search.grouping.TopGroupsCollector in project lucene-solr by apache.
the class TopGroupsFieldCommand method create.
@Override
public List<Collector> create() throws IOException {
if (firstPhaseGroups.isEmpty()) {
return Collections.emptyList();
}
final List<Collector> collectors = new ArrayList<>(1);
final FieldType fieldType = field.getType();
if (fieldType.getNumberType() != null) {
ValueSource vs = fieldType.getValueSource(field, null);
Collection<SearchGroup<MutableValue>> v = GroupConverter.toMutable(field, firstPhaseGroups);
secondPassCollector = new TopGroupsCollector<>(new ValueSourceGroupSelector(vs, new HashMap<>()), v, groupSort, withinGroupSort, maxDocPerGroup, needScores, needMaxScore, true);
} else {
secondPassCollector = new TopGroupsCollector<>(new TermGroupSelector(field.getName()), firstPhaseGroups, groupSort, withinGroupSort, maxDocPerGroup, needScores, needMaxScore, true);
}
collectors.add(secondPassCollector);
return collectors;
}
Aggregations