RMongo dbGetQueryForKeys returns NA

北战南征 提交于 2020-01-14 09:39:06

问题


I'm using the dbGetQueryForKeys function (which I learned about here), and don't seem to be getting proper return values---it collects the right keys, but the values are all NA.

Here's my query in the mongo console, which produces what I expect:

db.final.find({},{"ids.myid":1,"org.name":1,"_id":0}).skip(0).limit(5000)

This produces the list of...

{"ids" : {"myid": "123"}, "org": {"name": "Fred"}},

However, the equivalent in RMongo:

dbGetQueryForKeys(db,'final', '{}','{"ids.myid":1,"org.name":1,"_id":0}',skip=0,limit=5000)

Produces

    ids.myid         org.name X_id
1         NA               NA   NA
2         NA               NA   NA
3         NA               NA   NA

There are a couple problems:

  1. It has NAs for everything
  2. The X_id column is still there, even though it was 0'd.

But it does correctly /omit/ all the rest of the keys, so it's clearly recognizing the command at some level, just returning the wrong values for these.

Now, documentation says this:

 The output is a data.frame object
 and will work properly only if the mongoDB collection contains
 primitive data types. It may not work properly if there are any
 embedded documents or arrays.

This seems like the likely problem in that I am querying nested variables. However, the return values of those nestings are themselves singular, ids.myid and org.name are both strings and not arrays. Still, is this really the case? RMongo only works for completely flat collections with no nesting whatsoever?

来源:https://stackoverflow.com/questions/22098799/rmongo-dbgetqueryforkeys-returns-na

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!