Querying and Limit in mongoexport

2,568 views
Skip to first unread message

Adam

unread,
Aug 3, 2010, 11:47:41 AM8/3/10
to mongodb-user
I have a collection of large objects with multiple fields and embedded
objects stored in MongoDB.
My main goal is to translate this (retrieving a subset of fields)
query to the correct query format for mongoexport:

db.things.find( { }, { subscriber.id : 1 } ).limit(10);

I got this to work somewhat without a limit just by specifying the csv
fields as subscriber.id without any query at all.

Now, I am doing a query like this for mongoexport (I know it has to be
strict JSON)
--query "{ 'subscriber' : { 'id': { '$lt' : 2000 } } }"

Where I have a embedded subscriber object and within that object there
is a field id.

Not only is that not returning any results, but also I would like to
use $limit not less than.

I assume I do --query "{ 'subscriber' : { 'id': { '$limit' :
20 } } }" or something like that.

Can somewhat help me out. I'm sure its extremely simple. Thanks.

Kyle Banker

unread,
Aug 3, 2010, 11:58:28 AM8/3/10
to mongod...@googlegroups.com
Have you tried:

--query  "{ 'subscriber.id': { '$lt' : 2000 } } }"

There's no way to specify a limit for mongoexport at the moment. If you're just limited to a few results, you might just write those to a temporary collection and then export that. Otherwise, feel free to open a JIRA to add limit to mongoexport.




--
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.
For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.


cwruss

unread,
Aug 11, 2010, 1:42:26 PM8/11/10
to mongodb-user
Hi,

Out of curiosity, how does one go about writing results to a temporary
collection? if you could tell me how to do that that would be
extremely helpful! Thanks!
> > mongodb-user...@googlegroups.com<mongodb-user%2Bunsubscribe@google groups.com>
> > .

Kyle Banker

unread,
Aug 11, 2010, 2:17:57 PM8/11/10
to mongod...@googlegroups.com
Temporary collections are built by running map-reduce jobs. If you're not using map-reduce, you probably best just writing a script that manually builds a temporary collection as you need it.

To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.

cwruss

unread,
Aug 11, 2010, 5:16:23 PM8/11/10
to mongodb-user
I've been having problems getting anything to export using a query.. I
keep getting this error:

terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::program_options::too_many_positional_options_error>
>'
what(): too many positional options

the query I'm trying to run is pretty simple I'm not sure what 'too
many positional options' means..

Thanks!

Eliot Horowitz

unread,
Aug 12, 2010, 12:04:05 AM8/12/10
to mongod...@googlegroups.com
Is that with mongoexport?
Can you send the exact command you are using?

> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages