[SERVER-2293] Distinct can't process more than one key Created: 28/Dec/10  Updated: 06/Dec/22  Resolved: 09/Mar/18

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 1.6.5
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: xuqing Assignee: Backlog - Query Team (Inactive)
Resolution: Done Votes: 10
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

OS:Win7 Enterprise x64


Issue Links:
Related
is related to SERVER-447 new aggregation framework Closed
Assigned Teams:
Query
Participants:

 Description   

I have a request to distinct some data with more keys.But in mongo client or program,It can only distinct one key.I have to hand my data in C# with linq.Does this be support in the feature?



 Comments   
Comment by Asya Kamsky [ 09/Mar/18 ]

This can be done using aggregation framework.

Something similar to:

db.coll.aggregate([{$group:{_id:{key1:"$key1", key2:"$key2", key3:"$key3"}}}])

Comment by Artur Rodrigues [ 03/Oct/12 ]

Is this available within the Aggregation Framework. The link provided bu Chris is dead.

Comment by Chris Westin [ 31/May/11 ]

Until this is done directly, you can achieve this effect using group by following the instructions here: http://groups.google.com/group/fametest/browse_thread/thread/5f571f39ee79b75f/8781be252dfa8f39#8781be252dfa8f39 .

Comment by Eliot Horowitz (Inactive) [ 28/Dec/10 ]

Yes - we should do this.

Comment by xuqing [ 28/Dec/10 ]

for example:
use test;
db.test.distinct(

{"key1":true,"key2":true,"key3":true}

);
this is like this sql in relation database:
SELECT DISTINCT key1,key2,key3 FROM test;

and sometimes I need to distinct some data with filter.the sql like below:
SELECT DISTINCT key1,key2,key3 FROM test WHERE iState!=0

but at this moment,mongo's distinct can only work as:
db.test.distinct("key1");

Comment by Eliot Horowitz (Inactive) [ 28/Dec/10 ]

Do you mean distinct tuples?
Can you give an example?

Generated at Thu Feb 08 02:59:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.