2

I'm using mongodb and i want to take all the files from the collection observations, there are more than 1 millions of files, so i want to take the ones from the last two days.

I'm trying this:

mongodump -d mydb -c observations -q '{timestamp: {$gte: new Date(1448928000000)}}'

My json files is like:

_id : ObjectId(),
loc : Array
creation : Date(),
timestamp : Date(),
user_id ; ObjectId(),
data : object

But the last query returned 0 documents, so I'm probably doing something wrong.

I want to take all these data from the last 2 days, any ideas?

PD: Yes, I was looking for before ask but I don't find nothing usefull for me.

EDIT

Trying this from stackoverflow:

mongodump -d correos -c observations --query "{\"ts\":{\"\$gt\":{\"\$date\":`date -d 2015-09-01 +%s`000},\"\$lte\":{\"\$date\":`date -d 2015-11-05 +%s`000}}}"

I don't get any documents.

Community
  • 1
  • 1
Josete Manu
  • 187
  • 2
  • 16
  • Possible duplicate of [How can I use mongodump to dump out records matching a specific date range?](http://stackoverflow.com/questions/6996999/how-can-i-use-mongodump-to-dump-out-records-matching-a-specific-date-range) – chridam Nov 04 '15 at 12:23
  • I put exactly the same query(changing the date) and mongo response to me with: 2015-11-04T12:34:09.470+0000 0 documents – Josete Manu Nov 04 '15 at 12:29
  • There's a typo in the query that you tried; you copied the query verbatim. Instead of `"{\"ts\": {...`, use the field in your db i.e. `"{\"timestamp\": {`. – chridam Nov 04 '15 at 12:34
  • 1
    Perfect, that worked!!! Thank you !! – Josete Manu Nov 04 '15 at 12:51

0 Answers0