Message from discussion
difference between count() and python builtin len()
Received: by 10.58.28.228 with SMTP id e4mr3989311veh.4.1349613679012;
Sun, 07 Oct 2012 05:41:19 -0700 (PDT)
X-BeenThere: mongodb-user@googlegroups.com
Received: by 10.220.107.208 with SMTP id c16ls4000176vcp.3.gmail; Sun, 07 Oct
2012 05:41:10 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.52.65.33 with SMTP id u1mr2220033vds.18.1349613670091; Sun, 07
Oct 2012 05:41:10 -0700 (PDT)
Authentication-Results: ls.google.com; spf=pass (google.com: domain of
alabdeloua...@gmail.com designates internal as permitted sender)
smtp.mail=alabdeloua...@gmail.com; dkim=pass
header...@gmail.com
Received: by y6g2000vbb.googlegroups.com with HTTP; Sun, 7 Oct 2012 05:41:10
-0700 (PDT)
Date: Sun, 7 Oct 2012 05:41:10 -0700 (PDT)
In-Reply-To: <CALKyTE7Hum36nC+SDB=FWQu-dNKJQEZuQ6B8XK8bB06tbrO9_w@mail.gmail.com>
References: <11bc4f95-e2d0-4b72-924a-070b076e7caf@c20g2000vbz.googlegroups.com>
<CALKyTE7LRKexCG6mp28JtTfdQNt=qe2SwcECvqBpGcY5Tj4iJQ@mail.gmail.com>
<DEA765F0-2727-4D54-A110-D4DBDF68EA7C@rainforestapp.com> <ee59b2e6-2a4f-40d0-9522-e68d03f1dab3@g18g2000vbf.googlegroups.com>
<CALKyTE7Hum36nC+SDB=FWQu-dNKJQEZuQ6B8XK8bB06tbrO9_w@mail.gmail.com>
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1
(KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1,gzip(gfe)
Message-ID: <8e9ab160-13ad-447c-b557-50ec72d3eec5@y6g2000vbb.googlegroups.com>
Subject: Re: difference between count() and python builtin len()
From: aliane abdelouahab <alabdeloua...@gmail.com>
To: mongodb-user <mongodb-user@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
ah! now i get it,
it seems that mongodb becomes interresting more and more ;)
thank you :)
On 7 oct, 11:49, Sam Millman <sam.mill...@gmail.com> wrote:
> Unless distinct works differently on the find of geospatial query then no
> since the distinct would have have only two documents to distinct then.
>
> On 6 October 2012 22:52, aliane abdelouahab <alabdeloua...@gmail.com> wro=
te:
>
>
>
>
>
>
>
> > here it's the coordinates, and because there is a duplicated value
> > that it has been omited to return 2 instead of 3?
>
> > On 6 oct, 17:25, Russell Smith <r...@rainforestapp.com> wrote:
> > > Distinct returns unique values for the specified field
>
> > > You may (if I recall correctly) be getting duplicated entires if you
> > have more than one addresse field per document, as it may match twice.
>
> > > Russ
> > > Rainforest =A0| =A0+1-650-919-3216 | =A0rainforestqa.com
>
> > > On Oct 5, 2012, at 2:36 PM, Sam Millman <sam.mill...@gmail.com> wrote=
:
>
> > > > Distinct returns a single bson document, it's not like SQLs distinc=
t,
> > if I remember right the function outputs three fields in that document,=
one
> > being the results.
>
> > > > On 5 October 2012 22:30, aliane abdelouahab <alabdeloua...@gmail.co=
m>
> > wrote:
> > > > hi
> > > > it's a bizarre thing i got:
>
> > > > db.users.find({"adresse.coord":{"$within":{"$center":[[4.365041,
> > > > 36.743954], 100]}}}).distinct("produit_up")
> > > > Out[17]:
> > > > [{u'avatar': {u'avctype': u'image/jpeg',
> > > > =A0 =A0u'orientation': u'portrait',
> > > > =A0 =A0u'photo': ObjectId('506f2ee93a5f3a0528ab8621')},
> > > > =A0 u'spec': {u'abus': 0,
> > > > =A0 =A0u'date': u'2012-10-05',
> > > > =A0 =A0u'description': u'brrrrrrrrrrr',
> > > > =A0 =A0u'id': u'tofla134946378579',
> > > > =A0 =A0u'namep': u'nokia 6230',
> > > > =A0 =A0u'nombre': 2,
> > > > =A0 =A0u'prix': 1000,
> > > > =A0 =A0u'tags': [u'nokia', u'6230', u'photo'],
> > > > =A0 =A0u'vendu': False}},
> > > > =A0{u'avatar': {u'avctype': u'image/jpeg',
> > > > =A0 =A0u'orientation': u'portrait',
> > > > =A0 =A0u'photo': ObjectId('506867863a5f3a0ea84dcd6c')},
> > > > =A0 u'spec': {u'abus': 0,
> > > > =A0 =A0u'date': u'2012-09-30',
> > > > =A0 =A0u'description': u"portable tr\xe8s solide, peu servi, avec b=
atterie
> > > > d'une autonomie de 3 heures.",
> > > > =A0 =A0u'id': u'alucaard134901952647',
> > > > =A0 =A0u'namep': u'nokia 3310',
> > > > =A0 =A0u'nombre': 1,
> > > > =A0 =A0u'prix': 1000,
> > > > =A0 =A0u'tags': [u'portable', u'nokia', u'3310'],
> > > > =A0 =A0u'vendu': False}},
> > > > =A0{u'avatar': {u'avctype': u'image/jpeg',
> > > > =A0 =A0u'orientation': u'portrait',
> > > > =A0 =A0u'photo': ObjectId('506f2b3e3a5f3a0b3c4731a9')},
> > > > =A0 u'spec': {u'abus': 0,
> > > > =A0 =A0u'date': u'2012-10-05',
> > > > =A0 =A0u'description': u'bzzzzzzzzzz',
> > > > =A0 =A0u'id': u'alucaard134946284638',
> > > > =A0 =A0u'namep': u'nokia 6230',
> > > > =A0 =A0u'nombre': 1,
> > > > =A0 =A0u'prix': 2000,
> > > > =A0 =A0u'tags': [u'nokia', u'nok', u'noki'],
> > > > =A0 =A0u'vendu': False}}]
>
> > > > db.users.find({"adresse.coord":{"$within":{"$center":[[4.365041,
> > > > 36.743954], 100]}}}).count()
> > > > Out[18]: 2
>
> > > > len(db.users.find({"adresse.coord":{"$within":{"$center":[[4.365041=
,
> > > > 36.743954], 100]}}}).distinct("produit_up"))
> > > > Out[19]: 3
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "mongodb-user" group.
> > > > To post to this group, send email to mongodb-user@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > mongodb-user+unsubscribe@googlegroups.com
> > > > See also the IRC channel -- freenode.net#mongodb
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "mongodb-user" group.
> > > > To post to this group, send email to mongodb-user@googlegroups.com
> > > > To unsubscribe from this group, send email to
> > > > mongodb-user+unsubscribe@googlegroups.com
> > > > See also the IRC channel -- freenode.net#mongodb
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "mongodb-user" group.
> > To post to this group, send email to mongodb-user@googlegroups.com
> > To unsubscribe from this group, send email to
> > mongodb-user+unsubscribe@googlegroups.com
> > See also the IRC channel -- freenode.net#mongodb