in the shell I can run:
db.Hosts.find( { “Group Name” :{$exists: true}}, { _id:0, “Group Name”:1 } ).sort( { “Group Name”: 1 } );
And the results are as expected.
Hi John,
You can do the equivalent of the find() query above in Perl’s aggregate like below:
my @pipeline = (
{ '$match' => { 'Group Name' => { '$exists' => 1 }}},
{ '$group' => { '_id' => '$Group Name' }},
{ '$sort' => { '_id' => 1 }}
);
my $cursor = $collection->aggregate(\@pipeline);
It should returns the result sorted by Group Name field. You could also rename _id field back to Group Name by using $project operator.
When I move over to the perl I am writing and try to aggregate all the info about each of the hosts in each group, I get all the info I want but the sort is off so that the groups are not presented in alphabetical order as they are in the above simple shell query.
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
---
You received this message because you are subscribed to a topic in the Google Groups "mongodb-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mongodb-user/7wf5UOaCYOQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/0aa6765c-d79b-4219-8ff9-a86cbdf2755c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.