Search in sources :

Example 1 with QueryCommand

use of org.apache.solr.search.grouping.distributed.command.QueryCommand 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;
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) TopGroupsFieldCommand(org.apache.solr.search.grouping.distributed.command.TopGroupsFieldCommand) QueryCommand(org.apache.solr.search.grouping.distributed.command.QueryCommand) Command(org.apache.solr.search.grouping.Command) TopGroupsFieldCommand(org.apache.solr.search.grouping.distributed.command.TopGroupsFieldCommand) NamedList(org.apache.solr.common.util.NamedList) QueryCommand(org.apache.solr.search.grouping.distributed.command.QueryCommand) IndexSchema(org.apache.solr.schema.IndexSchema)

Aggregations

NamedList (org.apache.solr.common.util.NamedList)1 IndexSchema (org.apache.solr.schema.IndexSchema)1 SchemaField (org.apache.solr.schema.SchemaField)1 Command (org.apache.solr.search.grouping.Command)1 QueryCommand (org.apache.solr.search.grouping.distributed.command.QueryCommand)1 TopGroupsFieldCommand (org.apache.solr.search.grouping.distributed.command.TopGroupsFieldCommand)1