Listing distinct values of a nested structure

46 views
Skip to first unread message

Niko

unread,
Sep 1, 2009, 11:33:55 AM9/1/09
to mongodb-user
Assuming the following objects in my collection:

db.foo.save( { a : { b : "A", c: 1 } } )
db.foo.save( { a : { b : "B", c: 2 } } )
db.foo.save( { a : { b : "C", c: 1 }, d : 1 } )

How would I get out the distinct values for a:b ?
Expected {"A", "B", "C"}

Thanks,
Niko

Eliot Horowitz

unread,
Sep 1, 2009, 11:38:16 AM9/1/09
to mongod...@googlegroups.com
There is no way right now.
We are adding a distinct command that does exactly this though.
You can track here: http://jira.mongodb.org/browse/SERVER-127

Kristina Chodorow

unread,
Sep 1, 2009, 11:40:15 AM9/1/09
to mongod...@googlegroups.com
...and vote for it, if you want it.  We'll implement the stuff with the most votes the fastest :)

Niko

unread,
Sep 1, 2009, 1:01:38 PM9/1/09
to mongodb-user
Yes, I have voted now ...

Currently we have 4 votes on the distinct feature vs. 4 votes on the
slave replication feature http://jira.mongodb.org/browse/SERVER-30
That sounds for quite good chances for both hopefully for being part
of the next release...

In the meantime: is it possible to use grouping to help out on my
problem?

Thanks,
Niko

On Sep 1, 5:40 pm, Kristina Chodorow <krist...@10gen.com> wrote:
> ...and vote for it, if you want it.  We'll implement the stuff with the most
> votes the fastest :)
>
> On Tue, Sep 1, 2009 at 11:38 AM, Eliot Horowitz <eliothorow...@gmail.com>wrote:
>
> > There is no way right now.
> > We are adding a distinct command that does exactly this though.
> > You can track here:http://jira.mongodb.org/browse/SERVER-127
>

Eliot Horowitz

unread,
Sep 1, 2009, 1:28:52 PM9/1/09
to mongod...@googlegroups.com
It would except for this bug: http://jira.mongodb.org/browse/SERVER-257
This should be fixed in 1.1.0 or 1.1.1 at the latest.
Reply all
Reply to author
Forward
0 new messages