Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projection problem ? #25

Open
Ryo51289 opened this issue Dec 16, 2013 · 0 comments
Open

Projection problem ? #25

Ryo51289 opened this issue Dec 16, 2013 · 0 comments

Comments

@Ryo51289
Copy link

Here is my data test store in MongoDB

{
        "_id" : ObjectId("52983ff67dbf497a8bb0192b"),
        "data" : [
                {
                        "LoadPct" : 10,
                        "RECORD_SEQ" : 1
                }
        ]
}
{
        "_id" : ObjectId("5298400b7dbf497a8bb0192d"),
        "data" : [
                {
                        "LoadPct" : 59,
                        "RECORD_SEQ" : 2
                }
        ]
}
{
        "_id" : ObjectId("529840217dbf497a8bb01934"),
        "data" : [
                {
                        "LoadPct" : 8,
                        "RECORD_SEQ" : 3
                }
        ]
}
....

I can not perform a query to get data like result of following query when i run it on mongo shell

db.collect.find({'data.LoadPct':{$gt:10}},{'data.LoadPct':1}).forEach(printjson)
{
        "_id" : ObjectId("5298404d7dbf497a8bb01942"),
        "data" : [
                {
                        "LoadPct" : 59
                }
        ]
}
......

My R-Code to get result like above query

data <- dbGetQueryForKeys(mongoConn,"collect","{'data.LoadPct':{'$gt':10}}","{'data.LoadPct':1}")

and data return

 data.LoadPct                     X_id
1           NA 5298400b7dbf497a8bb0192d
2           NA 5298404d7dbf497a8bb01942
3           NA 5298408c7dbf497a8bb019a2
4           NA 529840cc7dbf497a8bb019f5
5           NA 529840d17dbf497a8bb019fc
.....

other code

data <- dbGetQueryForKeys(mongoConn,"collect","{'data.LoadPct':{'$gt':10}}","{'data':1,data.LoadPct:1}")

result

                  data data.LoadPct                     X_id
1 [ { "LoadPct" : 59}]           NA 5298400b7dbf497a8bb0192d
2 [ { "LoadPct" : 24}]           NA 5298404d7dbf497a8bb01942
3 [ { "LoadPct" : 50}]           NA 5298408c7dbf497a8bb019a2
4 [ { "LoadPct" : 22}]           NA 529840cc7dbf497a8bb019f5
5 [ { "LoadPct" : 11}]           NA 529840d17dbf497a8bb019fc
.....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant