Last active
August 29, 2015 14:16
-
-
Save shiplunc/c634c5fc1ac37da046b2 to your computer and use it in GitHub Desktop.
mongodump query with date error "FailedToParse: FailedToParse: Bad characters in value"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check the following bash session carefully to know how this was solved. | |
# In short I just used the milliseconds with Date function | |
ubuntu@production-server:~$ mongodump --collection my_collection --db my_db --query '{"timestamp": {$gt: ISODate("2015-02-01T00: | |
00:00Z")}}' | |
connected to: 127.0.0.1 | |
assertion: 16619 code FailedToParse: FailedToParse: Bad characters in value: offset:19 | |
ubuntu@production-server:~$ mongodump --collection my_collection --db my_db --query '{"timestamp": {$gt:ISODate("2015-02-01T00:0 | |
0:00Z")}}' | |
connected to: 127.0.0.1 | |
assertion: 16619 code FailedToParse: FailedToParse: Bad characters in value: offset:19 | |
ubuntu@production-server:~$ mongodump --collection my_collection --db my_db --query '{timestamp: {$gte:new Date(2015,1,1)}}' | |
connected to: 127.0.0.1 | |
assertion: 16619 code FailedToParse: FailedToParse: First character in field must be [A-Za-z$_]: offset:32 | |
ubuntu@production-server:~$ mongodump --collection my_collection --db my_db --query '{timestamp:{$gte:new Date(2015,1,1)}}' | |
connected to: 127.0.0.1 | |
assertion: 16619 code FailedToParse: FailedToParse: First character in field must be [A-Za-z$_]: offset:31 | |
ubuntu@production-server:~$ mongo | |
MongoDB shell version: 2.4.6 | |
connecting to: test | |
> show dbs | |
admin (empty) | |
image-tracker (empty) | |
my_db 207.8525390625GB | |
image-tracker-split-2 (empty) | |
local 0.078125GB | |
> use my_db | |
switched to db my_db | |
> db.my_collection | |
my_db.my_collection | |
> db.my_collection.find({timestamp:{$gte:new Date(2015,0, 1)}}, {_id: 1}) | |
{ "_id" : ObjectId("54a48e0054ddff85251f877e") } | |
{ "_id" : ObjectId("54a48e0054ddff85251f8787") } | |
{ "_id" : ObjectId("54a48e0154ddff85251f8796") } | |
{ "_id" : ObjectId("54a48e0154ddff85251f8798") } | |
{ "_id" : ObjectId("54a48e0154ddff85251f879d") } | |
{ "_id" : ObjectId("54a48e0254ddff85251f87a5") } | |
{ "_id" : ObjectId("54a48e0254ddff85251f87ae") } | |
{ "_id" : ObjectId("54a48e0354ddff85251f87b7") } | |
{ "_id" : ObjectId("54a48e0454ddff85251f87c3") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f87d8") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f87d9") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f87e5") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f87ea") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f87f8") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f87f9") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f880b") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f880e") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f8810") } | |
{ "_id" : ObjectId("54a48e0554ddff85251f8812") } | |
{ "_id" : ObjectId("54a48e0654ddff85251f881f") } | |
Type "it" for more | |
> db.my_collection.find({timestamp:{$gte:new Date(2015,0, 1)}}, {_id: 1})^C | |
bye | |
ubuntu@production-server:~$ mongodump --collection my_collection --db my_db --query '{"timestamp":{$gte: Date(1422748800000)}}' | |
connected to: 127.0.0.1 | |
Thu Mar 12 10:22:35.296 DATABASE: my_db to dump/my_db | |
Thu Mar 12 10:22:35.301 my_db.my_collection to dump/my_db/my_collection.bson | |
Thu Mar 12 10:22:49.378 Collection File Writing Progress: 100/27100726 0% (objects) | |
Thu Mar 12 10:22:51.264 1681071 objects | |
Thu Mar 12 10:22:51.264 Metadata for my_db.my_collection to dump/my_db/my_collection.metadata.json | |
ubuntu@production-server:~$ ls | |
dump | |
ubuntu@production-server:~$ du --max-depth=1 -h dump | |
379M dump/my_db | |
379M dump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment