Package com.mongodb

Examples of com.mongodb.DBCollection.aggregate()


        // Allow body to be a pipeline
        // @see http://docs.mongodb.org/manual/core/aggregation/
        if (query instanceof BasicDBList) {
            BasicDBList queryList = (BasicDBList)query;
            aggregationResult = dbCol.aggregate((DBObject)queryList.get(0), queryList
                .subList(1, queryList.size()).toArray(new BasicDBObject[queryList.size() - 1]));
        } else {
            aggregationResult = dbCol.aggregate(query);
        }
View Full Code Here


        if (query instanceof BasicDBList) {
            BasicDBList queryList = (BasicDBList)query;
            aggregationResult = dbCol.aggregate((DBObject)queryList.get(0), queryList
                .subList(1, queryList.size()).toArray(new BasicDBObject[queryList.size() - 1]));
        } else {
            aggregationResult = dbCol.aggregate(query);
        }

        dbIterator = aggregationResult.results();
        Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.aggregate);
        resultMessage.setBody(dbIterator);
View Full Code Here

            // Allow body to be a pipeline
            // @see http://docs.mongodb.org/manual/core/aggregation/
            if (query instanceof BasicDBList) {
                BasicDBList queryList = (BasicDBList)query;
                aggregationResult = dbCol.aggregate((DBObject)queryList.get(0), (BasicDBObject[])queryList
                    .subList(1, queryList.size()).toArray(new BasicDBObject[queryList.size() - 1]));
            } else {
                aggregationResult = dbCol.aggregate(query);
            }
View Full Code Here

            if (query instanceof BasicDBList) {
                BasicDBList queryList = (BasicDBList)query;
                aggregationResult = dbCol.aggregate((DBObject)queryList.get(0), (BasicDBObject[])queryList
                    .subList(1, queryList.size()).toArray(new BasicDBObject[queryList.size() - 1]));
            } else {
                aggregationResult = dbCol.aggregate(query);
            }

            dbIterator = aggregationResult.results();
            Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.aggregate);
            resultMessage.setBody(dbIterator);
View Full Code Here

            // Allow body to be a pipeline
            // @see http://docs.mongodb.org/manual/core/aggregation/
            if (query instanceof BasicDBList) {
                BasicDBList queryList = (BasicDBList)query;
                aggregationResult = dbCol.aggregate((DBObject)queryList.get(0), queryList
                    .subList(1, queryList.size()).toArray(new BasicDBObject[queryList.size() - 1]));
            } else {
                aggregationResult = dbCol.aggregate(query);
            }
View Full Code Here

            if (query instanceof BasicDBList) {
                BasicDBList queryList = (BasicDBList)query;
                aggregationResult = dbCol.aggregate((DBObject)queryList.get(0), queryList
                    .subList(1, queryList.size()).toArray(new BasicDBObject[queryList.size() - 1]));
            } else {
                aggregationResult = dbCol.aggregate(query);
            }

            dbIterator = aggregationResult.results();
            Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.aggregate);
            resultMessage.setBody(dbIterator);
View Full Code Here

        // Allow body to be a pipeline
        // @see http://docs.mongodb.org/manual/core/aggregation/
        if (query instanceof BasicDBList) {
            BasicDBList queryList = (BasicDBList)query;
            aggregationResult = dbCol.aggregate((DBObject)queryList.get(0), queryList
                .subList(1, queryList.size()).toArray(new BasicDBObject[queryList.size() - 1]));
        } else {
            aggregationResult = dbCol.aggregate(query);
        }
View Full Code Here

        if (query instanceof BasicDBList) {
            BasicDBList queryList = (BasicDBList)query;
            aggregationResult = dbCol.aggregate((DBObject)queryList.get(0), queryList
                .subList(1, queryList.size()).toArray(new BasicDBObject[queryList.size() - 1]));
        } else {
            aggregationResult = dbCol.aggregate(query);
        }

        dbIterator = aggregationResult.results();
        Message resultMessage = prepareResponseMessage(exchange, MongoDbOperation.aggregate);
        resultMessage.setBody(dbIterator);
View Full Code Here

                    Template helloTemplate = configuration.getTemplate("answer.ftl");

                    // Not necessary yet to understand this.  It's just to prove that you
                    // are able to run a command on a mongod server
                    AggregationOutput output =
                            collection.aggregate(
                                    new BasicDBObject("$group",
                                            new BasicDBObject("_id", "$value")
                                                    .append("count", new BasicDBObject("$sum", 1)))
                                    ,
                                    new BasicDBObject("$match", new BasicDBObject("count",
View Full Code Here

        // Finally the $sort operation
        DBObject sort = new BasicDBObject("$sort", new BasicDBObject("average", -1));

        // run aggregation
        List<DBObject> pipeline = Arrays.asList(match, project, group, sort);
        AggregationOutput output = coll.aggregate(pipeline);

        // Output the results
        for (DBObject result : output.results()) {
            System.out.println(result);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.