use of org.apache.solr.search.grouping.Command 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;
}
use of org.apache.solr.search.grouping.Command in project lucene-solr by apache.
the class TopGroupsResultTransformer method transform.
/**
* {@inheritDoc}
*/
@Override
public NamedList transform(List<Command> data) throws IOException {
NamedList<NamedList> result = new NamedList<>();
final IndexSchema schema = rb.req.getSearcher().getSchema();
for (Command command : data) {
NamedList commandResult;
if (TopGroupsFieldCommand.class.isInstance(command)) {
TopGroupsFieldCommand fieldCommand = (TopGroupsFieldCommand) command;
SchemaField groupField = schema.getField(fieldCommand.getKey());
commandResult = serializeTopGroups(fieldCommand.result(), groupField);
} else if (QueryCommand.class.isInstance(command)) {
QueryCommand queryCommand = (QueryCommand) command;
commandResult = serializeTopDocs(queryCommand.result());
} else {
commandResult = null;
}
result.add(command.getKey(), commandResult);
}
return result;
}
Aggregations