can you try "unwind"? here is an example:
db.users.find({"personnel.pseudo":"alucaard"}).distinct("produit_up.spec")
Out[62]:
[{u'abus': 0,
u'date': u'2012-09-30',
u'description': u"portable tr\xe8s solide, peu servi, avec batterie
d'une autonomie de 3 heures.",
u'id': u'alucaard134901952647',
u'namep': u'nokia 3310',
u'nombre': 1,
u'prix': 1000,
u'tags': [u'portable', u'nokia', u'3310'],
u'vendu': False},
{u'abus': 0,
u'date': u'2012-09-30',
u'description': u'\u0646\u0628\u064a\u0639 \u0623\u064a
\u0641\u0648\u0646 \u062c\u062f\u064a\u062f \u0641\u064a
\u0627\u0644\u0628\u0648\u0627\u0637 \u0645\u0639\u0627\u0647
\u0634\u0627\u0631\u062c\u0648\u0631 \u062f\u0648\u0631\u064a\u062c
\u064a\u0646',
u'id': u'alucaard134902092967',
u'namep': u'iphone 3gs',
u'nombre': 1,
u'prix': 20000,
u'tags': [u'iphone', u'3gs', u'apple'],
u'vendu': False},
{u'abus': 0,
u'date': u'2012-09-30',
u'description': u'vends 206 toutes options 2006 hdi.',
u'id': u'alucaard134902099082',
u'namep': u'peugeot 206',
u'nombre': 1,
u'prix': 500000,
u'tags': [u'voiture', u'206', u'hdi'],
u'vendu': False}]
db.users.aggregate([{"$unwind":"$produit_up"},{"$match":
{"produit_up.spec.tags":{"$in":["3310", "iphone", "heloooooo"]}}},
{"$group":{"_id":"$_id","result":
{"$push":"$produit_up.spec.namep"}}}])
Out[63]:
{u'ok': 1.0,
u'result': [{u'_id': ObjectId('5061fab93a5f3a09f4be0e21'),
u'result': [u'nokia 3310', u'iphone 3gs']}]}
On 3 oct, 21:07, MKN Web Solutions <
mich...@mknwebsolutions.com>
wrote:
> *Index for "tags":*
> {
> "v" : 1,
> "key" : {
> "tags" : NumberLong(1)},
>
> "ns" : "xxx.xxx",
> "background" : NumberLong(1),
> "name" : "tags"
>
> }
>
> *Distinct output: **Note, these tags don't reflect the example I posted
> above - these are the true tags.*> db.xxx.distinct("tags")
> *Mongo Query: (All tags)*> db.xxx.find({"tags":{"$in":["massage","hotels","yoga","skin
>
> care","massage","yogurt","art","wine","detailing","photography","tours","am erican","mexican","spa","sporting
> goods","baked
> goods","food","hotels","sushi","fishing","amusement","automotive","coffee", "golf","pets","adventure","health","fitness","services","retail"]}}).count( )
> 88
>
> *Mongo Query: (All)*> db.xxx.find().count()
> > > To post to this group, send email to
mongod...@googlegroups.com<javascript:>
> > > To unsubscribe from this group, send email to
> > >
mongodb-user...@googlegroups.com <javascript:>