1

在 pymongo 我正在做这样的排序查询:

from pymongo import MongoClient
client = MongoClient()
dbase = client[dbname]
collection = dbase[symbol]
start = time.time()
cursor = collection.find().sort([{'_id', -1}]).limit(6000)
data = list(cursor)

现在尝试在 R 中做同样的事情......

library("RMongo")
mongo <- mongoDbConnect("dbname", "localhost", 27017) 
query = '{sort({_id: -1})}'
output <- dbGetQuery(mongo, "symbol", query, skip=0, limit=6000)

> output
data frame with 0 columns and 0 rows

这里正确的 JSON 查询字符串格式是什么?

4

1 回答 1

0

用蒙古石想通了....

library('mongolite')
con <- mongo("collection_name", url = "mongodb://localhost:27017/dbname")
output <- con$find('{}', sort='{"_id":-1}', limit=6000)
于 2017-04-12T21:55:06.110 回答