Re: [mongodb-user] how to make returning partial matching array elements of a document.

44 views
Skip to first unread message

Eliot Horowitz

unread,
Jul 16, 2012, 8:02:10 AM7/16/12
to mongod...@googlegroups.com
There isn't a way in 2.0, but 2.2 added a new feature you can use:
https://jira.mongodb.org/browse/SERVER-2238

On Mon, Jul 16, 2012 at 3:06 AM, Onkar Lal Janwa
<er.onk...@gmail.com> wrote:
> I am showing an example of mongodb collection document structure. I have
> also shown my expected result while making query which i have shown.
>
> Document Structure::
>
> {
> _id : "132423423",
> name : "hi_code",
> my_entries : [
> {
> e_id : "12345",
> e_name : "f1",
> e_posted : "2010-05-01",
> },
> {
> e_id : "12346",
> e_name : "f2",
> e_posted : "2010-06-01",
> },
> {
> e_id : "12346",
> e_name : "f3",
> e_posted : "2010-03-02",
> }
> ]
> }
>
> Query Structure::
>
> db.myCollection.find( { my_entries : { $elemMatch : { e_posted :
> "2010-06-01",
> e_name : "f2" } } } )
>
> Expected Result::
>
> {
> _id : "132423423",
> name : "hi_code",
> my_entries : [
> {
> e_id : "12346",
> e_name : "f2",
> e_posted : "2010-06-01",
> }
> ]
> }
>
> I don't want to use map reduce for this because i am working on big database
> which will make it slow performance, just want to make it possible only by
> find query.
>
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
Reply all
Reply to author
Forward
0 new messages