Search in sources :

Example 1 with SearchGroupsFieldCommand

use of org.apache.solr.search.grouping.distributed.command.SearchGroupsFieldCommand in project lucene-solr by apache.

the class SearchGroupsResultTransformer method transform.

/**
   * {@inheritDoc}
   */
@Override
public NamedList transform(List<Command> data) throws IOException {
    final NamedList<NamedList> result = new NamedList<>(data.size());
    for (Command command : data) {
        final NamedList<Object> commandResult = new NamedList<>(2);
        if (SearchGroupsFieldCommand.class.isInstance(command)) {
            SearchGroupsFieldCommand fieldCommand = (SearchGroupsFieldCommand) command;
            final SearchGroupsFieldCommandResult fieldCommandResult = fieldCommand.result();
            final Collection<SearchGroup<BytesRef>> searchGroups = fieldCommandResult.getSearchGroups();
            if (searchGroups != null) {
                commandResult.add(TOP_GROUPS, serializeSearchGroup(searchGroups, fieldCommand));
            }
            final Integer groupedCount = fieldCommandResult.getGroupCount();
            if (groupedCount != null) {
                commandResult.add(GROUP_COUNT, groupedCount);
            }
        } else {
            continue;
        }
        result.add(command.getKey(), commandResult);
    }
    return result;
}
Also used : Command(org.apache.solr.search.grouping.Command) SearchGroupsFieldCommand(org.apache.solr.search.grouping.distributed.command.SearchGroupsFieldCommand) SearchGroup(org.apache.lucene.search.grouping.SearchGroup) NamedList(org.apache.solr.common.util.NamedList) SearchGroupsFieldCommand(org.apache.solr.search.grouping.distributed.command.SearchGroupsFieldCommand) SearchGroupsFieldCommandResult(org.apache.solr.search.grouping.distributed.command.SearchGroupsFieldCommandResult)

Aggregations

SearchGroup (org.apache.lucene.search.grouping.SearchGroup)1 NamedList (org.apache.solr.common.util.NamedList)1 Command (org.apache.solr.search.grouping.Command)1 SearchGroupsFieldCommand (org.apache.solr.search.grouping.distributed.command.SearchGroupsFieldCommand)1 SearchGroupsFieldCommandResult (org.apache.solr.search.grouping.distributed.command.SearchGroupsFieldCommandResult)1