I'm using mongodb 2.6 and trying to create a dump using the query option gives "positional arguments not allowed".
I am trying to get all the products who parameter's timestamp is between specified range and whose id is of any of the specified format.
mongodump --host 10.xx.xxx.xx:xxxx --db test --collection products --username abc --password uvw --query '{"parameterList":{$elemMatch:{ "paramName":"TimeStamp","paramValue":{$gte:"20160620000000",$lt:"20160724000000"}}},"parameterList.paramValue": {$in:[/SPC126/,/CSC234/]}}' --authenticationDatabase test --out "c:\New folder\dump"
document structure
{
"_id": ObjectId("590074c362f41f15144996fa"),
"product": "device1",
"parameterList":[{"paramName":"TimeStamp",
"paramValue":"20160731000700"},
{"paramName":"Id",
"paramValue": "SPC126332"}]
}
Unlike UNIX bash
, Windows cmd.exe
doesn't recognize single quotes as a delimiter.
Running your example command as-is in cmd.exe
gives the error:
Error parsing command line: too many positional options
Try changing your quotes around, replacing the single quotes with double quotes and vice versa. For example, using the example command you posted:
mongodump --host 10.xx.xxx.xx:xxxx --db test --collection products --username abc --password uvw --query "{'parameterList':{$elemMatch:{ 'paramName':'TimeStamp','paramValue':{$gte:'20160620000000',$lt:'20160724000000'}}},'parameterList.paramValue': {$in:[/SPC126/,/CSC234/]}}" --authenticationDatabase test --out "c:\New folder\dump"
Note the --query "..."
instead of --query '...'
in the example above.
It should be able to complete the dump successfully.