Search in sources :

Example 1 with TopGroupsCollector

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;
}
Also used : SearchGroup(org.apache.lucene.search.grouping.SearchGroup) ValueSource(org.apache.lucene.queries.function.ValueSource) ArrayList(java.util.ArrayList) Collector(org.apache.lucene.search.Collector) TopGroupsCollector(org.apache.lucene.search.grouping.TopGroupsCollector) ValueSourceGroupSelector(org.apache.lucene.search.grouping.ValueSourceGroupSelector) TermGroupSelector(org.apache.lucene.search.grouping.TermGroupSelector) FieldType(org.apache.solr.schema.FieldType)

Aggregations

ArrayList (java.util.ArrayList)1 ValueSource (org.apache.lucene.queries.function.ValueSource)1 Collector (org.apache.lucene.search.Collector)1 SearchGroup (org.apache.lucene.search.grouping.SearchGroup)1 TermGroupSelector (org.apache.lucene.search.grouping.TermGroupSelector)1 TopGroupsCollector (org.apache.lucene.search.grouping.TopGroupsCollector)1 ValueSourceGroupSelector (org.apache.lucene.search.grouping.ValueSourceGroupSelector)1 FieldType (org.apache.solr.schema.FieldType)1