Re: Re: Find duplicates in array field

From: Asya Kamsky <asya@xxxxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Wed, 27 Apr 2016 09:31:07 -0700
Why ads?
The syntax is wrong, should be:

{"$group" : { _id: { "$arrayElemAt:["$a1", 0]", "count": { "$sum": 1 } } }

It would help if you indicated what happens when it "doesn't work" -
do you get an error?

What version of MongoDB are you using?

Asya


On Tue, Apr 26, 2016 at 12:48 AM, Szaniszlo Szöke
<szoke.szaniszlo@xxxxxxxxx> wrote:
Thanks for the advise.
I tried a bunch of different syntax, like this one:

{"$group" : { _id: "$arrayElemAt:[$a1, 0]", "count": { "$sum": 1 } } }
{"$match": {"count" : {"$gt": 1} } }
{"$project": {"arrayElemAt:[$a1, 0]" : "$_id", "_id" : 1} }

to no avail. I can't get the number of documents having one precise element
of array a1 duplicated (in this sample the first one, could be any other
one).

Any idea ?

--
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 the Google Groups
"mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
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/b9fe984f-216f-4173-a7b9-8232690d1d44%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



-- 
Asya Kamsky
Lead Product Manager
MongoDB
Download MongoDB - mongodb.org/downloads
Free MongoDB Monitoring - cloud.mongodb.com
Free Online Education - university.mongodb.com
Get Involved - mongodb.org/community
We're Hiring! - https://www.mongodb.com/careers

-- 
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 the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
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/CAOe6dJCFQ-tBghjus1uZbBZAJi6yCOqTd0dR5xxJMWdpgYmW-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Why ads?